Skip to content

Commit

Permalink
Revert "Avoid assigning nil value to required field in podSpec: Conta…
Browse files Browse the repository at this point in the history
…iners (#317)" (#318)

This reverts commit 1c295f7.
  • Loading branch information
SupriyaKasten authored and tdmanv committed Sep 25, 2019
1 parent 1c295f7 commit 5b14b00
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions pkg/kube/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,15 @@ func WaitForPodCompletion(ctx context.Context, cli kubernetes.Interface, namespa

// PodSpecOverride override default pod Spec with the ones provided via specs
func PodSpecOverride(ctx context.Context, defaultSpecs, overrideSpecs v1.PodSpec) (v1.PodSpec, error) {
containers := defaultSpecs.Containers
// - Marshal override specs
// - Unmarshal override specs on default object so that it overrides only the fields that are present in override specs
override, err := json.Marshal(overrideSpecs)
if err != nil {
return v1.PodSpec{}, err
}
// - Unmarshal override specs on default object so that it overrides only the fields that are present in override specs
err = json.Unmarshal(override, &defaultSpecs)
if err != nil {
return v1.PodSpec{}, err
}
if defaultSpecs.Containers == nil {
defaultSpecs.Containers = containers
}
return defaultSpecs, nil
}

0 comments on commit 5b14b00

Please sign in to comment.