diff --git a/pkg/reconciler/pipelinerun/resources/conditionresolution.go b/pkg/reconciler/pipelinerun/resources/conditionresolution.go index 973988b1d07..c63de3c861d 100644 --- a/pkg/reconciler/pipelinerun/resources/conditionresolution.go +++ b/pkg/reconciler/pipelinerun/resources/conditionresolution.go @@ -25,6 +25,7 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/pkg/apis/resource" resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1" + "github.com/tektoncd/pipeline/pkg/names" corev1 "k8s.io/api/core/v1" ) @@ -96,7 +97,7 @@ func (state TaskConditionCheckState) IsSuccess() bool { // ConditionToTaskSpec creates a TaskSpec from a given Condition func (rcc *ResolvedConditionCheck) ConditionToTaskSpec() (*v1beta1.TaskSpec, error) { if rcc.Condition.Spec.Check.Name == "" { - rcc.Condition.Spec.Check.Name = unnamedCheckNamePrefix + rcc.Condition.Name + rcc.Condition.Spec.Check.Name = names.SimpleNameGenerator.RestrictLength(unnamedCheckNamePrefix + rcc.Condition.Name) } t := &v1beta1.TaskSpec{ diff --git a/pkg/reconciler/pipelinerun/resources/conditionresolution_test.go b/pkg/reconciler/pipelinerun/resources/conditionresolution_test.go index 422d31626ee..c92d3182300 100644 --- a/pkg/reconciler/pipelinerun/resources/conditionresolution_test.go +++ b/pkg/reconciler/pipelinerun/resources/conditionresolution_test.go @@ -215,6 +215,18 @@ func TestResolvedConditionCheck_ConditionToTaskSpec(t *testing.T) { Image: "ubuntu", }}}, }, + }, { + name: "default-container-name", + cond: tbv1alpha1.Condition("very-very-very-very-very-very-very-very-very-very-very-long-name", tbv1alpha1.ConditionSpec( + tbv1alpha1.ConditionSpecCheck("", "ubuntu"), + )), + want: v1beta1.TaskSpec{ + Steps: []v1beta1.Step{{Container: corev1.Container{ + // Shortened via: names.SimpleNameGenerator.RestrictLength + Name: "condition-check-very-very-very-very-very-very-very-very-very-ve", + Image: "ubuntu", + }}}, + }, }, { name: "with-input-params", cond: tbv1alpha1.Condition("bar", tbv1alpha1.ConditionSpec(