MCPcopy Create free account
hub / github.com/devfile/api / ValidateAndReplaceForProjects

Function ValidateAndReplaceForProjects

pkg/validation/variables/variables_project.go:25–51  ·  view source on GitHub ↗

ValidateAndReplaceForProjects validates the projects data for global variable references and replaces them with the variable value. Returns a map of project names and invalid variable references if present.

(variables map[string]string, projects []v1alpha2.Project)

Source from the content-addressed store, hash-verified

23// ValidateAndReplaceForProjects validates the projects data for global variable references and replaces them with the variable value.
24// Returns a map of project names and invalid variable references if present.
25func ValidateAndReplaceForProjects(variables map[string]string, projects []v1alpha2.Project) map[string][]string {
26
27 projectsWarningMap := make(map[string][]string)
28
29 for i := range projects {
30 var err error
31
32 invalidKeys := make(map[string]bool)
33
34 // Validate project clonepath
35 if projects[i].ClonePath, err = validateAndReplaceDataWithVariable(projects[i].ClonePath, variables); err != nil {
36 checkForInvalidError(invalidKeys, err)
37 }
38
39 // Validate project source
40 if err = validateandReplaceForProjectSource(variables, &projects[i].ProjectSource); err != nil {
41 checkForInvalidError(invalidKeys, err)
42 }
43
44 err = newInvalidKeysError(invalidKeys)
45 if verr, ok := err.(*InvalidKeysError); ok {
46 projectsWarningMap[projects[i].Name] = verr.Keys
47 }
48 }
49
50 return projectsWarningMap
51}
52
53// ValidateAndReplaceForStarterProjects validates the starter projects data for global variable references and replaces them with the variable value.
54// Returns a map of starter project names and invalid variable references if present.

Tested by 1