This is an automated email from the ASF dual-hosted git repository.
lburgazzoli 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 66d282c CAMEL-12789: complete install command
66d282c is described below
commit 66d282c6bb2e148954ec98c8f95181900342786f
Author: nferraro <[email protected]>
AuthorDate: Tue Sep 11 12:10:11 2018 +0200
CAMEL-12789: complete install command
---
README.md | 2 +-
pkg/client/cmd/install.go | 22 ++++++++++++++++------
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index b360da8..d996909 100644
--- a/README.md
+++ b/README.md
@@ -48,7 +48,7 @@ This will configure the cluster with the Camel K custom
resource definitions and
**Note:** Custom Resource Definitions (CRD) are cluster-wide objects and you
need admin rights to install them. Fortunately this
operation can be done once per cluster. So, if the `kamel install` operation
fails, you'll be asked to repeat it when logged as admin.
-For Minishift, this means executing `oc login -u system:admin` before
first-time installation only.
+For Minishift, this means executing `oc login -u system:admin` then `kamel
install --cluster-setup` only for first-time installation.
### Running a Integration
diff --git a/pkg/client/cmd/install.go b/pkg/client/cmd/install.go
index 27fa96f..12746c8 100644
--- a/pkg/client/cmd/install.go
+++ b/pkg/client/cmd/install.go
@@ -23,6 +23,7 @@ import (
"github.com/apache/camel-k/pkg/install"
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/api/errors"
+ "os"
)
type InstallCmdOptions struct {
@@ -40,6 +41,10 @@ func NewCmdInstall(rootCmdOptions *RootCmdOptions)
*cobra.Command {
Long: `Installs Camel K on a Kubernetes or Openshift cluster.`,
RunE: options.install,
}
+
+ cmd.Flags().BoolVar(&options.ClusterSetupOnly, "cluster-setup", false,
"Execute cluster-wide operations only (may require admin rights)")
+ cmd.ParseFlags(os.Args)
+
return &cmd
}
@@ -48,16 +53,21 @@ func (o *InstallCmdOptions) install(cmd *cobra.Command,
args []string) error {
if err != nil && errors.IsForbidden(err) {
// TODO explain that this is a one time operation and add a
flag to do cluster-level operations only when logged as admin
fmt.Println("Current user is not authorized to create
cluster-wide objects like custom resource definitions or cluster roles: ", err)
- fmt.Println("Please login as cluster-admin to continue the
installation.")
+ fmt.Println("Please login as cluster-admin and execute \"kamel
install --cluster-setup\" to install those resources (one-time operation).")
return nil // TODO better error handling: if here we return err
the help page is shown
}
- namespace := o.Namespace
+ if o.ClusterSetupOnly {
+ fmt.Println("Camel K cluster setup completed successfully")
+ } else {
+ namespace := o.Namespace
- err = install.Operator(namespace)
- if err != nil {
- return err
+ err = install.Operator(namespace)
+ if err != nil {
+ return err
+ }
+ fmt.Println("Camel K installed in namespace", namespace)
}
- fmt.Println("Camel K installed in namespace", namespace)
+
return nil
}