Skip to content

Commit

Permalink
mark kubeconfig flag required (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatousJobanek authored Aug 7, 2024
1 parent de57ecd commit 2cf7e16
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
7 changes: 1 addition & 6 deletions pkg/cmd/adm/must_gather_namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"k8s.io/client-go/discovery"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/util/homedir"
"k8s.io/kubectl/pkg/scheme"
runtimeclient "sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down Expand Up @@ -52,13 +51,9 @@ func NewMustGatherNamespaceCmd() *cobra.Command {
return MustGatherNamespace(term, kubeconfig, args[0], destDir)
},
}
defaultKubeconfigPath := ""
if home := homedir.HomeDir(); home != "" {
defaultKubeconfigPath = filepath.Join(home, ".kube", "config")
}
cmd.Flags().StringVar(&destDir, "dest-dir", "", "Gather information with a specific local folder to copy to")
flags.MustMarkRequired(cmd, "dest-dir")
cmd.Flags().StringVar(&kubeconfig, "kubeconfig", defaultKubeconfigPath, "Path to the kubeconfig file (default: "+defaultKubeconfigPath+")")
cmd.Flags().StringVar(&kubeconfig, "kubeconfig", "", "Path to the kubeconfig file")
flags.MustMarkRequired(cmd, "kubeconfig")
return cmd
}
Expand Down
9 changes: 2 additions & 7 deletions pkg/cmd/generate/cli_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"os"
"path/filepath"
"strings"

"github.com/kubesaw/ksctl/pkg/assets"
Expand All @@ -21,7 +20,6 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/util/homedir"
"k8s.io/kubectl/pkg/scheme"
"k8s.io/utils/pointer"
runtimeclient "sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -54,12 +52,9 @@ func NewCliConfigsCmd() *cobra.Command {
command.Flags().StringVarP(&f.outDir, "out-dir", "o", configDirPath, "Directory where generated ksctl.yaml files should be stored")
command.Flags().UintVarP(&f.tokenExpirationDays, "token-expiration-days", "e", 365, "Expiration time of the ServiceAccount tokens in days")

defaultKubeconfigPath := ""
if home := homedir.HomeDir(); home != "" {
defaultKubeconfigPath = filepath.Join(home, ".kube", "config")
}
command.Flags().StringSliceVarP(&f.kubeconfigs, "kubeconfig", "k", []string{defaultKubeconfigPath}, "Kubeconfig(s) for managing multiple clusters and the access to them - paths should be comma separated when using multiple of them. "+
command.Flags().StringSliceVarP(&f.kubeconfigs, "kubeconfig", "k", nil, "Kubeconfig(s) for managing multiple clusters and the access to them - paths should be comma separated when using multiple of them. "+
"In dev mode, the first one has to represent the host cluster.")
flags.MustMarkRequired(command, "kubeconfig")

return command
}
Expand Down

0 comments on commit 2cf7e16

Please sign in to comment.