diff --git a/pkg/reconciler/pipelinerun/pipelinerun.go b/pkg/reconciler/pipelinerun/pipelinerun.go index 8ff1e1046b9..750f32b3a3d 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun.go +++ b/pkg/reconciler/pipelinerun/pipelinerun.go @@ -507,7 +507,7 @@ func (c *Reconciler) reconcile(ctx context.Context, pr *v1beta1.PipelineRun, get } // Ensure that the array reference is not out of bound - if err := resources.ValidateParamArrayIndex(ctx, pipelineSpec, pr); err != nil { + if err := resources.ValidateParamArrayIndex(ctx, pipelineSpec, pr.Spec.Params); err != nil { // This Run has failed, so we need to mark it as failed and stop reconciling it pr.Status.MarkFailed(ReasonObjectParameterMissKeys, "PipelineRun %s/%s parameters is missing object keys required by Pipeline %s/%s's parameters: %s", diff --git a/pkg/reconciler/pipelinerun/resources/validate_params.go b/pkg/reconciler/pipelinerun/resources/validate_params.go index 0b65d3683b9..00fe472235d 100644 --- a/pkg/reconciler/pipelinerun/resources/validate_params.go +++ b/pkg/reconciler/pipelinerun/resources/validate_params.go @@ -24,8 +24,6 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/list" "github.com/tektoncd/pipeline/pkg/reconciler/taskrun" - "github.com/tektoncd/pipeline/pkg/substitution" - "k8s.io/apimachinery/pkg/util/sets" ) // ValidateParamTypesMatching validate that parameters in PipelineRun override corresponding parameters in Pipeline of the same type. @@ -90,108 +88,56 @@ func ValidateObjectParamRequiredKeys(pipelineParameters []v1beta1.ParamSpec, pip } // ValidateParamArrayIndex validate if the array indexing param reference target is existent -func ValidateParamArrayIndex(ctx context.Context, p *v1beta1.PipelineSpec, pr *v1beta1.PipelineRun) error { +func ValidateParamArrayIndex(ctx context.Context, pipelineSpec *v1beta1.PipelineSpec, prParams []v1beta1.Param) error { if !config.CheckAlphaOrBetaAPIFields(ctx) { return nil } - arrayParams := extractParamIndexes(p.Params, pr.Spec.Params) + // Collect all array params lengths + // Example: {"$(params.array-params)": 2, "$(params[\"array-params\"])": 2, "$(params['array-params'])": 2} + arrayParamsLengths := taskrun.ExtractParamArrayLengths(pipelineSpec.Params, prParams) - outofBoundParams := sets.String{} - - // collect all the references - for i := range p.Tasks { - findInvalidParamArrayReferences(p.Tasks[i].Params, arrayParams, &outofBoundParams) - if p.Tasks[i].IsMatrixed() { - findInvalidParamArrayReferences(p.Tasks[i].Matrix.Params, arrayParams, &outofBoundParams) + // extract all array indexing references, for example []{"$(params.array-params[1])"} + arrayIndexParamRefs := []string{} + for i := range pipelineSpec.Tasks { + extractArrayIndexingRefsFromParams(pipelineSpec.Tasks[i].Params, &arrayIndexParamRefs) + if pipelineSpec.Tasks[i].IsMatrixed() { + extractArrayIndexingRefsFromParams(pipelineSpec.Tasks[i].Matrix.Params, &arrayIndexParamRefs) } - for j := range p.Tasks[i].Workspaces { - findInvalidParamArrayReference(p.Tasks[i].Workspaces[j].SubPath, arrayParams, &outofBoundParams) + for j := range pipelineSpec.Tasks[i].Workspaces { + taskrun.ExtractArrayIndexingParamRefs(pipelineSpec.Tasks[i].Workspaces[j].SubPath, &arrayIndexParamRefs) } - for _, wes := range p.Tasks[i].WhenExpressions { - findInvalidParamArrayReference(wes.Input, arrayParams, &outofBoundParams) + for _, wes := range pipelineSpec.Tasks[i].WhenExpressions { + taskrun.ExtractArrayIndexingParamRefs(wes.Input, &arrayIndexParamRefs) for _, v := range wes.Values { - findInvalidParamArrayReference(v, arrayParams, &outofBoundParams) + taskrun.ExtractArrayIndexingParamRefs(v, &arrayIndexParamRefs) } } } - for i := range p.Finally { - findInvalidParamArrayReferences(p.Finally[i].Params, arrayParams, &outofBoundParams) - if p.Finally[i].IsMatrixed() { - findInvalidParamArrayReferences(p.Finally[i].Matrix.Params, arrayParams, &outofBoundParams) + for i := range pipelineSpec.Finally { + extractArrayIndexingRefsFromParams(pipelineSpec.Finally[i].Params, &arrayIndexParamRefs) + if pipelineSpec.Finally[i].IsMatrixed() { + extractArrayIndexingRefsFromParams(pipelineSpec.Finally[i].Matrix.Params, &arrayIndexParamRefs) } - for _, wes := range p.Finally[i].WhenExpressions { + for _, wes := range pipelineSpec.Finally[i].WhenExpressions { for _, v := range wes.Values { - findInvalidParamArrayReference(v, arrayParams, &outofBoundParams) + taskrun.ExtractArrayIndexingParamRefs(v, &arrayIndexParamRefs) } } } - - if outofBoundParams.Len() > 0 { - return fmt.Errorf("non-existent param references:%v", outofBoundParams.List()) - } - return nil + return taskrun.ValidateOutofBoundArrayParams(arrayIndexParamRefs, arrayParamsLengths) } -func extractParamIndexes(defaults []v1beta1.ParamSpec, params []v1beta1.Param) map[string]int { - // Collect all array params - arrayParams := make(map[string]int) - - patterns := []string{ - "$(params.%s)", - "$(params[%q])", - "$(params['%s'])", - } - - // Collect array params lengths from defaults - for _, p := range defaults { - if p.Default != nil { - if p.Default.Type == v1beta1.ParamTypeArray { - for _, pattern := range patterns { - for i := 0; i < len(p.Default.ArrayVal); i++ { - arrayParams[fmt.Sprintf(pattern, p.Name)] = len(p.Default.ArrayVal) - } - } - } - } - } - - // Collect array params lengths from pipelinerun or taskrun - for _, p := range params { - if p.Value.Type == v1beta1.ParamTypeArray { - for _, pattern := range patterns { - for i := 0; i < len(p.Value.ArrayVal); i++ { - arrayParams[fmt.Sprintf(pattern, p.Name)] = len(p.Value.ArrayVal) - } - } - } - } - return arrayParams -} - -func findInvalidParamArrayReferences(params []v1beta1.Param, arrayParams map[string]int, outofBoundParams *sets.String) { +// extractArrayIndexingRefsFromParams get all array indexing references from params +func extractArrayIndexingRefsFromParams(params []v1beta1.Param, arrayIndexingParams *[]string) { for i := range params { - findInvalidParamArrayReference(params[i].Value.StringVal, arrayParams, outofBoundParams) + taskrun.ExtractArrayIndexingParamRefs(params[i].Value.StringVal, arrayIndexingParams) for _, v := range params[i].Value.ArrayVal { - findInvalidParamArrayReference(v, arrayParams, outofBoundParams) + taskrun.ExtractArrayIndexingParamRefs(v, arrayIndexingParams) } for _, v := range params[i].Value.ObjectVal { - findInvalidParamArrayReference(v, arrayParams, outofBoundParams) - } - } -} - -func findInvalidParamArrayReference(paramReference string, arrayParams map[string]int, outofBoundParams *sets.String) { - list := substitution.ExtractParamsExpressions(paramReference) - for _, val := range list { - indexString := substitution.ExtractIndexString(paramReference) - idx, _ := substitution.ExtractIndex(indexString) - v := substitution.TrimArrayIndex(val) - if paramLength, ok := arrayParams[v]; ok { - if idx >= paramLength { - outofBoundParams.Insert(val) - } + taskrun.ExtractArrayIndexingParamRefs(v, arrayIndexingParams) } } } diff --git a/pkg/reconciler/pipelinerun/resources/validate_params_test.go b/pkg/reconciler/pipelinerun/resources/validate_params_test.go index 685b06dd829..feb25941be7 100644 --- a/pkg/reconciler/pipelinerun/resources/validate_params_test.go +++ b/pkg/reconciler/pipelinerun/resources/validate_params_test.go @@ -492,12 +492,7 @@ func TestValidateParamArrayIndex_valid(t *testing.T) { tt := tt // capture range variable t.Run(tt.name, func(t *testing.T) { t.Parallel() - run := &v1beta1.PipelineRun{ - Spec: v1beta1.PipelineRunSpec{ - Params: tt.params, - }, - } - err := ValidateParamArrayIndex(ctx, &tt.original, run) + err := ValidateParamArrayIndex(ctx, &tt.original, tt.params) if err != nil { t.Errorf("ValidateParamArrayIndex() got err %s", err) } @@ -647,10 +642,15 @@ func TestValidateParamArrayIndex_invalid(t *testing.T) { Operator: selection.In, Values: []string{"$(params.second-param[2])"}, }}, + Matrix: &v1beta1.Matrix{ + Params: []v1beta1.Param{ + {Name: "final-task-first-param", Value: *v1beta1.NewStructuredValues("$(params.first-param[4])")}, + {Name: "final-task-second-param", Value: *v1beta1.NewStructuredValues("$(params.second-param[4])")}, + }}, }}, }, params: []v1beta1.Param{{Name: "second-param", Value: *v1beta1.NewStructuredValues("second-value", "second-value-again")}}, - expected: fmt.Errorf("non-existent param references:[$(params.first-param[2]) $(params.first-param[3]) $(params.second-param[2]) $(params.second-param[3])]"), + expected: fmt.Errorf("non-existent param references:[$(params.first-param[2]) $(params.first-param[3]) $(params.first-param[4]) $(params.second-param[2]) $(params.second-param[3]) $(params.second-param[4])]"), }, { name: "parameter references with bracket notation and special characters reference out of bound", original: v1beta1.PipelineSpec{ @@ -698,17 +698,30 @@ func TestValidateParamArrayIndex_invalid(t *testing.T) { }, params: []v1beta1.Param{{Name: "second-param", Value: *v1beta1.NewStructuredValues("second-value", "second-value-again")}}, expected: fmt.Errorf("non-existent param references:[$(params.first-param[2]) $(params.second-param[3])]"), + }, { + name: "parameter in matrix reference out of bound", + original: v1beta1.PipelineSpec{ + Params: []v1beta1.ParamSpec{ + {Name: "first-param", Type: v1beta1.ParamTypeArray, Default: v1beta1.NewStructuredValues("default-value", "default-value-again")}, + {Name: "second-param", Type: v1beta1.ParamTypeArray}, + }, + Tasks: []v1beta1.PipelineTask{{ + Matrix: &v1beta1.Matrix{ + Params: []v1beta1.Param{ + {Name: "first-task-first-param", Value: *v1beta1.NewStructuredValues("$(params.first-param[2])")}, + {Name: "first-task-second-param", Value: *v1beta1.NewStructuredValues("static value")}, + }, + }, + }}, + }, + params: []v1beta1.Param{{Name: "second-param", Value: *v1beta1.NewStructuredValues("second-value", "second-value-again")}}, + expected: fmt.Errorf("non-existent param references:[$(params.first-param[2])]"), }, } { tt := tt // capture range variable t.Run(tt.name, func(t *testing.T) { t.Parallel() - run := &v1beta1.PipelineRun{ - Spec: v1beta1.PipelineRunSpec{ - Params: tt.params, - }, - } - err := ValidateParamArrayIndex(ctx, &tt.original, run) + err := ValidateParamArrayIndex(ctx, &tt.original, tt.params) if d := cmp.Diff(tt.expected.Error(), err.Error()); d != "" { t.Errorf("ValidateParamArrayIndex() errors diff %s", diff.PrintWantGot(d)) } diff --git a/pkg/reconciler/taskrun/validate_resources.go b/pkg/reconciler/taskrun/validate_resources.go index c4aac26e7a6..57a550d9001 100644 --- a/pkg/reconciler/taskrun/validate_resources.go +++ b/pkg/reconciler/taskrun/validate_resources.go @@ -366,18 +366,36 @@ func missingKeysofObjectResults(tr *v1beta1.TaskRun, specResults []v1beta1.TaskR return findMissingKeys(neededKeys, providedKeys) } -func validateParamArrayIndex(ctx context.Context, params []v1beta1.Param, spec *v1beta1.TaskSpec) error { +// validateParamArrayIndex validate if the array indexing param reference target is existent +// - `trParams` are params from taskrun. +// - `taskSpec` contains params declarations. +func validateParamArrayIndex(ctx context.Context, trParams []v1beta1.Param, taskSpec *v1beta1.TaskSpec) error { cfg := config.FromContextOrDefaults(ctx) if cfg.FeatureFlags.EnableAPIFields != config.AlphaAPIFields { return nil } - var defaults []v1beta1.ParamSpec - if len(spec.Params) > 0 { - defaults = append(defaults, spec.Params...) + // Collect all array params lengths + // Example: {"$(params.array-params)": 2, "$(params[\"array-params\"])": 2, "$(params['array-params'])": 2} + arrayParamsLengths := ExtractParamArrayLengths(taskSpec.Params, trParams) + + // extract all array indexing references, for example []{"$(params.array-params[1])"} + arrayIndexingParams := []string{} + extractArrayIndexingParamRefsFromSteps(taskSpec.Steps, &arrayIndexingParams) + extractArrayIndexingParamRefsFromStepTemplate(taskSpec.StepTemplate, &arrayIndexingParams) + extractArrayIndexingParamRefsFromVolumes(taskSpec.Volumes, &arrayIndexingParams) + for _, v := range taskSpec.Workspaces { + ExtractArrayIndexingParamRefs(v.MountPath, &arrayIndexingParams) } + extractArrayIndexingParamRefsFromSidecars(taskSpec.Sidecars, &arrayIndexingParams) + + return ValidateOutofBoundArrayParams(arrayIndexingParams, arrayParamsLengths) +} + +// ExtractParamArrayLengths extract and return the lengths of all array params +func ExtractParamArrayLengths(defaults []v1beta1.ParamSpec, params []v1beta1.Param) map[string]int { // Collect all array params - arrayParams := make(map[string]int) + arrayParamsLengths := make(map[string]int) patterns := []string{ "$(params.%s)", @@ -391,173 +409,172 @@ func validateParamArrayIndex(ctx context.Context, params []v1beta1.Param, spec * if p.Default.Type == v1beta1.ParamTypeArray { for _, pattern := range patterns { for i := 0; i < len(p.Default.ArrayVal); i++ { - arrayParams[fmt.Sprintf(pattern, p.Name)] = len(p.Default.ArrayVal) + arrayParamsLengths[fmt.Sprintf(pattern, p.Name)] = len(p.Default.ArrayVal) } } } } } - // Collect array params lengths from pipeline + // Collect array params lengths from params for _, p := range params { if p.Value.Type == v1beta1.ParamTypeArray { for _, pattern := range patterns { for i := 0; i < len(p.Value.ArrayVal); i++ { - arrayParams[fmt.Sprintf(pattern, p.Name)] = len(p.Value.ArrayVal) + arrayParamsLengths[fmt.Sprintf(pattern, p.Name)] = len(p.Value.ArrayVal) } } } } + return arrayParamsLengths +} +// ValidateOutofBoundArrayParams validates if the array indexing params are out of bound +func ValidateOutofBoundArrayParams(arrayIndexingParams []string, arrayParams map[string]int) error { outofBoundParams := sets.String{} - - // Validate array param in steps fields. - validateStepsParamArrayIndexing(spec.Steps, arrayParams, &outofBoundParams) - - // Validate array param in StepTemplate fields. - validateStepsTemplateParamArrayIndexing(spec.StepTemplate, arrayParams, &outofBoundParams) - - // Validate array param in build's volumes - validateVolumesParamArrayIndexing(spec.Volumes, arrayParams, &outofBoundParams) - - for _, v := range spec.Workspaces { - extractParamIndex(v.MountPath, arrayParams, &outofBoundParams) + for _, val := range arrayIndexingParams { + indexString := substitution.ExtractIndexString(val) + idx, _ := substitution.ExtractIndex(indexString) + v := substitution.TrimArrayIndex(val) + if paramLength, ok := arrayParams[v]; ok { + if idx >= paramLength { + outofBoundParams.Insert(val) + } + } } - - validateSidecarsParamArrayIndexing(spec.Sidecars, arrayParams, &outofBoundParams) - if outofBoundParams.Len() > 0 { return fmt.Errorf("non-existent param references:%v", outofBoundParams.List()) } - return nil } -func extractParamIndex(paramReference string, arrayParams map[string]int, outofBoundParams *sets.String) { +// ExtractArrayIndexingParamRefs extract the array indexing references +func ExtractArrayIndexingParamRefs(paramReference string, arrayIndexingParams *[]string) { list := substitution.ExtractParamsExpressions(paramReference) for _, val := range list { - indexString := substitution.ExtractIndexString(paramReference) - idx, _ := substitution.ExtractIndex(indexString) - v := substitution.TrimArrayIndex(val) - if paramLength, ok := arrayParams[v]; ok { - if idx >= paramLength { - outofBoundParams.Insert(val) - } + indexString := substitution.ExtractIndexString(val) + if indexString != "" { + *arrayIndexingParams = append(*arrayIndexingParams, val) } } } -func validateStepsParamArrayIndexing(steps []v1beta1.Step, arrayParams map[string]int, outofBoundParams *sets.String) { +// extractArrayIndexingParamRefsFromSteps get all array indexing references from steps +func extractArrayIndexingParamRefsFromSteps(steps []v1beta1.Step, arrayIndexingParams *[]string) { for _, step := range steps { - extractParamIndex(step.Script, arrayParams, outofBoundParams) + ExtractArrayIndexingParamRefs(step.Script, arrayIndexingParams) container := step.ToK8sContainer() - validateContainerParamArrayIndexing(container, arrayParams, outofBoundParams) + extractArrayIndexingParamRefsFromContainer(container, arrayIndexingParams) } } -func validateStepsTemplateParamArrayIndexing(stepTemplate *v1beta1.StepTemplate, arrayParams map[string]int, outofBoundParams *sets.String) { +// extractArrayIndexingParamRefsFromStepTemplate get all array indexing references from StepsTemplate +func extractArrayIndexingParamRefsFromStepTemplate(stepTemplate *v1beta1.StepTemplate, arrayIndexingParams *[]string) { if stepTemplate == nil { return } container := stepTemplate.ToK8sContainer() - validateContainerParamArrayIndexing(container, arrayParams, outofBoundParams) + extractArrayIndexingParamRefsFromContainer(container, arrayIndexingParams) } -func validateSidecarsParamArrayIndexing(sidecars []v1beta1.Sidecar, arrayParams map[string]int, outofBoundParams *sets.String) { +// extractArrayIndexingParamRefsFromSidecars get all array indexing references from sidecars +func extractArrayIndexingParamRefsFromSidecars(sidecars []v1beta1.Sidecar, arrayIndexingParams *[]string) { for _, s := range sidecars { - extractParamIndex(s.Script, arrayParams, outofBoundParams) + ExtractArrayIndexingParamRefs(s.Script, arrayIndexingParams) container := s.ToK8sContainer() - validateContainerParamArrayIndexing(container, arrayParams, outofBoundParams) + extractArrayIndexingParamRefsFromContainer(container, arrayIndexingParams) } } -func validateVolumesParamArrayIndexing(volumes []corev1.Volume, arrayParams map[string]int, outofBoundParams *sets.String) { +// extractArrayIndexingParamRefsFromVolumes get all array indexing references from volumes +func extractArrayIndexingParamRefsFromVolumes(volumes []corev1.Volume, arrayIndexingParams *[]string) { for i, v := range volumes { - extractParamIndex(v.Name, arrayParams, outofBoundParams) + ExtractArrayIndexingParamRefs(v.Name, arrayIndexingParams) if v.VolumeSource.ConfigMap != nil { - extractParamIndex(v.ConfigMap.Name, arrayParams, outofBoundParams) + ExtractArrayIndexingParamRefs(v.ConfigMap.Name, arrayIndexingParams) for _, item := range v.ConfigMap.Items { - extractParamIndex(item.Key, arrayParams, outofBoundParams) - extractParamIndex(item.Path, arrayParams, outofBoundParams) + ExtractArrayIndexingParamRefs(item.Key, arrayIndexingParams) + ExtractArrayIndexingParamRefs(item.Path, arrayIndexingParams) } } if v.VolumeSource.Secret != nil { - extractParamIndex(v.Secret.SecretName, arrayParams, outofBoundParams) + ExtractArrayIndexingParamRefs(v.Secret.SecretName, arrayIndexingParams) for _, item := range v.Secret.Items { - extractParamIndex(item.Key, arrayParams, outofBoundParams) - extractParamIndex(item.Path, arrayParams, outofBoundParams) + ExtractArrayIndexingParamRefs(item.Key, arrayIndexingParams) + ExtractArrayIndexingParamRefs(item.Path, arrayIndexingParams) } } if v.PersistentVolumeClaim != nil { - extractParamIndex(v.PersistentVolumeClaim.ClaimName, arrayParams, outofBoundParams) + ExtractArrayIndexingParamRefs(v.PersistentVolumeClaim.ClaimName, arrayIndexingParams) } if v.Projected != nil { for _, s := range volumes[i].Projected.Sources { if s.ConfigMap != nil { - extractParamIndex(s.ConfigMap.Name, arrayParams, outofBoundParams) + ExtractArrayIndexingParamRefs(s.ConfigMap.Name, arrayIndexingParams) } if s.Secret != nil { - extractParamIndex(s.Secret.Name, arrayParams, outofBoundParams) + ExtractArrayIndexingParamRefs(s.Secret.Name, arrayIndexingParams) } if s.ServiceAccountToken != nil { - extractParamIndex(s.ServiceAccountToken.Audience, arrayParams, outofBoundParams) + ExtractArrayIndexingParamRefs(s.ServiceAccountToken.Audience, arrayIndexingParams) } } } if v.CSI != nil { if v.CSI.NodePublishSecretRef != nil { - extractParamIndex(v.CSI.NodePublishSecretRef.Name, arrayParams, outofBoundParams) + ExtractArrayIndexingParamRefs(v.CSI.NodePublishSecretRef.Name, arrayIndexingParams) } if v.CSI.VolumeAttributes != nil { for _, value := range v.CSI.VolumeAttributes { - extractParamIndex(value, arrayParams, outofBoundParams) + ExtractArrayIndexingParamRefs(value, arrayIndexingParams) } } } } } -func validateContainerParamArrayIndexing(c *corev1.Container, arrayParams map[string]int, outofBoundParams *sets.String) { - extractParamIndex(c.Name, arrayParams, outofBoundParams) - extractParamIndex(c.Image, arrayParams, outofBoundParams) - extractParamIndex(string(c.ImagePullPolicy), arrayParams, outofBoundParams) +// extractArrayIndexingParamRefsFromContainer get all array indexing references from container +func extractArrayIndexingParamRefsFromContainer(c *corev1.Container, arrayIndexingParams *[]string) { + ExtractArrayIndexingParamRefs(c.Name, arrayIndexingParams) + ExtractArrayIndexingParamRefs(c.Image, arrayIndexingParams) + ExtractArrayIndexingParamRefs(string(c.ImagePullPolicy), arrayIndexingParams) for _, a := range c.Args { - extractParamIndex(a, arrayParams, outofBoundParams) + ExtractArrayIndexingParamRefs(a, arrayIndexingParams) } for ie, e := range c.Env { - extractParamIndex(e.Value, arrayParams, outofBoundParams) + ExtractArrayIndexingParamRefs(e.Value, arrayIndexingParams) if c.Env[ie].ValueFrom != nil { if e.ValueFrom.SecretKeyRef != nil { - extractParamIndex(e.ValueFrom.SecretKeyRef.LocalObjectReference.Name, arrayParams, outofBoundParams) - extractParamIndex(e.ValueFrom.SecretKeyRef.Key, arrayParams, outofBoundParams) + ExtractArrayIndexingParamRefs(e.ValueFrom.SecretKeyRef.LocalObjectReference.Name, arrayIndexingParams) + ExtractArrayIndexingParamRefs(e.ValueFrom.SecretKeyRef.Key, arrayIndexingParams) } if e.ValueFrom.ConfigMapKeyRef != nil { - extractParamIndex(e.ValueFrom.ConfigMapKeyRef.LocalObjectReference.Name, arrayParams, outofBoundParams) - extractParamIndex(e.ValueFrom.ConfigMapKeyRef.Key, arrayParams, outofBoundParams) + ExtractArrayIndexingParamRefs(e.ValueFrom.ConfigMapKeyRef.LocalObjectReference.Name, arrayIndexingParams) + ExtractArrayIndexingParamRefs(e.ValueFrom.ConfigMapKeyRef.Key, arrayIndexingParams) } } } for _, e := range c.EnvFrom { - extractParamIndex(e.Prefix, arrayParams, outofBoundParams) + ExtractArrayIndexingParamRefs(e.Prefix, arrayIndexingParams) if e.ConfigMapRef != nil { - extractParamIndex(e.ConfigMapRef.LocalObjectReference.Name, arrayParams, outofBoundParams) + ExtractArrayIndexingParamRefs(e.ConfigMapRef.LocalObjectReference.Name, arrayIndexingParams) } if e.SecretRef != nil { - extractParamIndex(e.SecretRef.LocalObjectReference.Name, arrayParams, outofBoundParams) + ExtractArrayIndexingParamRefs(e.SecretRef.LocalObjectReference.Name, arrayIndexingParams) } } - extractParamIndex(c.WorkingDir, arrayParams, outofBoundParams) + ExtractArrayIndexingParamRefs(c.WorkingDir, arrayIndexingParams) for _, cc := range c.Command { - extractParamIndex(cc, arrayParams, outofBoundParams) + ExtractArrayIndexingParamRefs(cc, arrayIndexingParams) } for _, v := range c.VolumeMounts { - extractParamIndex(v.Name, arrayParams, outofBoundParams) - extractParamIndex(v.MountPath, arrayParams, outofBoundParams) - extractParamIndex(v.SubPath, arrayParams, outofBoundParams) + ExtractArrayIndexingParamRefs(v.Name, arrayIndexingParams) + ExtractArrayIndexingParamRefs(v.MountPath, arrayIndexingParams) + ExtractArrayIndexingParamRefs(v.SubPath, arrayIndexingParams) } }