Skip to content

Commit

Permalink
cmd/install: don't show usage on install failure
Browse files Browse the repository at this point in the history
Before this patch, when the install fail (e.g. some validation failed)
the usage would be displayed. For example, when the minikube minium
version was not met:

     % go run ./cmd/cilium install
    🔮 Auto-detected Kubernetes kind: minikube
    ✨ Running "minikube" validation checks
    ❌ Validation test minimum-version failed: minimum version is ">=2.5.2", found version "1.16.0"
    ℹ️  You can disable the test with --disable-check=minimum-version
    Error: validation check for kind "minikube" failed: minimum version is ">=2.5.2", found version "1.16.0"
    Usage:
      cilium install [flags]

    Flags:
          --cluster-name string     Name of the cluster
          --datapath-mode string    Cilium version to install
          --disable-check strings   Disable a particular validation check
      -h, --help                    help for install
          --namespace string        Namespace to install Cilium into (default "kube-system")
          --version string          Cilium version to install

This patch make it so an install step error would not make cobra show
the usage.

See also spf13/cobra#340

Signed-off-by: Alexandre Perrin <alex@kaworu.ch>
  • Loading branch information
kaworu committed Jan 7, 2021
1 parent 452b581 commit 1201328
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions internal/cli/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func newCmdInstall() *cobra.Command {
Long: ``,
RunE: func(cmd *cobra.Command, args []string) error {
installer := install.NewK8sInstaller(k8sClient, params)
cmd.SilenceUsage = true
return installer.Install(context.Background())
},
}
Expand Down

0 comments on commit 1201328

Please sign in to comment.