This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 28cbdd3b229ed05df4b6f951089b1815920e0282
Author: Antonin Stefanutti <anto...@stefanutti.fr>
AuthorDate: Mon Feb 24 19:14:04 2020 +0100

    chore: Avoid another call to k8s discovery API and infer cluster from status
---
 pkg/install/builder.go   | 10 +++-------
 pkg/platform/defaults.go |  2 +-
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/pkg/install/builder.go b/pkg/install/builder.go
index 9a43999..f8af463 100644
--- a/pkg/install/builder.go
+++ b/pkg/install/builder.go
@@ -20,17 +20,13 @@ package install
 import (
        "context"
 
+       v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
        "github.com/apache/camel-k/pkg/client"
-       "github.com/apache/camel-k/pkg/util/openshift"
 )
 
 // BuilderServiceAccountRoles installs the builder service account and related 
roles in the given namespace
-func BuilderServiceAccountRoles(ctx context.Context, c client.Client, 
namespace string) error {
-       isOpenShift, err := openshift.IsOpenShift(c)
-       if err != nil {
-               return err
-       }
-       if isOpenShift {
+func BuilderServiceAccountRoles(ctx context.Context, c client.Client, 
namespace string, cluster v1.IntegrationPlatformCluster) error {
+       if cluster == v1.IntegrationPlatformClusterOpenShift {
                if err := installBuilderServiceAccountRolesOpenShift(ctx, c, 
namespace); err != nil {
                        return err
                }
diff --git a/pkg/platform/defaults.go b/pkg/platform/defaults.go
index 9afd250..c508d25 100644
--- a/pkg/platform/defaults.go
+++ b/pkg/platform/defaults.go
@@ -285,7 +285,7 @@ func createBuilderServiceAccount(ctx context.Context, 
client client.Client, p *v
 
        err := client.Get(ctx, key, &sa)
        if err != nil && k8serrors.IsNotFound(err) {
-               return install.BuilderServiceAccountRoles(ctx, client, 
p.Namespace)
+               return install.BuilderServiceAccountRoles(ctx, client, 
p.Namespace, p.Status.Cluster)
        }
 
        return err

Reply via email to