Skip to content

Commit 51ce115

Browse files
committed
feat(install): remove unnecessary rbac
1 parent 9349f9a commit 51ce115

25 files changed

+261
-402
lines changed

e2e/common/git/git_test.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,24 @@ func TestGitRepository(t *testing.T) {
4040
t.Run("Camel Quarkus", func(t *testing.T) {
4141
itName := "sample"
4242
g.Expect(KamelRun(t, ctx, ns,
43-
"--git", "https://github.com/squakez/sample.git").Execute()).To(Succeed())
43+
"--git", "https://github.com/squakez/sample.git",
44+
).Execute()).To(Succeed())
45+
g.Eventually(IntegrationConditionStatus(t, ctx, ns, itName, v1.IntegrationConditionReady), TestTimeoutLong).
46+
Should(Equal(corev1.ConditionTrue))
47+
g.Eventually(IntegrationPodPhase(t, ctx, ns, itName)).Should(Equal(corev1.PodRunning))
48+
g.Eventually(IntegrationLogs(t, ctx, ns, itName)).Should(ContainSubstring("Hello Camel from route1"))
49+
})
50+
})
51+
}
52+
func TestPodStrategyGitRepository(t *testing.T) {
53+
t.Parallel()
54+
WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
55+
t.Run("Camel Quarkus", func(t *testing.T) {
56+
itName := "sample"
57+
g.Expect(KamelRun(t, ctx, ns,
58+
"--git", "https://github.com/squakez/sample.git",
59+
"-t", "builder.strategy=pod",
60+
).Execute()).To(Succeed())
4461
g.Eventually(IntegrationConditionStatus(t, ctx, ns, itName, v1.IntegrationConditionReady), TestTimeoutLong).
4562
Should(Equal(corev1.ConditionTrue))
4663
g.Eventually(IntegrationPodPhase(t, ctx, ns, itName)).Should(Equal(corev1.PodRunning))

e2e/support/test_support.go

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import (
4444
"time"
4545

4646
consoleV1 "github.com/openshift/api/console/v1"
47-
"github.com/stretchr/testify/require"
4847

4948
"github.com/google/uuid"
5049
"github.com/onsi/gomega"
@@ -78,7 +77,6 @@ import (
7877
traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait"
7978
"github.com/apache/camel-k/v2/pkg/client"
8079
"github.com/apache/camel-k/v2/pkg/cmd"
81-
"github.com/apache/camel-k/v2/pkg/install"
8280
"github.com/apache/camel-k/v2/pkg/platform"
8381
v2util "github.com/apache/camel-k/v2/pkg/util"
8482
"github.com/apache/camel-k/v2/pkg/util/defaults"
@@ -2557,50 +2555,6 @@ func ClusterDomainName(t *testing.T, ctx context.Context) (string, error) {
25572555
return dns.Spec.BaseDomain, nil
25582556
}
25592557

2560-
/*
2561-
Tekton
2562-
*/
2563-
2564-
func CreateOperatorServiceAccount(t *testing.T, ctx context.Context, ns string) error {
2565-
return install.Resource(ctx, TestClient(t), ns, true, install.IdentityResourceCustomizer, "/config/manager/operator-service-account.yaml")
2566-
}
2567-
2568-
func CreateOperatorRole(t *testing.T, ctx context.Context, ns string) (err error) {
2569-
oc, err := openshift.IsOpenShift(TestClient(t))
2570-
if err != nil {
2571-
failTest(t, err)
2572-
}
2573-
customizer := install.IdentityResourceCustomizer
2574-
if oc {
2575-
// Remove Ingress permissions as it's not needed on OpenShift
2576-
// This should ideally be removed from the common RBAC manifest.
2577-
customizer = install.RemoveIngressRoleCustomizer
2578-
}
2579-
err = install.Resource(ctx, TestClient(t), ns, true, customizer, "/config/rbac/namespaced/operator-role.yaml")
2580-
if err != nil {
2581-
return err
2582-
}
2583-
if oc {
2584-
return install.Resource(ctx, TestClient(t), ns, true, install.IdentityResourceCustomizer, "/config/rbac/openshift/namespaced/operator-role-openshift.yaml")
2585-
}
2586-
return nil
2587-
}
2588-
2589-
func CreateOperatorRoleBinding(t *testing.T, ctx context.Context, ns string) error {
2590-
oc, err := openshift.IsOpenShift(TestClient(t))
2591-
if err != nil {
2592-
failTest(t, err)
2593-
}
2594-
err = install.Resource(ctx, TestClient(t), ns, true, install.IdentityResourceCustomizer, "/config/rbac/namespaced/operator-role-binding.yaml")
2595-
if err != nil {
2596-
return err
2597-
}
2598-
if oc {
2599-
return install.Resource(ctx, TestClient(t), ns, true, install.IdentityResourceCustomizer, "/config/rbac/openshift/namespaced/operator-role-binding-openshift.yaml")
2600-
}
2601-
return nil
2602-
}
2603-
26042558
// CreateKamelPodWithIntegrationSource generates and deploy a Pod from current Camel K controller image that will run a `kamel xxxx` command.
26052559
// The integration parameter represent an Integration source file contained in a ConfigMap or Secret defined and mounted on the as a Volume.
26062560
func CreateKamelPodWithIntegrationSource(t *testing.T, ctx context.Context, ns string, name string, integration v1.ValueSource, command ...string) error {
@@ -2827,18 +2781,6 @@ func WithNewTestNamespace(t *testing.T, doRun func(context.Context, *gomega.With
28272781
invokeUserTestCode(t, testContext, ns.GetName(), doRun)
28282782
}
28292783

2830-
func WithGlobalOperatorNamespace(t *testing.T, test func(context.Context, *gomega.WithT, string)) {
2831-
ocp, err := openshift.IsOpenShift(TestClient(t))
2832-
require.NoError(t, err)
2833-
if ocp {
2834-
// global operators are always installed in the openshift-operators namespace
2835-
invokeUserTestCode(t, testContext, "openshift-operators", test)
2836-
} else {
2837-
// create new namespace for the global operator
2838-
WithNewTestNamespace(t, test)
2839-
}
2840-
}
2841-
28422784
func WithNewTestNamespaceWithKnativeBroker(t *testing.T, doRun func(context.Context, *gomega.WithT, string)) {
28432785
ns := NewTestNamespace(t, testContext, true)
28442786
defer deleteTestNamespace(t, testContext, ns)
@@ -2867,6 +2809,8 @@ func userCleanup(t *testing.T) {
28672809
func invokeUserTestCode(t *testing.T, ctx context.Context, ns string, doRun func(context.Context, *gomega.WithT, string)) {
28682810
defer func() {
28692811
DumpNamespace(t, ctx, ns)
2812+
// Also dump the operator namespace in case it's common
2813+
DumpNamespace(t, ctx, "camel-k")
28702814
}()
28712815

28722816
g := gomega.NewWithT(t)

helm/camel-k/templates/rbacs-common.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,22 @@ rules:
108108
- create
109109
---
110110
apiVersion: rbac.authorization.k8s.io/v1
111+
kind: Role
112+
metadata:
113+
labels:
114+
app: camel-k
115+
name: camel-k-kamelet-viewer
116+
rules:
117+
- apiGroups:
118+
- camel.apache.org
119+
resources:
120+
- kamelets
121+
verbs:
122+
- get
123+
- list
124+
- watch
125+
---
126+
apiVersion: rbac.authorization.k8s.io/v1
111127
kind: RoleBinding
112128
metadata:
113129
labels:
@@ -134,3 +150,18 @@ roleRef:
134150
subjects:
135151
- kind: ServiceAccount
136152
name: camel-k-builder
153+
---
154+
apiVersion: rbac.authorization.k8s.io/v1
155+
kind: RoleBinding
156+
metadata:
157+
labels:
158+
app: camel-k
159+
name: camel-k-kamelet-viewer
160+
roleRef:
161+
apiGroup: rbac.authorization.k8s.io
162+
kind: Role
163+
name: camel-k-kamelet-viewer
164+
subjects:
165+
- apiGroup: rbac.authorization.k8s.io
166+
kind: Group
167+
name: system:authenticated

0 commit comments

Comments
 (0)