Skip to content

Commit

Permalink
Cleanup by removing labels from pipelinerun
Browse files Browse the repository at this point in the history
In the v0.18.x PAC release, labels such as
git-provider, sender, and branch have been deprecated.

This change involves completely removing the
git-provider, sender, and branch labels,
which constitutes a breaking change.

Signed-off-by: Savita Ashture <[email protected]>
  • Loading branch information
savitaashture authored and piyush-garg committed Feb 27, 2024
1 parent 7c93890 commit 5fc22de
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion pkg/cmd/tknpac/describe/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func describe(ctx context.Context, cs *params.Run, clock clockwork.Clock, opts *
runTimeObj = append(runTimeObj, &events.Items[i])
}

// we do twice the prun list, but since it's behind a flag and not the default behavior, it's ok (i guess)
// we do twice the prun list, but since it's behind a flag and not the default behavior, it's ok (I guess)
label := keys.Repository + "=" + repository.Name
prs, err := cs.Clients.Tekton.TektonV1().PipelineRuns(repository.Namespace).List(ctx, metav1.ListOptions{
LabelSelector: label,
Expand Down
32 changes: 19 additions & 13 deletions pkg/cmd/tknpac/describe/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ func TestDescribe(t *testing.T) {
currentNamespace: ns,
opts: &describeOpts{},
pruns: []*tektonv1.PipelineRun{
tektontest.MakePRCompletion(cw, "running", ns, running, nil, map[string]string{
tektontest.MakePRCompletion(cw, "running", ns, running, map[string]string{
keys.Branch: "tartanpion",
keys.EventType: "papayolo",
}, map[string]string{
keys.Repository: "test-run",
keys.Branch: "tartanpion",
keys.EventType: "papayolo",
}, 30),
},
statuses: []v1alpha1.RepositoryRunStatus{
Expand Down Expand Up @@ -89,9 +90,10 @@ func TestDescribe(t *testing.T) {
currentNamespace: ns,
opts: &describeOpts{},
pruns: []*tektonv1.PipelineRun{
tektontest.MakePRCompletion(cw, "running", ns, running, nil, map[string]string{
tektontest.MakePRCompletion(cw, "running", ns, running, map[string]string{
keys.Branch: "tartanpion",
}, map[string]string{
keys.Repository: "test-run",
keys.Branch: "tartanpion",
}, 30),
},
statuses: []v1alpha1.RepositoryRunStatus{},
Expand All @@ -105,13 +107,15 @@ func TestDescribe(t *testing.T) {
currentNamespace: ns,
opts: &describeOpts{TargetPipelineRun: "running2"},
pruns: []*tektonv1.PipelineRun{
tektontest.MakePRCompletion(cw, "running", ns, running, nil, map[string]string{
tektontest.MakePRCompletion(cw, "running", ns, running, map[string]string{
keys.Branch: "tartanpion",
}, map[string]string{
keys.Repository: "test-run",
keys.Branch: "tartanpion",
}, 30),
tektontest.MakePRCompletion(cw, "running2", ns, running, nil, map[string]string{
tektontest.MakePRCompletion(cw, "running2", ns, running, map[string]string{
keys.Branch: "vavaroom",
}, map[string]string{
keys.Repository: "test-run",
keys.Branch: "vavaroom",
}, 30),
},
statuses: []v1alpha1.RepositoryRunStatus{},
Expand All @@ -125,13 +129,15 @@ func TestDescribe(t *testing.T) {
currentNamespace: ns,
opts: &describeOpts{},
pruns: []*tektonv1.PipelineRun{
tektontest.MakePRCompletion(cw, "running", ns, running, nil, map[string]string{
tektontest.MakePRCompletion(cw, "running", ns, running, map[string]string{
keys.Branch: "tartanpion",
}, map[string]string{
keys.Repository: "test-run",
keys.Branch: "tartanpion",
}, 30),
tektontest.MakePRCompletion(cw, "running2", ns, running, nil, map[string]string{
tektontest.MakePRCompletion(cw, "running2", ns, running, map[string]string{
keys.Branch: "vavaroom",
}, map[string]string{
keys.Repository: "test-run",
keys.Branch: "vavaroom",
}, 30),
},
statuses: []v1alpha1.RepositoryRunStatus{},
Expand Down
10 changes: 2 additions & 8 deletions pkg/kubeinteraction/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ func AddLabelsAndAnnotations(ctx context.Context, event *info.Event, pipelineRun
if event == nil {
return fmt.Errorf("event should not be nil")
}
// Add labels on the soon to be created pipelinerun so UI/CLI can easily
// Add labels on the soon-to-be created pipelinerun so UI/CLI can easily
// query them.
paramsinfo := info.GetInfo(ctx, info.GetCurrentControllerName(ctx))
labels := map[string]string{
// These keys are used in LabelSelector query so we are keeping in Labels as it is.
// These keys are used in LabelSelector query, so we are keeping in Labels as it is.
// But adding same keys to Annotations so UI/CLI can fetch the actual value instead of modified value
"app.kubernetes.io/managed-by": pipelinesascode.GroupName,
"app.kubernetes.io/version": formatting.CleanValueKubernetes(version.Version),
Expand All @@ -39,12 +39,6 @@ func AddLabelsAndAnnotations(ctx context.Context, event *info.Event, pipelineRun
keys.Repository: formatting.CleanValueKubernetes(repo.GetName()),
keys.State: StateStarted,
keys.EventType: formatting.CleanValueKubernetes(event.EventType),

// We are deprecating these below keys from labels and adding it to Annotations
// In PAC v0.20.x releases we will remove these keys from Labels
keys.Sender: formatting.CleanValueKubernetes(event.Sender),
keys.Branch: formatting.CleanValueKubernetes(event.BaseBranch),
keys.GitProvider: providerinfo.Name,
}

annotations := map[string]string{
Expand Down
1 change: 0 additions & 1 deletion pkg/reconciler/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func TestBuildEventFromPipelineRun(t *testing.T) {
keys.URLRepository: "repo",
keys.SHA: "sha",
keys.EventType: "push",
keys.Branch: "branch",
keys.State: kubeinteraction.StateStarted,
keys.PullRequest: "1234",
},
Expand Down

0 comments on commit 5fc22de

Please sign in to comment.