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

Function validateProfile

pkg/devspace/config/loader/loader.go:379–453  ·  view source on GitHub ↗
(profile interface{})

Source from the content-addressed store, hash-verified

377}
378
379func validateProfile(profile interface{}) error {
380 profileMap, ok := profile.(map[string]interface{})
381 if !ok {
382 return fmt.Errorf("profile is not an object")
383 }
384
385 parents := profileMap["parents"]
386 if parents != nil {
387 parentsString, ok := parents.(string)
388 if ok {
389 if vars.VarMatchRegex.MatchString(parentsString) {
390 return fmt.Errorf("parents cannot be a variable")
391 }
392
393 if expression.ExpressionMatchRegex.MatchString(parentsString) {
394 return fmt.Errorf("parents cannot be an expression")
395 }
396
397 return fmt.Errorf("parents is not an array")
398 }
399 }
400
401 activation := profileMap["activation"]
402 if activation != nil {
403 activationString, ok := activation.(string)
404 if ok {
405 if vars.VarMatchRegex.MatchString(activationString) {
406 return fmt.Errorf("activation cannot be a variable")
407 }
408
409 if expression.ExpressionMatchRegex.MatchString(activationString) {
410 return fmt.Errorf("activation cannot be an expression")
411 }
412
413 return fmt.Errorf("activation is not an array")
414 }
415 }
416
417 profileConfig, err := copyForValidation(profile)
418 if err != nil {
419 return err
420 }
421
422 if vars.VarMatchRegex.MatchString(profileConfig.Name) {
423 return fmt.Errorf("name cannot be a variable")
424 }
425
426 if expression.ExpressionMatchRegex.MatchString(profileConfig.Name) {
427 return fmt.Errorf("name cannot be an expression")
428 }
429
430 if vars.VarMatchRegex.MatchString(profileConfig.Parent) {
431 return fmt.Errorf("parent cannot be a variable")
432 }
433
434 if expression.ExpressionMatchRegex.MatchString(profileConfig.Parent) {
435 return fmt.Errorf("parent cannot be an expression")
436 }

Callers 1

prepareProfilesFunction · 0.85

Calls 2

copyForValidationFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected