Skip to content

Commit 23944fb

Browse files
committed
chore: Update controller finalizer name to include explicit part
* The finalizer name used by the controller was updated. * A new constant `FinalizerName` was introduced for the explicit part of the name. * The finalizer name was updated to combine the group name and the new constant. * This change aligns the finalizer naming with common Kubernetes conventions. Fixes openshift-pipelines#1763 Signed-off-by: Chmouel Boudjnah <[email protected]>
1 parent b2a2238 commit 23944fb

File tree

6 files changed

+12
-8
lines changed

6 files changed

+12
-8
lines changed

pkg/action/patch_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package action
22

33
import (
4-
"path/filepath"
4+
"path"
55
"testing"
66

77
apipac "github.com/openshift-pipelines/pipelines-as-code/pkg/apis/pipelinesascode"
@@ -40,7 +40,7 @@ func TestPatchPipelineRun(t *testing.T) {
4040

4141
patchedPR, err := PatchPipelineRun(ctx, logger, "log URL", fakeClients.Tekton, testPR, getLogURLMergePatch(fakeClients, testPR))
4242
assert.NilError(t, err)
43-
assert.Equal(t, patchedPR.Annotations[filepath.Join(apipac.GroupName, "log-url")], "https://localhost.console/#/namespaces/namespace/pipelineruns/force-me")
43+
assert.Equal(t, patchedPR.Annotations[path.Join(apipac.GroupName, "log-url")], "https://localhost.console/#/namespaces/namespace/pipelineruns/force-me")
4444
}
4545

4646
func getLogURLMergePatch(clients clients.Clients, pr *pipelinev1.PipelineRun) map[string]any {

pkg/apis/pipelinesascode/register.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ const (
2121
GroupName = "pipelinesascode.tekton.dev"
2222
RepositoryKind = "Repository"
2323
V1alpha1Version = "v1alpha1"
24+
FinalizerName = "finalizer"
2425
)

pkg/pipelineascode/pipelineascode_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"fmt"
99
"io"
1010
"net/http"
11-
"path/filepath"
11+
"path"
1212
"regexp"
1313
"strings"
1414
"sync"
@@ -667,7 +667,7 @@ func TestRun(t *testing.T) {
667667
if pr.GetName() == "force-me" {
668668
continue
669669
}
670-
logURL, ok := pr.Annotations[filepath.Join(apipac.GroupName, "log-url")]
670+
logURL, ok := pr.Annotations[path.Join(apipac.GroupName, "log-url")]
671671
assert.Assert(t, ok, "failed to find log-url label on pipelinerun: %s/%s", pr.GetNamespace(), pr.GetGenerateName())
672672
assert.Equal(t, logURL, cs.Clients.ConsoleUI().DetailURL(&pr))
673673

@@ -700,5 +700,5 @@ func TestGetLogURLMergePatch(t *testing.T) {
700700
assert.Assert(t, ok)
701701
a, ok := m["annotations"].(map[string]string)
702702
assert.Assert(t, ok)
703-
assert.Equal(t, a[filepath.Join(apipac.GroupName, "log-url")], con.URL())
703+
assert.Equal(t, a[path.Join(apipac.GroupName, "log-url")], con.URL())
704704
}

pkg/provider/gitlab/gitlab.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"net/http"
88
"net/url"
9+
"path"
910
"path/filepath"
1011
"regexp"
1112
"strings"
@@ -212,7 +213,7 @@ func (v *Provider) SetClient(_ context.Context, run *params.Run, runevent *info.
212213
// if we don't have sourceProjectID (ie: incoming-webhook) then try to set
213214
// it ASAP if we can.
214215
if v.sourceProjectID == 0 && runevent.Organization != "" && runevent.Repository != "" {
215-
projectSlug := filepath.Join(runevent.Organization, runevent.Repository)
216+
projectSlug := path.Join(runevent.Organization, runevent.Repository)
216217
projectinfo, _, err := v.Client().Projects.GetProject(projectSlug, &gitlab.GetProjectOptions{})
217218
if err != nil {
218219
return err

pkg/reconciler/controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package reconciler
22

33
import (
44
"context"
5+
"path"
56

67
"github.com/openshift-pipelines/pipelines-as-code/pkg/apis/pipelinesascode"
78
"github.com/openshift-pipelines/pipelines-as-code/pkg/apis/pipelinesascode/keys"
@@ -88,7 +89,7 @@ func checkStateAndEnqueue(impl *controller.Impl) func(obj any) {
8889
func ctrlOpts() func(impl *controller.Impl) controller.Options {
8990
return func(_ *controller.Impl) controller.Options {
9091
return controller.Options{
91-
FinalizerName: pipelinesascode.GroupName,
92+
FinalizerName: path.Join(pipelinesascode.GroupName, pipelinesascode.FinalizerName),
9293
PromoteFilterFunc: func(obj any) bool {
9394
_, exist := obj.(*tektonv1.PipelineRun).GetAnnotations()[keys.State]
9495
return exist

pkg/reconciler/controller_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package reconciler
22

33
import (
44
"context"
5+
"path"
56
"testing"
67

78
"github.com/openshift-pipelines/pipelines-as-code/pkg/apis/pipelinesascode"
@@ -63,7 +64,7 @@ func TestCtrlOpts(t *testing.T) {
6364
opts := ctrlOpts()(impl)
6465

6566
// Assert that the finalizer name is set correctly.
66-
assert.Equal(t, pipelinesascode.GroupName, opts.FinalizerName)
67+
assert.Equal(t, path.Join(pipelinesascode.GroupName, pipelinesascode.FinalizerName), opts.FinalizerName)
6768

6869
// Create a new PipelineRun object with the "started" state label.
6970
pr := &pipelinev1.PipelineRun{

0 commit comments

Comments
 (0)