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

Function validateAndReplaceForEnv

pkg/validation/variables/variables_component.go:139–158  ·  view source on GitHub ↗

validateAndReplaceForEnv validates the env data for global variable references and replaces them with the variable value

(variables map[string]string, env []v1alpha2.EnvVar)

Source from the content-addressed store, hash-verified

137
138// validateAndReplaceForEnv validates the env data for global variable references and replaces them with the variable value
139func validateAndReplaceForEnv(variables map[string]string, env []v1alpha2.EnvVar) error {
140
141 invalidKeys := make(map[string]bool)
142
143 for i := range env {
144 var err error
145
146 // Validate env name
147 if env[i].Name, err = validateAndReplaceDataWithVariable(env[i].Name, variables); err != nil {
148 checkForInvalidError(invalidKeys, err)
149 }
150
151 // Validate env value
152 if env[i].Value, err = validateAndReplaceDataWithVariable(env[i].Value, variables); err != nil {
153 checkForInvalidError(invalidKeys, err)
154 }
155 }
156
157 return newInvalidKeysError(invalidKeys)
158}
159
160// validateAndReplaceForKubernetesComponent validates the kubernetes component data for global variable references and replaces them with the variable value
161func validateAndReplaceForKubernetesComponent(variables map[string]string, kubernetes *v1alpha2.KubernetesComponent) error {

Calls 3

checkForInvalidErrorFunction · 0.85
newInvalidKeysErrorFunction · 0.85

Tested by 1