Skip to content

Commit

Permalink
Remove create clusterrole in triggers test
Browse files Browse the repository at this point in the history
This will remove creating clusterrole in triggers test
as it is shipped by triggers now and an be used in clusterolebinding
  • Loading branch information
piyush-garg committed Jan 15, 2025
1 parent 1842fa8 commit d3b8050
Showing 1 changed file with 4 additions and 25 deletions.
29 changes: 4 additions & 25 deletions test/e2e/eventlistener/eventListener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package eventlistener

import (
"context"
"os"
"testing"

"github.com/tektoncd/cli/test/cli"
Expand Down Expand Up @@ -184,20 +183,6 @@ func createResources(t *testing.T, c *framework.Clients, namespace string) {
t.Fatalf("Error creating SA: %s", err)
}

// Create ClusterRole required by triggers
_, err = c.KubeClient.RbacV1().ClusterRoles().Create(context.Background(),
&rbacv1.ClusterRole{
ObjectMeta: metav1.ObjectMeta{Name: "sa-clusterrole"},
Rules: []rbacv1.PolicyRule{{
APIGroups: []string{"triggers.tekton.dev"},
Resources: []string{"clustertriggerbindings", "clusterinterceptors"},
Verbs: []string{"get", "list", "watch"},
}},
}, metav1.CreateOptions{},
)
if err != nil {
t.Fatalf("Error creating ClusterRole: %s", err)
}
_, err = c.KubeClient.RbacV1().ClusterRoleBindings().Create(context.Background(),
&rbacv1.ClusterRoleBinding{
ObjectMeta: metav1.ObjectMeta{Name: "sa-clusterrolebinding"},
Expand All @@ -209,7 +194,7 @@ func createResources(t *testing.T, c *framework.Clients, namespace string) {
RoleRef: rbacv1.RoleRef{
APIGroup: "rbac.authorization.k8s.io",
Kind: "ClusterRole",
Name: "sa-clusterrole",
Name: "tekton-triggers-eventlistener-clusterroles",
},
}, metav1.CreateOptions{},
)
Expand All @@ -222,14 +207,8 @@ func cleanupResources(t *testing.T, c *framework.Clients, namespace string) {
t.Helper()
framework.TearDown(t, c, namespace)

if os.Getenv("TEST_KEEP_NAMESPACES") == "" && !t.Failed() {
// Cleanup cluster-scoped resources
t.Logf("Deleting cluster-scoped resources")
if err := c.KubeClient.RbacV1().ClusterRoles().Delete(context.Background(), "sa-clusterrole", metav1.DeleteOptions{}); err != nil {
t.Errorf("Failed to delete clusterrole sa-clusterrole: %s", err)
}
if err := c.KubeClient.RbacV1().ClusterRoleBindings().Delete(context.Background(), "sa-clusterrolebinding", metav1.DeleteOptions{}); err != nil {
t.Errorf("Failed to delete clusterrolebinding sa-clusterrolebinding: %s", err)
}
// Cleanup cluster-scoped resources
if err := c.KubeClient.RbacV1().ClusterRoleBindings().Delete(context.Background(), "sa-clusterrolebinding", metav1.DeleteOptions{}); err != nil {
t.Errorf("Failed to delete clusterrolebinding sa-clusterrolebinding: %s", err)
}
}

0 comments on commit d3b8050

Please sign in to comment.