Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-v0.14] Remove usages of "new" as variable name #1757

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading