config?
This commit is contained in:
35
internal/config/configFile.go
Normal file
35
internal/config/configFile.go
Normal file
@ -0,0 +1,35 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"io/ioutil"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type configFileStruct struct {
|
||||
AllowAdminNoMutate bool `yaml:"allow-admin-nomutate"`
|
||||
AllowAdminNoMutateToggle string `yaml:"allow-admin-nomutate-toggle"`
|
||||
DockerhubRegistry string `yaml:"dockerhub-registry"`
|
||||
MutateIgnoredImages []string `yaml:"mutate-ignored-images"`
|
||||
}
|
||||
|
||||
func getConfigFileData(fileLocation string) (configFileStruct, error) {
|
||||
// does file exist
|
||||
if _, err := os.Stat(fileLocation); os.IsNotExist(err) {
|
||||
return configFileStruct{}, err
|
||||
}
|
||||
// read file
|
||||
rd, err := ioutil.ReadFile(fileLocation)
|
||||
if err != nil {
|
||||
return configFileStruct{}, err
|
||||
}
|
||||
// convert config file data to struct
|
||||
var output configFileStruct
|
||||
if err := yaml.Unmarshal(rd, &output); err != nil {
|
||||
return output, err
|
||||
}
|
||||
|
||||
return output, nil
|
||||
}
|
Reference in New Issue
Block a user