Skip to content

Commit

Permalink
de-duplicate common flags
Browse files Browse the repository at this point in the history
  • Loading branch information
ngtuna committed Oct 30, 2017
1 parent 013ef6a commit e502c51
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 1 addition & 3 deletions cmd/down.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/ksonnet/kubecfg/pkg/kubecfg"
"github.com/spf13/cobra"
"k8s.io/client-go/pkg/api"
)

var downCmd = &cobra.Command{
Expand Down Expand Up @@ -52,7 +51,6 @@ var downCmd = &cobra.Command{

func init() {
RootCmd.AddCommand(downCmd)
downCmd.Flags().StringP("namespace", "", api.NamespaceDefault, "Specify namespace for the KubeApps components")
downCmd.Flags().Int64("grace-period", -1, "Number of seconds given to resources to terminate gracefully. A negative value is ignored")
downCmd.Flags().String("path", "", "Specify folder contains the manifests")
bindFlags(downCmd)
}
7 changes: 7 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/client-go/discovery"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/pkg/api"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
)
Expand All @@ -29,6 +30,12 @@ var RootCmd = &cobra.Command{
},
}

func bindFlags(cmd *cobra.Command) {
cmd.Flags().StringP("namespace", "", api.NamespaceDefault, "Specify namespace for the KubeApps components")
cmd.Flags().String("path", "", "Specify folder contains the manifests")

}

func appendObj(res *[]*unstructured.Unstructured) filepath.WalkFunc {
return func(path string, info os.FileInfo, err error) error {
if err != nil {
Expand Down
6 changes: 2 additions & 4 deletions cmd/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ package cmd

import (
"os"
"path/filepath"

"github.com/ksonnet/kubecfg/metadata"
"github.com/ksonnet/kubecfg/pkg/kubecfg"
"github.com/spf13/cobra"
"k8s.io/client-go/pkg/api"
"path/filepath"
)

const (
Expand Down Expand Up @@ -68,7 +67,6 @@ var upCmd = &cobra.Command{

func init() {
RootCmd.AddCommand(upCmd)
upCmd.Flags().StringP("namespace", "", api.NamespaceDefault, "Specify namespace for the KubeApps components")
upCmd.Flags().Bool("dry-run", false, "Provides output to be submitted to the server")
upCmd.Flags().String("path", "", "Specify folder contains the manifests")
bindFlags(upCmd)
}

0 comments on commit e502c51

Please sign in to comment.