From 644f8bc986c3da61abc44d2fb522a99fda5acc75 Mon Sep 17 00:00:00 2001 From: Chitrang Patel Date: Fri, 19 May 2023 14:41:02 -0400 Subject: [PATCH] Issue-6823 Conversion Webhook panic fix 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: https://github.com/tektoncd/pipeline/issues/6823 --- pkg/apis/pipeline/v1beta1/task_conversion.go | 27 +++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/pkg/apis/pipeline/v1beta1/task_conversion.go b/pkg/apis/pipeline/v1beta1/task_conversion.go index 162358f2acd..7bea57c4ac1 100644 --- a/pkg/apis/pipeline/v1beta1/task_conversion.go +++ b/pkg/apis/pipeline/v1beta1/task_conversion.go @@ -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