git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GitHub] lburgazzoli closed pull request #22: CAMEL-12789: complete install command


lburgazzoli closed pull request #22: CAMEL-12789: complete install command
URL: https://github.com/apache/camel-k/pull/22
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@xxxxxxxxxxxxxxxx


With regards,
Apache Git Services