From 02986de15cf1294bd0c663f7a167e440f2cf5fb9 Mon Sep 17 00:00:00 2001 From: Piyush Garg Date: Thu, 19 Mar 2020 12:28:44 +0530 Subject: [PATCH] Fix copying description also during upgrade This will add copying the description also while upgrading from v1alpha1 to v1beta1 for pipeline, task and clustertask Related to https://github.com/tektoncd/cli/issues/819 --- pkg/apis/pipeline/v1alpha1/pipeline_conversion.go | 2 ++ pkg/apis/pipeline/v1alpha1/pipeline_conversion_test.go | 1 + pkg/apis/pipeline/v1alpha1/task_conversion.go | 2 ++ pkg/apis/pipeline/v1alpha1/task_conversion_test.go | 1 + 4 files changed, 6 insertions(+) diff --git a/pkg/apis/pipeline/v1alpha1/pipeline_conversion.go b/pkg/apis/pipeline/v1alpha1/pipeline_conversion.go index b54edbf5944..26173c4c9e8 100644 --- a/pkg/apis/pipeline/v1alpha1/pipeline_conversion.go +++ b/pkg/apis/pipeline/v1alpha1/pipeline_conversion.go @@ -42,6 +42,7 @@ func (source *PipelineSpec) ConvertTo(ctx context.Context, sink *v1beta1.Pipelin sink.Resources = source.Resources sink.Params = source.Params sink.Workspaces = source.Workspaces + sink.Description = source.Description if len(source.Tasks) > 0 { sink.Tasks = make([]v1beta1.PipelineTask, len(source.Tasks)) for i := range source.Tasks { @@ -86,6 +87,7 @@ func (sink *PipelineSpec) ConvertFrom(ctx context.Context, source v1beta1.Pipeli sink.Resources = source.Resources sink.Params = source.Params sink.Workspaces = source.Workspaces + sink.Description = source.Description if len(source.Tasks) > 0 { sink.Tasks = make([]PipelineTask, len(source.Tasks)) for i := range source.Tasks { diff --git a/pkg/apis/pipeline/v1alpha1/pipeline_conversion_test.go b/pkg/apis/pipeline/v1alpha1/pipeline_conversion_test.go index 2189715afa9..eec92a66834 100644 --- a/pkg/apis/pipeline/v1alpha1/pipeline_conversion_test.go +++ b/pkg/apis/pipeline/v1alpha1/pipeline_conversion_test.go @@ -56,6 +56,7 @@ func TestPipelineConversion(t *testing.T) { Generation: 1, }, Spec: PipelineSpec{ + Description: "test", Resources: []PipelineDeclaredResource{{ Name: "resource1", Type: resource.PipelineResourceTypeGit, diff --git a/pkg/apis/pipeline/v1alpha1/task_conversion.go b/pkg/apis/pipeline/v1alpha1/task_conversion.go index 771fd8d6ac1..b4e350a7107 100644 --- a/pkg/apis/pipeline/v1alpha1/task_conversion.go +++ b/pkg/apis/pipeline/v1alpha1/task_conversion.go @@ -47,6 +47,7 @@ func (source *TaskSpec) ConvertTo(ctx context.Context, sink *v1beta1.TaskSpec) e sink.Results = source.Results sink.Resources = source.Resources sink.Params = source.Params + sink.Description = source.Description if source.Inputs != nil { if len(source.Inputs.Params) > 0 && len(source.Params) > 0 { // This shouldn't happen as it shouldn't pass validation @@ -120,5 +121,6 @@ func (sink *TaskSpec) ConvertFrom(ctx context.Context, source *v1beta1.TaskSpec) sink.Results = source.Results sink.Params = source.Params sink.Resources = source.Resources + sink.Description = source.Description return nil } diff --git a/pkg/apis/pipeline/v1alpha1/task_conversion_test.go b/pkg/apis/pipeline/v1alpha1/task_conversion_test.go index 19b577e523a..4e6078add35 100644 --- a/pkg/apis/pipeline/v1alpha1/task_conversion_test.go +++ b/pkg/apis/pipeline/v1alpha1/task_conversion_test.go @@ -57,6 +57,7 @@ func TestTaskConversion(t *testing.T) { }, Spec: TaskSpec{ TaskSpec: v1beta1.TaskSpec{ + Description: "test", Steps: []v1beta1.Step{{Container: corev1.Container{ Image: "foo", }}},