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

Function ValidateAndReplaceGlobalVariable

pkg/validation/variables/variables.go:48–70  ·  view source on GitHub ↗

ValidateAndReplaceGlobalVariable validates the workspace template spec data for global variable references and replaces them with the variable value

(workspaceTemplateSpec *v1alpha2.DevWorkspaceTemplateSpec)

Source from the content-addressed store, hash-verified

46
47// ValidateAndReplaceGlobalVariable validates the workspace template spec data for global variable references and replaces them with the variable value
48func ValidateAndReplaceGlobalVariable(workspaceTemplateSpec *v1alpha2.DevWorkspaceTemplateSpec) VariableWarning {
49
50 var variableWarning VariableWarning
51
52 if workspaceTemplateSpec != nil {
53 // Validate the components and replace for global variable
54 variableWarning.Components = ValidateAndReplaceForComponents(workspaceTemplateSpec.Variables, workspaceTemplateSpec.Components)
55
56 // Validate the commands and replace for global variable
57 variableWarning.Commands = ValidateAndReplaceForCommands(workspaceTemplateSpec.Variables, workspaceTemplateSpec.Commands)
58
59 // Validate the projects and replace for global variable
60 variableWarning.Projects = ValidateAndReplaceForProjects(workspaceTemplateSpec.Variables, workspaceTemplateSpec.Projects)
61
62 // Validate the starter projects and replace for global variable
63 variableWarning.StarterProjects = ValidateAndReplaceForStarterProjects(workspaceTemplateSpec.Variables, workspaceTemplateSpec.StarterProjects)
64
65 // Validate the starter projects and replace for global variable
66 variableWarning.DependentProjects = ValidateAndReplaceForProjects(workspaceTemplateSpec.Variables, workspaceTemplateSpec.DependentProjects)
67 }
68
69 return variableWarning
70}
71
72// validateAndReplaceDataWithVariable validates the string for a global variable and replaces it. An error
73// is returned if the string references an invalid global variable key

Callers 1

Tested by 1