Skip to content

Commit

Permalink
mark kubeconfig flag required
Browse files Browse the repository at this point in the history
  • Loading branch information
MatousJobanek committed Aug 6, 2024
1 parent 456bd90 commit 3e6e6b8
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")

Check warning on line 56 in pkg/cmd/adm/must_gather_namespace.go

View check run for this annotation

Codecov / codecov/patch

pkg/cmd/adm/must_gather_namespace.go#L56

Added line #L56 was not covered by tests
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. "+

Check warning on line 55 in pkg/cmd/generate/cli_configs.go

View check run for this annotation

Codecov / codecov/patch

pkg/cmd/generate/cli_configs.go#L55

Added line #L55 was not covered by tests
"In dev mode, the first one has to represent the host cluster.")
flags.MustMarkRequired(command, "kubeconfig")

Check warning on line 57 in pkg/cmd/generate/cli_configs.go

View check run for this annotation

Codecov / codecov/patch

pkg/cmd/generate/cli_configs.go#L57

Added line #L57 was not covered by tests

return command
}
Expand Down

0 comments on commit 3e6e6b8

Please sign in to comment.