Skip to content

Commit

Permalink
Remove usages of "new" as variable name
Browse files Browse the repository at this point in the history
Signed-off-by: Sascha Schwarze <[email protected]>
  • Loading branch information
SaschaSchwarze0 committed Nov 11, 2024
1 parent bee9608 commit 4a8b763
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions pkg/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions pkg/volumes/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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))
Expand Down

0 comments on commit 4a8b763

Please sign in to comment.