This is an automated email from the ASF dual-hosted git repository. nferraro pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/master by this push: new 28d46e9 Fix #1393: create standard role at operator startup in OLM 28d46e9 is described below commit 28d46e9c2987efacc39d849adfa925587dafb148 Author: Nicola Ferraro <ni.ferr...@gmail.com> AuthorDate: Tue Apr 7 17:00:15 2020 +0200 Fix #1393: create standard role at operator startup in OLM --- ...el-k.v1.0.0-snapshot.clusterserviceversion.yaml | 14 +++++------ deploy/operator-role-olm-cluster.yaml | 6 +++++ pkg/cmd/operator/operator.go | 7 ++---- pkg/install/optional.go | 29 ++++++++++++++++++++++ 4 files changed, 43 insertions(+), 13 deletions(-) diff --git a/deploy/olm-catalog/camel-k/1.0.0-snapshot/camel-k.v1.0.0-snapshot.clusterserviceversion.yaml b/deploy/olm-catalog/camel-k/1.0.0-snapshot/camel-k.v1.0.0-snapshot.clusterserviceversion.yaml index e3390d8..cd03029 100644 --- a/deploy/olm-catalog/camel-k/1.0.0-snapshot/camel-k.v1.0.0-snapshot.clusterserviceversion.yaml +++ b/deploy/olm-catalog/camel-k/1.0.0-snapshot/camel-k.v1.0.0-snapshot.clusterserviceversion.yaml @@ -169,6 +169,12 @@ spec: - patch - update - watch + - apiGroups: + - camel.apache.org + resources: + - '*' + verbs: + - '*' serviceAccountName: camel-k-operator deployments: - name: camel-k-operator @@ -402,14 +408,6 @@ spec: - update - watch - apiGroups: - - rbac.authorization.k8s.io - resourceNames: - - system:image-builder - resources: - - clusterroles - verbs: - - bind - - apiGroups: - monitoring.coreos.com resources: - servicemonitors diff --git a/deploy/operator-role-olm-cluster.yaml b/deploy/operator-role-olm-cluster.yaml index 26a56ec..09cf5f8 100644 --- a/deploy/operator-role-olm-cluster.yaml +++ b/deploy/operator-role-olm-cluster.yaml @@ -35,3 +35,9 @@ rules: - patch - update - watch +- apiGroups: + - camel.apache.org + resources: + - '*' + verbs: + - '*' diff --git a/pkg/cmd/operator/operator.go b/pkg/cmd/operator/operator.go index 8394e91..708f573 100644 --- a/pkg/cmd/operator/operator.go +++ b/pkg/cmd/operator/operator.go @@ -147,12 +147,9 @@ func Run() { } // Try to register the OpenShift CLI Download link if possible - installCtx, installCancel := context.WithTimeout(context.TODO(), 30*time.Second) + installCtx, installCancel := context.WithTimeout(context.TODO(), 1*time.Minute) defer installCancel() - if err := install.OpenShiftConsoleDownloadLink(installCtx, c); err != nil { - log.Info("Cannot install OpenShift CLI download link: skipping.") - log.V(8).Info("Error while installing OpenShift CLI download link", "error", err) - } + install.OperatorStartupOptionalTools(installCtx, c, log) // Setup all Controllers if err := controller.AddToManager(mgr); err != nil { diff --git a/pkg/install/optional.go b/pkg/install/optional.go new file mode 100644 index 0000000..f3fe873 --- /dev/null +++ b/pkg/install/optional.go @@ -0,0 +1,29 @@ +package install + +import ( + "context" + "github.com/apache/camel-k/pkg/client" + "github.com/go-logr/logr" +) + +// OperatorStartupOptionalTools tries to install optional tools at operator startup and warns if something goes wrong +func OperatorStartupOptionalTools(ctx context.Context, c client.Client, log logr.Logger) { + + // Try to register the OpenShift CLI Download link if possible + if err := OpenShiftConsoleDownloadLink(ctx, c); err != nil { + log.Info("Cannot install OpenShift CLI download link: skipping.") + log.V(8).Info("Error while installing OpenShift CLI download link", "error", err) + } + + // Try to register the cluster role for standard admin and edit users + if clusterRoleInstalled, err := IsClusterRoleInstalled(ctx, c); err != nil { + log.Info("Cannot detect user cluster role: skipping.") + log.V(8).Info("Error while getting user cluster role", "error", err) + } else if !clusterRoleInstalled { + if err := installClusterRole(ctx, c, nil); err != nil { + log.Info("Cannot install user cluster role: skipping.") + log.V(8).Info("Error while installing user cluster role", "error", err) + } + } + +}