Skip to content

Commit

Permalink
fix: removed cmd.ParseFlags
Browse files Browse the repository at this point in the history
  • Loading branch information
zregvart committed Dec 5, 2018
1 parent 144e04d commit 342aec9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
10 changes: 2 additions & 8 deletions pkg/client/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ package cmd
import (
"fmt"

"os"

"github.com/apache/camel-k/pkg/install"
"github.com/pkg/errors"
"github.com/spf13/cobra"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
)

func newCmdInstall(rootCmdOptions *RootCmdOptions) (*cobra.Command, error) {
func newCmdInstall(rootCmdOptions *RootCmdOptions) *cobra.Command {
options := installCmdOptions{
RootCmdOptions: rootCmdOptions,
}
Expand All @@ -44,12 +42,8 @@ func newCmdInstall(rootCmdOptions *RootCmdOptions) (*cobra.Command, error) {
cmd.Flags().StringVar(&options.registry, "registry", "", "A Docker registry that can be used to publish images")
cmd.Flags().StringVar(&options.organization, "organization", "", "A organization on the Docker registry that can be used to publish images")
cmd.Flags().StringVar(&options.pushSecret, "push-secret", "", "A secret used to push images to the Docker registry")
err := cmd.ParseFlags(os.Args)
if err != nil {
return nil, err
}

return &cmd, nil
return &cmd
}

type installCmdOptions struct {
Expand Down
15 changes: 2 additions & 13 deletions pkg/client/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package cmd

import (
"context"
"os"
"time"

"github.com/operator-framework/operator-sdk/pkg/k8sclient"
Expand Down Expand Up @@ -57,12 +56,6 @@ func NewKamelCommand(ctx context.Context) (*cobra.Command, error) {
cmd.PersistentFlags().StringVar(&options.KubeConfig, "config", "", "Path to the config file to use for CLI requests")
cmd.PersistentFlags().StringVarP(&options.Namespace, "namespace", "n", "", "Namespace to use for all operations")

// Parse the flags before setting the defaults
err := cmd.ParseFlags(os.Args)
if err != nil {
return nil, err
}

if options.Namespace == "" {
current, err := kubernetes.GetClientCurrentNamespace(options.KubeConfig)
if err != nil {
Expand All @@ -78,7 +71,7 @@ func NewKamelCommand(ctx context.Context) (*cobra.Command, error) {
k8sclient.ResetCacheEvery(2 * time.Second)

// Initialize the Kubernetes client to allow using the operator-sdk
err = kubernetes.InitKubeClient(options.KubeConfig)
err := kubernetes.InitKubeClient(options.KubeConfig)
if err != nil {
return nil, err
}
Expand All @@ -88,11 +81,7 @@ func NewKamelCommand(ctx context.Context) (*cobra.Command, error) {
cmd.AddCommand(newCmdRun(&options))
cmd.AddCommand(newCmdGet(&options))
cmd.AddCommand(newCmdDelete(&options))
install, err := newCmdInstall(&options)
if err != nil {
return nil, err
}
cmd.AddCommand(install)
cmd.AddCommand(newCmdInstall(&options))
cmd.AddCommand(newCmdLog(&options))
cmd.AddCommand(newCmdContext(&options))

Expand Down

0 comments on commit 342aec9

Please sign in to comment.