Skip to content

Commit

Permalink
Pass-through empty nodeSelector to podSpecs
Browse files Browse the repository at this point in the history
There is no need drop empty nodeSelector maps, omitempty already does this
  • Loading branch information
olliewalsh committed Nov 18, 2024
1 parent 6d9ec1b commit 1a349e3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/keystone/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func BootstrapJob(
}
job.Spec.Template.Spec.Containers[0].Env = env.MergeEnvs(job.Spec.Template.Spec.Containers[0].Env, envVars)

if instance.Spec.NodeSelector != nil && len(*instance.Spec.NodeSelector) > 0 {
if instance.Spec.NodeSelector != nil {
job.Spec.Template.Spec.NodeSelector = *instance.Spec.NodeSelector
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/keystone/cronjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func CronJob(
},
},
}
if instance.Spec.NodeSelector != nil && len(*instance.Spec.NodeSelector) > 0 {
if instance.Spec.NodeSelector != nil {
cronjob.Spec.JobTemplate.Spec.Template.Spec.NodeSelector = *instance.Spec.NodeSelector
}
return cronjob
Expand Down
2 changes: 1 addition & 1 deletion pkg/keystone/dbsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func DbSyncJob(
},
}

if instance.Spec.NodeSelector != nil && len(*instance.Spec.NodeSelector) > 0 {
if instance.Spec.NodeSelector != nil {
job.Spec.Template.Spec.NodeSelector = *instance.Spec.NodeSelector
}

Expand Down
4 changes: 3 additions & 1 deletion pkg/keystone/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ func Deployment(
},
corev1.LabelHostname,
)
if instance.Spec.NodeSelector != nil && len(*instance.Spec.NodeSelector) > 0 {

if instance.Spec.NodeSelector != nil {
deployment.Spec.Template.Spec.NodeSelector = *instance.Spec.NodeSelector
}

return deployment, nil
}

0 comments on commit 1a349e3

Please sign in to comment.