From 67a272c3934408e66ebad38a4224839cf50e214c Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Mon, 23 Oct 2023 15:45:31 +0200 Subject: [PATCH] Made webhook secret part of kustomize (#175) --- config/webhook/kustomization.yaml | 1 + config/webhook/secret.yaml | 11 +++++ go.mod | 2 - go.sum | 14 ------ hack/e2e/cleanup/cleanup_test.go | 76 +++++++++++++++---------------- 5 files changed, 49 insertions(+), 55 deletions(-) create mode 100644 config/webhook/secret.yaml diff --git a/config/webhook/kustomization.yaml b/config/webhook/kustomization.yaml index 2ec95ae1..92cde7f9 100644 --- a/config/webhook/kustomization.yaml +++ b/config/webhook/kustomization.yaml @@ -3,6 +3,7 @@ resources: - cronjob.yaml - webhook_configs.yaml - service.yaml +- secret.yaml apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization diff --git a/config/webhook/secret.yaml b/config/webhook/secret.yaml new file mode 100644 index 00000000..6342d2a3 --- /dev/null +++ b/config/webhook/secret.yaml @@ -0,0 +1,11 @@ +# secret without any data. The cronjob will insert the cert into this file. +apiVersion: v1 +kind: Secret +metadata: + name: eventing-manager-webhook-server-cert + labels: + app.kubernetes.io/name: eventing-manager-webhook-service + app.kubernetes.io/component: eventing-manager + app.kubernetes.io/created-by: eventing-manager + app.kubernetes.io/part-of: eventing-manager +type: Opaque diff --git a/go.mod b/go.mod index 0f1c03e6..2d2c0ea3 100644 --- a/go.mod +++ b/go.mod @@ -55,7 +55,6 @@ require ( github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.17.0 // indirect - github.com/kyma-project/kyma/components/application-operator v0.0.0-20230127165033-ec8e43477eca // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/minio/highwayhash v1.0.2 // indirect @@ -80,7 +79,6 @@ require ( golang.org/x/term v0.13.0 // indirect golang.org/x/text v0.13.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.13.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.31.0 // indirect diff --git a/go.sum b/go.sum index 3ca4a7bc..f0fe7ce4 100644 --- a/go.sum +++ b/go.sum @@ -15,8 +15,6 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/emicklei/go-restful/v3 v3.10.1 h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ= -github.com/emicklei/go-restful/v3 v3.10.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= @@ -95,14 +93,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kyma-project/api-gateway v0.0.0-20220819093753-296e6704d413 h1:fkGKNOFbltycpdQ7yCGfa+7MpH9X18F09x+n7Tgfp7A= github.com/kyma-project/api-gateway v0.0.0-20220819093753-296e6704d413/go.mod h1:5kBV6C2JEaapjTAn10Mo81Te4e6LN3epexUCSLXgQLI= -github.com/kyma-project/kyma/common/logging v0.0.0-20230616102347-ad6927dc28d5 h1:Uey3jJWq9eyXiepEvqQjBIWwPGM8nMIylBpcTc9FuDM= -github.com/kyma-project/kyma/common/logging v0.0.0-20230616102347-ad6927dc28d5/go.mod h1:JGb5RBi8Uz+RZ/jf54+qA+RqY6uPQBJ8pO1w3KSwm1Q= github.com/kyma-project/kyma/common/logging v0.0.0-20231020092259-d58329d50da1 h1:Lur/R654ghUmsZiNrSrQBDjxCAvkb/7CueB0X/VQbKg= github.com/kyma-project/kyma/common/logging v0.0.0-20231020092259-d58329d50da1/go.mod h1:JGb5RBi8Uz+RZ/jf54+qA+RqY6uPQBJ8pO1w3KSwm1Q= -github.com/kyma-project/kyma/components/application-operator v0.0.0-20230127165033-ec8e43477eca h1:7UpCIk6+sMCOhPfolAlppRugSln5M4T8/dHJm8x0erc= -github.com/kyma-project/kyma/components/application-operator v0.0.0-20230127165033-ec8e43477eca/go.mod h1:Tog02gZ1VT7yvFmhSqmiuGZpDYt18zTF4kr6E0N9ttk= -github.com/kyma-project/kyma/components/eventing-controller v0.0.0-20231006112231-696ba866d5ec h1:P+V9r14NJKUFbIZIEMrjInABT+qN/ySLqWQ01aeq068= -github.com/kyma-project/kyma/components/eventing-controller v0.0.0-20231006112231-696ba866d5ec/go.mod h1:Ht1hT95iSKe5md3QhIZQrq3j9WXkiWe/qdDMaDrmdyI= github.com/kyma-project/kyma/components/eventing-controller v0.0.0-20231020092259-d58329d50da1 h1:DeK2GvRpL2YPPkCguEN376Lj6dlKkjwn1Z4Df1LHatg= github.com/kyma-project/kyma/components/eventing-controller v0.0.0-20231020092259-d58329d50da1/go.mod h1:llsnpySZ+YAB6WrWplNWbGdnYYPmMlUMXEhFl0sXtsE= github.com/kyma-project/nats-manager v1.0.2 h1:uJiVrLFFqnOsnz1IGNn76fm5cQoK+4L8GxP829mX2C8= @@ -260,8 +252,6 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= -golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU= golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw= @@ -310,12 +300,8 @@ k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 h1:LyMgNKD2P8Wn1iAwQU5OhxCKlKJy0sHc+PcDwFB24dQ= k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9/go.mod h1:wZK2AVp1uHCp4VamDVgBP2COHZjqD1T68Rf0CM3YjSM= -k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk= -k8s.io/utils v0.0.0-20230406110748-d93618cff8a2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -sigs.k8s.io/controller-runtime v0.15.2 h1:9V7b7SDQSJ08IIsJ6CY1CE85Okhp87dyTMNDG0FS7f4= -sigs.k8s.io/controller-runtime v0.15.2/go.mod h1:7ngYvp1MLT+9GeZ+6lH3LOlcHkp/+tzA/fmHa4iq9kk= sigs.k8s.io/controller-runtime v0.16.3 h1:2TuvuokmfXvDUamSx1SuAOO3eTyye+47mJCigwG62c4= sigs.k8s.io/controller-runtime v0.16.3/go.mod h1:j7bialYoSn142nv9sCOJmQgDXQXxnroFU4VnX/brVJ0= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= diff --git a/hack/e2e/cleanup/cleanup_test.go b/hack/e2e/cleanup/cleanup_test.go index 4886c381..1b88c0bf 100644 --- a/hack/e2e/cleanup/cleanup_test.go +++ b/hack/e2e/cleanup/cleanup_test.go @@ -79,45 +79,43 @@ func Test_NoPublisherServiceAccountExists(t *testing.T) { require.NoError(t, err) } -//// Enable this test once https://github.com/kyma-project/eventing-manager/issues/34 is done! -//// Test_NoPublisherClusterRoleExists tests if the publisher-proxy ClusterRole was deleted. -//func Test_NoPublisherClusterRoleExists(t *testing.T) { -// t.Parallel() -// ctx := context.TODO() -// eventingCR := EventingCR(eventingv1alpha1.BackendType(testEnvironment.TestConfigs.BackendType)) -// err := Retry(testenvironment.Attempts, testenvironment.Interval, func() error { -// _, getErr := testEnvironment.K8sClientset.RbacV1().ClusterRoles().Get(ctx, -// eventing.GetPublisherClusterRoleName(*eventingCR), metav1.GetOptions{}) -// if getErr == nil { -// return errors.New("PublisherClusterRole should have been deleted") -// } -// if !k8serrors.IsNotFound(getErr) { -// return getErr -// } -// return nil -// }) -// require.NoError(t, err) -//} -// -//// Enable this test once https://github.com/kyma-project/eventing-manager/issues/34 is done! -//// Test_NoPublisherClusterRoleBindingExists tests if the publisher-proxy ClusterRoleBinding was deleted. -//func Test_NoPublisherClusterRoleBindingExists(t *testing.T) { -// t.Parallel() -// ctx := context.TODO() -// eventingCR := EventingCR(eventingv1alpha1.BackendType(testEnvironment.TestConfigs.BackendType)) -// err := Retry(testenvironment.Attempts, testenvironment.Interval, func() error { -// _, getErr := testEnvironment.K8sClientset.RbacV1().ClusterRoleBindings().Get(ctx, -// eventing.GetPublisherClusterRoleBindingName(*eventingCR), metav1.GetOptions{}) -// if getErr == nil { -// return errors.New("PublisherClusterRoleBinding should have been deleted") -// } -// if !k8serrors.IsNotFound(getErr) { -// return getErr -// } -// return nil -// }) -// require.NoError(t, err) -//} +// Test_NoPublisherClusterRoleExists tests if the publisher-proxy ClusterRole was deleted. +func Test_NoPublisherClusterRoleExists(t *testing.T) { + t.Parallel() + ctx := context.TODO() + eventingCR := EventingCR(eventingv1alpha1.BackendType(testEnvironment.TestConfigs.BackendType)) + err := Retry(testenvironment.Attempts, testenvironment.Interval, func() error { + _, getErr := testEnvironment.K8sClientset.RbacV1().ClusterRoles().Get(ctx, + eventing.GetPublisherClusterRoleName(*eventingCR), metav1.GetOptions{}) + if getErr == nil { + return errors.New("PublisherClusterRole should have been deleted") + } + if !k8serrors.IsNotFound(getErr) { + return getErr + } + return nil + }) + require.NoError(t, err) +} + +// Test_NoPublisherClusterRoleBindingExists tests if the publisher-proxy ClusterRoleBinding was deleted. +func Test_NoPublisherClusterRoleBindingExists(t *testing.T) { + t.Parallel() + ctx := context.TODO() + eventingCR := EventingCR(eventingv1alpha1.BackendType(testEnvironment.TestConfigs.BackendType)) + err := Retry(testenvironment.Attempts, testenvironment.Interval, func() error { + _, getErr := testEnvironment.K8sClientset.RbacV1().ClusterRoleBindings().Get(ctx, + eventing.GetPublisherClusterRoleBindingName(*eventingCR), metav1.GetOptions{}) + if getErr == nil { + return errors.New("PublisherClusterRoleBinding should have been deleted") + } + if !k8serrors.IsNotFound(getErr) { + return getErr + } + return nil + }) + require.NoError(t, err) +} // Test_NoPublisherServicesExists tests if the publisher-proxy Services was deleted. func Test_NoPublisherServicesExists(t *testing.T) {