MCPcopy Index your code
hub / github.com/devspace-sh/devspace / ensureRequires

Method ensureRequires

pkg/devspace/config/loader/loader.go:200–294  ·  view source on GitHub ↗
(ctx context.Context, config *latest.Config, log log.Logger)

Source from the content-addressed store, hash-verified

198}
199
200func (l *configLoader) ensureRequires(ctx context.Context, config *latest.Config, log log.Logger) error {
201 if config == nil {
202 return nil
203 }
204
205 var aggregatedErrors []error
206
207 if config.Require.DevSpace != "" {
208 parsedConstraint, err := constraint.NewConstraint(config.Require.DevSpace)
209 if err != nil {
210 return errors.Wrap(err, "parsing require.devspace")
211 }
212
213 v, err := constraint.NewSemver(upgrade.GetVersion())
214 if err != nil {
215 return errors.Wrap(err, "parsing devspace version")
216 }
217
218 if !parsedConstraint.Check(v) {
219 aggregatedErrors = append(aggregatedErrors, fmt.Errorf("DevSpace version mismatch: %s (currently installed) does not match %s (required by config). Please make sure you have installed DevSpace with version %s", upgrade.GetVersion(), config.Require.DevSpace, config.Require.DevSpace))
220 }
221 }
222
223 if len(config.Require.Plugins) > 0 {
224 pluginClient := plugin.NewClient(log)
225 for index, p := range config.Require.Plugins {
226 _, metadata, err := pluginClient.GetByName(p.Name)
227 if err != nil {
228 aggregatedErrors = append(aggregatedErrors, fmt.Errorf("cannot find plugin '%s' (%v), however it is required by the config. Please make sure you have installed the plugin '%s' with version %s", p.Name, err, p.Name, p.Version))
229 continue
230 } else if metadata == nil {
231 aggregatedErrors = append(aggregatedErrors, fmt.Errorf("cannot find plugin '%s', however it is required by the config. Please make sure you have installed the plugin '%s' with version %s", p.Name, p.Name, p.Version))
232 continue
233 }
234
235 parsedConstraint, err := constraint.NewConstraint(p.Version)
236 if err != nil {
237 return errors.Wrapf(err, "parsing require.plugins[%d].version", index)
238 }
239
240 v, err := constraint.NewSemver(metadata.Version)
241 if err != nil {
242 return errors.Wrapf(err, "parsing plugin %s version", p.Name)
243 }
244
245 if !parsedConstraint.Check(v) {
246 aggregatedErrors = append(aggregatedErrors, fmt.Errorf("plugin '%s' version mismatch: %s (currently installed) does not match %s (required by config). Please make sure you have installed the plugin '%s' with version %s", p.Name, metadata.Version, p.Version, p.Name, p.Version))
247 }
248 }
249 }
250
251 for index, c := range config.Require.Commands {
252 regExString := c.VersionRegEx
253 if regExString == "" {
254 regExString = DefaultCommandVersionRegEx
255 }
256
257 versionArgs := c.VersionArgs

Callers 1

LoadWithParserMethod · 0.95

Calls 8

CheckMethod · 0.95
NewConstraintFunction · 0.92
NewSemverFunction · 0.92
GetVersionFunction · 0.92
NewClientFunction · 0.92
GetByNameMethod · 0.65
EnvironMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected