MCPcopy Index your code
hub / github.com/commitdev/zero / LoadModuleConfig

Function LoadModuleConfig

internal/config/moduleconfig/module_config.go:130–162  ·  view source on GitHub ↗
(filePath string)

Source from the content-addressed store, hash-verified

128}
129
130func LoadModuleConfig(filePath string) (ModuleConfig, error) {
131 config := ModuleConfig{}
132
133 data, err := ioutil.ReadFile(filePath)
134 if err != nil {
135 return config, err
136 }
137
138 err = yaml.Unmarshal(data, &config)
139 if err != nil {
140 return config, err
141 }
142
143 missing := config.collectMissing()
144 if len(missing) > 0 {
145 flog.Errorf("%v is missing information", filePath)
146
147 for _, m := range missing {
148 flog.Errorf("\t %v", m)
149 }
150
151 log.Fatal("")
152 }
153
154 if !ValidateZeroVersion(config) {
155 constraint := config.ZeroVersion.Constraints.String()
156 errTpl := `Module(%s) requires Zero to be version %s. Your current Zero version is: %s
157Please update your Zero version to %s.
158Please check %s for available releases.`
159 return config, errors.New(fmt.Sprintf(errTpl, config.Name, constraint, version.AppVersion, constraint, constants.ZeroReleaseURL))
160 }
161 return config, nil
162}
163
164// Recurses through a datastructure to find any missing data.
165// This assumes several things:

Callers 1

ParseModuleConfigFunction · 0.92

Calls 3

collectMissingMethod · 0.95
ErrorfFunction · 0.92
ValidateZeroVersionFunction · 0.85

Tested by

no test coverage detected