Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add some custom yaml unmarshalling rules to add default values
where go-flags ones aren't applicable
- Loading branch information
Showing
3 changed files
with
34 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package config | ||
|
||
/********************************************* | ||
* Custom UnmarshalYAML used to define some struct fields | ||
* default values where go-flags ones aren't applicable | ||
* (and so makes them optional) | ||
*********************************************/ | ||
|
||
func (s *S3BucketConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { | ||
type rawS3BucketConfig S3BucketConfig | ||
raw := rawS3BucketConfig{ | ||
FileExtension: []string{".tfstate"}, | ||
} | ||
if err := unmarshal(&raw); err != nil { | ||
return err | ||
} | ||
|
||
*s = S3BucketConfig(raw) | ||
return nil | ||
} | ||
|
||
func (s *GitlabConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { | ||
type rawGitlabConfig GitlabConfig | ||
raw := GitlabConfig{ | ||
Address: "https://gitlab.com", | ||
} | ||
if err := unmarshal(&raw); err != nil { | ||
return err | ||
} | ||
|
||
*s = GitlabConfig(raw) | ||
return 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