Skip to content

Commit

Permalink
Issue-6823 Conversion Webhook panic fix
Browse files Browse the repository at this point in the history
Prior to this, the conversion of task spec from v1beta1
was panicing when the step template was nil since it could not
access the underlying deprecated fields. This PR fixes that bug.
Related issue: #6823
  • Loading branch information
chitrangpatel committed Jun 13, 2023
1 parent 723c263 commit 644f8bc
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions pkg/apis/pipeline/v1beta1/task_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,18 +293,21 @@ func retrieveTaskDeprecation(spec *TaskSpec) *taskDeprecation {
DeprecatedTTY: s.DeprecatedTTY,
})
}
dst := &StepTemplate{
DeprecatedName: spec.StepTemplate.DeprecatedName,
DeprecatedPorts: spec.StepTemplate.DeprecatedPorts,
DeprecatedLivenessProbe: spec.StepTemplate.DeprecatedLivenessProbe,
DeprecatedReadinessProbe: spec.StepTemplate.DeprecatedReadinessProbe,
DeprecatedStartupProbe: spec.StepTemplate.DeprecatedStartupProbe,
DeprecatedLifecycle: spec.StepTemplate.DeprecatedLifecycle,
DeprecatedTerminationMessagePath: spec.StepTemplate.DeprecatedTerminationMessagePath,
DeprecatedTerminationMessagePolicy: spec.StepTemplate.DeprecatedTerminationMessagePolicy,
DeprecatedStdin: spec.StepTemplate.DeprecatedStdin,
DeprecatedStdinOnce: spec.StepTemplate.DeprecatedStdinOnce,
DeprecatedTTY: spec.StepTemplate.DeprecatedTTY,
dst := &StepTemplate{}
if spec.StepTemplate != nil {
dst = &StepTemplate{
DeprecatedName: spec.StepTemplate.DeprecatedName,
DeprecatedPorts: spec.StepTemplate.DeprecatedPorts,
DeprecatedLivenessProbe: spec.StepTemplate.DeprecatedLivenessProbe,
DeprecatedReadinessProbe: spec.StepTemplate.DeprecatedReadinessProbe,
DeprecatedStartupProbe: spec.StepTemplate.DeprecatedStartupProbe,
DeprecatedLifecycle: spec.StepTemplate.DeprecatedLifecycle,
DeprecatedTerminationMessagePath: spec.StepTemplate.DeprecatedTerminationMessagePath,
DeprecatedTerminationMessagePolicy: spec.StepTemplate.DeprecatedTerminationMessagePolicy,
DeprecatedStdin: spec.StepTemplate.DeprecatedStdin,
DeprecatedStdinOnce: spec.StepTemplate.DeprecatedStdinOnce,
DeprecatedTTY: spec.StepTemplate.DeprecatedTTY,
}
}
if reflect.DeepEqual(dst, &StepTemplate{}) {
dst = nil
Expand Down

0 comments on commit 644f8bc

Please sign in to comment.