Skip to content

Commit

Permalink
fix: ensure clustertask annotations are synced to taskrun
Browse files Browse the repository at this point in the history
fix #7601
  • Loading branch information
l-qing authored and tekton-robot committed Feb 12, 2024
1 parent 876b81e commit c58fa31
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/reconciler/taskrun/resources/taskref.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,12 @@ func convertClusterTaskToTask(ctx context.Context, ct v1beta1.ClusterTask) (*v1.
Kind: "Task",
APIVersion: "tekton.dev/v1beta1",
},
// We need to keep ObjectMeta to keep consistent with the existing Task logic.
// TaskRun will inherit the original Annotations and Labels information.
ObjectMeta: ct.ObjectMeta,
}

t.Spec = ct.Spec
t.ObjectMeta.Name = ct.ObjectMeta.Name

v1Task := &v1.Task{
TypeMeta: metav1.TypeMeta{
Expand Down
12 changes: 12 additions & 0 deletions pkg/reconciler/taskrun/resources/taskref_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ func TestLocalTaskRef(t *testing.T) {
&v1beta1.ClusterTask{
ObjectMeta: metav1.ObjectMeta{
Name: "cluster-task",
Annotations: map[string]string{
"foo": "bar",
},
Labels: map[string]string{
"foo": "bar",
},
},
},
&v1beta1.ClusterTask{
Expand All @@ -217,6 +223,12 @@ func TestLocalTaskRef(t *testing.T) {
},
ObjectMeta: metav1.ObjectMeta{
Name: "cluster-task",
Annotations: map[string]string{
"foo": "bar",
},
Labels: map[string]string{
"foo": "bar",
},
},
},
wantErr: nil,
Expand Down

0 comments on commit c58fa31

Please sign in to comment.