-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: export projectconfig for ext use
- Loading branch information
1 parent
498a668
commit 130bcb4
Showing
7 changed files
with
61 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package projectconfig | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"os" | ||
|
||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
var ErrNotFound = fmt.Errorf("could not find config file") | ||
var ErrParse = fmt.Errorf("error parsing config file") | ||
|
||
func Parse(cfgPath string) (*ProjectSpec, error) { | ||
cfg := &ProjectSpec{} | ||
b, err := os.ReadFile(cfgPath) | ||
if err != nil { | ||
return nil, errors.Join(ErrNotFound, err) | ||
} | ||
|
||
// parse yaml | ||
err = yaml.Unmarshal(b, cfg) | ||
if err != nil { | ||
return nil, errors.Join(ErrParse, err) | ||
} | ||
return cfg, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters