You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2023/04/13 13:08:46 UTC
[camel-k] 01/02: fix(cmd): uninstall kube-public rolebindings
This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit fdd30a6e742fb0744e87002fb6e36a4fe793ddfe
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Thu Apr 13 12:53:31 2023 +0200
fix(cmd): uninstall kube-public rolebindings
Closes #3829
---
pkg/cmd/uninstall.go | 24 ++++++++++++++++++++++++
pkg/install/operator.go | 2 +-
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/pkg/cmd/uninstall.go b/pkg/cmd/uninstall.go
index 56157b9d7..6579da4a0 100644
--- a/pkg/cmd/uninstall.go
+++ b/pkg/cmd/uninstall.go
@@ -239,6 +239,12 @@ func (o *uninstallCmdOptions) uninstallNamespaceRoles(ctx context.Context, cmd *
return err
}
fmt.Fprintln(cmd.OutOrStdout(), "Camel K Role Bindings removed from namespace", o.Namespace)
+
+ KEP1755Namespace := "kube-public"
+ if err := o.uninstallKEP_1755RoleBindings(ctx, c, KEP1755Namespace); err != nil {
+ return err
+ }
+ fmt.Fprintln(cmd.OutOrStdout(), "Camel K Role Bindings removed from namespace", KEP1755Namespace)
}
if !o.SkipRoles {
@@ -347,6 +353,24 @@ func (o *uninstallCmdOptions) uninstallRoleBindings(ctx context.Context, c clien
return nil
}
+func (o *uninstallCmdOptions) uninstallKEP_1755RoleBindings(ctx context.Context, c client.Client, namespace string) error {
+ api := c.RbacV1()
+
+ roleBindings, err := api.RoleBindings(namespace).List(ctx, defaultListOptions)
+ if err != nil {
+ return err
+ }
+
+ for _, roleBinding := range roleBindings.Items {
+ err := api.RoleBindings(namespace).Delete(ctx, roleBinding.Name, metav1.DeleteOptions{})
+ if err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
func (o *uninstallCmdOptions) uninstallClusterRoles(ctx context.Context, c client.Client) error {
api := c.RbacV1()
diff --git a/pkg/install/operator.go b/pkg/install/operator.go
index 9f8c10d9c..14f99fa0a 100644
--- a/pkg/install/operator.go
+++ b/pkg/install/operator.go
@@ -345,7 +345,7 @@ func OperatorOrCollect(ctx context.Context, cmd *cobra.Command, c client.Client,
}
if err = installNamespacedRoleBinding(ctx, c, collection, cfg.Namespace, "/rbac/operator-role-binding-local-registry.yaml"); err != nil {
- fmt.Fprintln(cmd.ErrOrStderr(), "Warning: the operator won't be able to detect a local image registry via KEP-1755")
+ fmt.Fprintf(cmd.ErrOrStderr(), "Warning: the operator may not be able to detect a local image registry (%s)\n", err.Error())
}
if cfg.Monitoring.Enabled {