From 4a8b763697dcf12fd608947916d3c9972f7f533a Mon Sep 17 00:00:00 2001 From: Sascha Schwarze Date: Mon, 11 Nov 2024 21:30:12 +0100 Subject: [PATCH] Remove usages of "new" as variable name Signed-off-by: Sascha Schwarze --- pkg/env/env.go | 12 ++++++------ pkg/volumes/volumes.go | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/env/env.go b/pkg/env/env.go index b6b147cca3..992f6b6a89 100644 --- a/pkg/env/env.go +++ b/pkg/env/env.go @@ -14,15 +14,15 @@ import ( // MergeEnvVars merges one slice of corev1.EnvVar into another slice of corev1.EnvVar // if overwriteValues is false, this function will return an error if a duplicate EnvVar name is encountered // if overwriteValues is true, this function will overwrite the existing value with the new value if a duplicate is encountered -func MergeEnvVars(new []corev1.EnvVar, into []corev1.EnvVar, overwriteValues bool) ([]corev1.EnvVar, error) { - // if new, into, or both are empty, there is no need to run through the processing logic +func MergeEnvVars(from []corev1.EnvVar, into []corev1.EnvVar, overwriteValues bool) ([]corev1.EnvVar, error) { + // if from, into, or both are empty, there is no need to run through the processing logic // just quickly return the appropriate value - if len(new) == 0 && len(into) == 0 { + if len(from) == 0 && len(into) == 0 { return []corev1.EnvVar{}, nil - } else if len(new) == 0 { + } else if len(from) == 0 { return into, nil } else if len(into) == 0 { - return new, nil + return from, nil } // create a map of the original (into) env vars with the name as the key and @@ -38,7 +38,7 @@ func MergeEnvVars(new []corev1.EnvVar, into []corev1.EnvVar, overwriteValues boo // merge the new env vars into the original env vars list following a few simple rules // based on if the name already exists and whether overwriteValues is true or false - for _, n := range new { + for _, n := range from { _, exists := originalEnvs[n.Name] switch { diff --git a/pkg/volumes/volumes.go b/pkg/volumes/volumes.go index 89168db1a2..7341d2849d 100644 --- a/pkg/volumes/volumes.go +++ b/pkg/volumes/volumes.go @@ -69,11 +69,11 @@ func isReadOnlyVolume(strategyVolume *buildv1beta1.BuildStrategyVolume) bool { // MergeBuildVolumes merges Build Volumes from one list into the other. It only allows to merge those that have property // Overridable set to true. In case it is empty or false, it is not allowed to be overridden, so Volume cannot be merged // Merging in this context means copying the VolumeSource from one object to the other. -func MergeBuildVolumes(into []buildv1beta1.BuildStrategyVolume, new []buildv1beta1.BuildVolume) ([]buildv1beta1.BuildStrategyVolume, error) { - if len(new) == 0 && len(into) == 0 { +func MergeBuildVolumes(into []buildv1beta1.BuildStrategyVolume, from []buildv1beta1.BuildVolume) ([]buildv1beta1.BuildStrategyVolume, error) { + if len(from) == 0 && len(into) == 0 { return []buildv1beta1.BuildStrategyVolume{}, nil } - if len(new) == 0 { + if len(from) == 0 { return into, nil } @@ -87,7 +87,7 @@ func MergeBuildVolumes(into []buildv1beta1.BuildStrategyVolume, new []buildv1bet mergeMap[vol.Name] = *vol.DeepCopy() } - for _, merger := range new { + for _, merger := range from { original, ok := mergeMap[merger.Name] if !ok { errors = append(errors, fmt.Errorf("Build Volume %q is not found in the BuildStrategy", merger.Name))