diff --git a/cmd/argocd/commands/headless/headless.go b/cmd/argocd/commands/headless/headless.go index a3b4b5ec6c3f0..1b033d05da068 100644 --- a/cmd/argocd/commands/headless/headless.go +++ b/cmd/argocd/commands/headless/headless.go @@ -12,10 +12,10 @@ import ( "github.com/golang/protobuf/ptypes/empty" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" + "github.com/spf13/pflag" "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/cache" - "k8s.io/client-go/tools/clientcmd" argoapi "github.com/argoproj/argo-cd/v2/pkg/apiclient" "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" @@ -43,21 +43,20 @@ func testAPI(clientOpts *argoapi.ClientOptions) error { return err } -func addKubectlFlagsToCmd(cmd *cobra.Command) clientcmd.ClientConfig { - loadingRules := clientcmd.NewDefaultClientConfigLoadingRules() - loadingRules.DefaultClientConfig = &clientcmd.DefaultClientConfig - overrides := clientcmd.ConfigOverrides{} - kflags := clientcmd.RecommendedConfigOverrideFlags("") - cmd.Flags().StringVar(&loadingRules.ExplicitPath, "kubeconfig", "", "Path to a kube config. Only required if out-of-cluster") - clientcmd.BindOverrideFlags(&overrides, cmd.Flags(), kflags) - return clientcmd.NewInteractiveDeferredLoadingClientConfig(loadingRules, &overrides, os.Stdin) -} - // InitCommand allows executing command in a headless mode: on the fly starts Argo CD API server and // changes provided client options to use started API server port func InitCommand(cmd *cobra.Command, clientOpts *argoapi.ClientOptions, port *int) *cobra.Command { ctx, cancel := context.WithCancel(context.Background()) - clientConfig := addKubectlFlagsToCmd(cmd) + flags := pflag.NewFlagSet("tmp", pflag.ContinueOnError) + clientConfig := cli.AddKubectlFlagsToSet(flags) + // copy k8s persistent flags into argocd command flags + flags.VisitAll(func(flag *pflag.Flag) { + // skip Kubernetes server flags since argocd has it's own server flag + if flag.Name == "server" { + return + } + cmd.Flags().AddFlag(flag) + }) cmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error { startInProcessAPI := clientOpts.Core if !startInProcessAPI { diff --git a/docs/proposals/002-ui-extensions.md b/docs/proposals/002-ui-extensions.md index 979bd3bee6616..8fa02d25fd11c 100644 --- a/docs/proposals/002-ui-extensions.md +++ b/docs/proposals/002-ui-extensions.md @@ -72,7 +72,7 @@ It is proposed that a git repository be used to contain the javascript code, as In the most simplest form, an Argo CD extension could simply be a pointer to a git repository at a revision: -```yaml= +```yaml kind: ArgoCDExtension metadata: name: argo-rollouts diff --git a/go.mod b/go.mod index 7e7c86c7654be..97df0318b62ae 100644 --- a/go.mod +++ b/go.mod @@ -51,6 +51,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/pquerna/cachecontrol v0.0.0-20180306154005-525d0eb5f91d // indirect github.com/prometheus/client_golang v1.7.1 + github.com/r3labs/diff v1.1.0 github.com/robfig/cron v1.1.0 github.com/rs/cors v1.6.0 // indirect github.com/sirupsen/logrus v1.7.0 diff --git a/go.sum b/go.sum index 66c234b061180..5fb34adc9c0d4 100644 --- a/go.sum +++ b/go.sum @@ -668,6 +668,8 @@ github.com/prometheus/procfs v0.2.0 h1:wH4vA7pcjKuZzjF7lM8awk4fnuJO6idemZXoKnULU github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/quobyte/api v0.1.8/go.mod h1:jL7lIHrmqQ7yh05OJ+eEEdHr0u/kmT1Ff9iHd+4H6VI= +github.com/r3labs/diff v1.1.0 h1:V53xhrbTHrWFWq3gI4b94AjgEJOerO1+1l0xyHOBi8M= +github.com/r3labs/diff v1.1.0/go.mod h1:7WjXasNzi0vJetRcB/RqNl5dlIsmXcTTLmF5IoH6Xig= github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M= github.com/robfig/cron v1.1.0 h1:jk4/Hud3TTdcrJgUOBgsqrZBarcxl6ADIjSC2iniwLY= github.com/robfig/cron v1.1.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k= diff --git a/reposerver/apiclient/repository.pb.go b/reposerver/apiclient/repository.pb.go index d8b0f1e182584..e14d0a99f558a 100644 --- a/reposerver/apiclient/repository.pb.go +++ b/reposerver/apiclient/repository.pb.go @@ -594,6 +594,7 @@ type RepoServerAppDetailsQuery struct { KustomizeOptions *v1alpha1.KustomizeOptions `protobuf:"bytes,4,opt,name=kustomizeOptions,proto3" json:"kustomizeOptions,omitempty"` AppName string `protobuf:"bytes,5,opt,name=appName,proto3" json:"appName,omitempty"` NoCache bool `protobuf:"varint,6,opt,name=noCache,proto3" json:"noCache,omitempty"` + NoRevisionCache bool `protobuf:"varint,7,opt,name=noRevisionCache,proto3" json:"noRevisionCache,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -674,6 +675,13 @@ func (m *RepoServerAppDetailsQuery) GetNoCache() bool { return false } +func (m *RepoServerAppDetailsQuery) GetNoRevisionCache() bool { + if m != nil { + return m.NoRevisionCache + } + return false +} + // RepoAppDetailsResponse application details type RepoAppDetailsResponse struct { Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` @@ -1359,94 +1367,95 @@ func init() { } var fileDescriptor_dd8723cfcc820480 = []byte{ - // 1392 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x18, 0xcb, 0x6e, 0xdb, 0xc6, - 0xd6, 0x94, 0xe4, 0x87, 0x8e, 0x12, 0x5b, 0x9e, 0x3c, 0x2e, 0xaf, 0xae, 0x23, 0x38, 0x04, 0x6e, - 0xe0, 0x36, 0x0d, 0x85, 0x28, 0x41,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ae, 0xe4, 0x84, 0x99, 0xd9, 0x7a, 0x3a, 0x6f, 0xce, 0xe6, 0xc5, 0x1a, 0x0b, 0x64, 0x5f, 0xba, - 0x9d, 0xe5, 0x1e, 0xb9, 0x52, 0x9a, 0x64, 0x69, 0xf4, 0xda, 0x27, 0xa1, 0x13, 0x57, 0x3f, 0xe9, - 0xfd, 0xfe, 0xba, 0xad, 0xfd, 0xf1, 0xba, 0xad, 0xfd, 0xf5, 0xba, 0xad, 0x7d, 0x79, 0xeb, 0x5f, - 0x7e, 0x64, 0x52, 0x7e, 0x0f, 0xa3, 0x9c, 0xd9, 0x23, 0x86, 0x6e, 0x78, 0xb8, 0x24, 0x7f, 0x52, - 0xba, 0xf5, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf6, 0x7e, 0x8e, 0xd3, 0x2e, 0x13, 0x00, 0x00, + // 1399 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x58, 0x4b, 0x6f, 0xdb, 0xc6, + 0x16, 0x36, 0x65, 0xd9, 0xb2, 0x8e, 0x12, 0x5b, 0x9e, 0x3c, 0x2e, 0xaf, 0xae, 0x23, 0x38, 0x04, + 0x6e, 0xe0, 0x36, 0x0d, 0x85, 0x28, 0x41, 0x1b, 0x24, 0x40, 0x01, 0xd5, 0x49, 0x1c, 0xc0, 0x49, + 0xec, 0xd2, 0x69, 0x81, 0x16, 0x41, 0x83, 0x31, 0x75, 0x4c, 0x4d, 0x25, 0x91, 0x13, 0x92, 0x52, + 0xe1, 0x00, 0x5d, 0x16, 0x5d, 0x74, 0xdd, 0xae, 0xfa, 0x5f, 0xba, 0xea, 0x63, 0xd9, 0xfe, 0x83, + 0x22, 0xbf, 0xa4, 0x98, 0xe1, 0x6b, 0x48, 0xd1, 0xee, 0x42, 0x89, 0xb3, 0xb1, 0x67, 0xce, 0x7b, + 0xce, 0x9c, 0xf3, 0xcd, 0xa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, 0x1e, 0x2e, 0xcb, 0x1f, 0x9f, 0x6e, 0xfd, 0x13, 0x00, 0x00, 0xff, 0xff, 0x9e, + 0x66, 0xb6, 0xa2, 0x58, 0x13, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2291,6 +2300,16 @@ func (m *RepoServerAppDetailsQuery) MarshalToSizedBuffer(dAtA []byte) (int, erro i -= len(m.XXX_unrecognized) copy(dAtA[i:], m.XXX_unrecognized) } + if m.NoRevisionCache { + i-- + if m.NoRevisionCache { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x38 + } if m.NoCache { i-- if m.NoCache { @@ -3199,6 +3218,9 @@ func (m *RepoServerAppDetailsQuery) Size() (n int) { if m.NoCache { n += 2 } + if m.NoRevisionCache { + n += 2 + } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } @@ -5105,6 +5127,26 @@ func (m *RepoServerAppDetailsQuery) Unmarshal(dAtA []byte) error { } } m.NoCache = bool(v != 0) + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NoRevisionCache", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRepository + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.NoRevisionCache = bool(v != 0) default: iNdEx = preIndex skippy, err := skipRepository(dAtA[iNdEx:]) diff --git a/reposerver/repository/repository.go b/reposerver/repository/repository.go index 54f6fb7dad0be..ff632d84d34b7 100644 --- a/reposerver/repository/repository.go +++ b/reposerver/repository/repository.go @@ -1179,7 +1179,7 @@ func (s *Service) GetAppDetails(ctx context.Context, q *apiclient.RepoServerAppD return nil } - settings := operationSettings{allowConcurrent: q.Source.AllowsConcurrentProcessing(), noCache: q.NoCache, noRevisionCache: q.NoCache} + settings := operationSettings{allowConcurrent: q.Source.AllowsConcurrentProcessing(), noCache: q.NoCache, noRevisionCache: q.NoCache || q.NoRevisionCache} err := s.runRepoOperation(ctx, q.Source.TargetRevision, q.Repo, q.Source, false, cacheFn, operation, settings) return res, err diff --git a/reposerver/repository/repository.proto b/reposerver/repository/repository.proto index ff98ccb68d05b..bd729bcb412f0 100644 --- a/reposerver/repository/repository.proto +++ b/reposerver/repository/repository.proto @@ -81,6 +81,7 @@ message RepoServerAppDetailsQuery { github.com.argoproj.argo_cd.v2.pkg.apis.application.v1alpha1.KustomizeOptions kustomizeOptions = 4; string appName = 5; bool noCache = 6; + bool noRevisionCache = 7; } // RepoAppDetailsResponse application details diff --git a/server/application/application.go b/server/application/application.go index 53d6a27acaf2f..483aa57abd6e4 100644 --- a/server/application/application.go +++ b/server/application/application.go @@ -212,7 +212,7 @@ func (s *Server) Create(ctx context.Context, q *application.ApplicationCreateReq return existing, nil } if q.Upsert == nil || !*q.Upsert { - return nil, status.Errorf(codes.InvalidArgument, "existing application spec is different, use upsert flag to force update") + return nil, status.Errorf(codes.InvalidArgument, argo.GenerateSpecIsDifferentErrorMessage("application", existing.Spec, a.Spec)) } if err := s.enf.EnforceErr(ctx.Value("claims"), rbacpolicy.ResourceApplications, rbacpolicy.ActionUpdate, appRBACName(a)); err != nil { return nil, err diff --git a/server/cluster/cluster.go b/server/cluster/cluster.go index f7ca608f7389c..b09c9e4593587 100644 --- a/server/cluster/cluster.go +++ b/server/cluster/cluster.go @@ -3,6 +3,8 @@ package cluster import ( "time" + "github.com/argoproj/argo-cd/v2/util/argo" + "github.com/argoproj/gitops-engine/pkg/utils/kube" log "github.com/sirupsen/logrus" "golang.org/x/net/context" @@ -93,7 +95,7 @@ func (s *Server) Create(ctx context.Context, q *cluster.ClusterCreateRequest) (* } else if q.Upsert { return s.Update(ctx, &cluster.ClusterUpdateRequest{Cluster: c}) } else { - return nil, status.Errorf(codes.InvalidArgument, "existing cluster spec is different; use upsert flag to force update") + return nil, status.Errorf(codes.InvalidArgument, argo.GenerateSpecIsDifferentErrorMessage("cluster", existing, c)) } } err = s.cache.SetClusterInfo(c.Server, &appv1.ClusterInfo{ diff --git a/server/project/project.go b/server/project/project.go index eadd96632c39a..69559cc9a7302 100644 --- a/server/project/project.go +++ b/server/project/project.go @@ -211,7 +211,7 @@ func (s *Server) Create(ctx context.Context, q *project.ProjectCreateRequest) (* res, err = s.appclientset.ArgoprojV1alpha1().AppProjects(s.ns).Update(ctx, existing, metav1.UpdateOptions{}) } else { if !reflect.DeepEqual(existing.Spec, q.GetProject().Spec) { - return nil, status.Errorf(codes.InvalidArgument, "existing project spec is different, use upsert flag to force update") + return nil, status.Errorf(codes.InvalidArgument, argo.GenerateSpecIsDifferentErrorMessage("project", existing.Spec, q.GetProject().Spec)) } return existing, nil } diff --git a/server/repocreds/repocreds.go b/server/repocreds/repocreds.go index ee38096fedbcc..add37e5a38c93 100644 --- a/server/repocreds/repocreds.go +++ b/server/repocreds/repocreds.go @@ -3,6 +3,8 @@ package repocreds import ( "reflect" + "github.com/argoproj/argo-cd/v2/util/argo" + "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -91,7 +93,7 @@ func (s *Server) CreateRepositoryCredentials(ctx context.Context, q *repocredspk } else if q.Upsert { return s.UpdateRepositoryCredentials(ctx, &repocredspkg.RepoCredsUpdateRequest{Creds: r}) } else { - return nil, status.Errorf(codes.InvalidArgument, "existing repository credentials spec is different; use upsert flag to force update") + return nil, status.Errorf(codes.InvalidArgument, argo.GenerateSpecIsDifferentErrorMessage("repository credentials", existing, r)) } } return &appsv1.RepoCreds{URL: r.URL}, err diff --git a/server/repository/repository.go b/server/repository/repository.go index f791c74f7bece..65d45b56c4af5 100644 --- a/server/repository/repository.go +++ b/server/repository/repository.go @@ -4,6 +4,8 @@ import ( "fmt" "reflect" + "github.com/argoproj/argo-cd/v2/util/argo" + "github.com/argoproj/gitops-engine/pkg/utils/kube" "github.com/argoproj/gitops-engine/pkg/utils/text" log "github.com/sirupsen/logrus" @@ -343,7 +345,7 @@ func (s *Server) CreateRepository(ctx context.Context, q *repositorypkg.RepoCrea r.Project = q.Repo.Project return s.UpdateRepository(ctx, &repositorypkg.RepoUpdateRequest{Repo: r}) } else { - return nil, status.Errorf(codes.InvalidArgument, "existing repository spec is different; use upsert flag to force update") + return nil, status.Errorf(codes.InvalidArgument, argo.GenerateSpecIsDifferentErrorMessage("repository", existing, r)) } } if err != nil { diff --git a/ui/src/app/applications/components/application-create-panel/application-create-panel.tsx b/ui/src/app/applications/components/application-create-panel/application-create-panel.tsx index 1cf9cb5c36d30..fa38071f23e29 100644 --- a/ui/src/app/applications/components/application-create-panel/application-create-panel.tsx +++ b/ui/src/app/applications/components/application-create-panel/application-create-panel.tsx @@ -6,6 +6,7 @@ import {RevisionHelpIcon, YamlEditor} from '../../../shared/components'; import * as models from '../../../shared/models'; import {services} from '../../../shared/services'; import {ApplicationParameters} from '../application-parameters/application-parameters'; +import {ApplicationRetryOptions} from '../application-retry-options/application-retry-options'; import {ApplicationSyncOptionsField} from '../application-sync-options/application-sync-options'; import {RevisionFormField} from '../revision-form-field/revision-form-field'; @@ -221,6 +222,7 @@ export const ApplicationCreatePanel = (props: {
+
); diff --git a/util/argo/argo.go b/util/argo/argo.go index 0f60fb99dd033..5a020e058ef63 100644 --- a/util/argo/argo.go +++ b/util/argo/argo.go @@ -7,6 +7,8 @@ import ( "strings" "time" + "github.com/r3labs/diff" + "github.com/argoproj/gitops-engine/pkg/utils/kube" log "github.com/sirupsen/logrus" "google.golang.org/grpc/codes" @@ -240,6 +242,8 @@ func ValidateRepo( Source: &spec.Source, Repos: permittedHelmRepos, KustomizeOptions: kustomizeOptions, + // don't use case during application change to make sure to fetch latest git/helm revisions + NoRevisionCache: true, }) if err != nil { conditions = append(conditions, argoappv1.ApplicationCondition{ @@ -692,3 +696,24 @@ func mergeVirtualProject(proj *argoappv1.AppProject, globalProj *argoappv1.AppPr return proj } + +func GenerateSpecIsDifferentErrorMessage(entity string, a, b interface{}) string { + basicMsg := fmt.Sprintf("existing %s spec is different; use upsert flag to force update", entity) + difference, _ := GetDifferentPathsBetweenStructs(a, b) + if len(difference) == 0 { + return basicMsg + } + return fmt.Sprintf("%s; difference in keys \"%s\"", basicMsg, strings.Join(difference[:], ",")) +} + +func GetDifferentPathsBetweenStructs(a, b interface{}) ([]string, error) { + var difference []string + changelog, err := diff.Diff(a, b) + if err != nil { + return nil, err + } + for _, changeItem := range changelog { + difference = append(difference, changeItem.Path...) + } + return difference, nil +} diff --git a/util/argo/argo_test.go b/util/argo/argo_test.go index ff1979f53b9ab..f95f77cbde372 100644 --- a/util/argo/argo_test.go +++ b/util/argo/argo_test.go @@ -253,6 +253,7 @@ func TestValidateRepo(t *testing.T) { Source: &app.Spec.Source, Repos: helmRepos, KustomizeOptions: kustomizeOptions, + NoRevisionCache: true, }).Return(&apiclient.RepoAppDetailsResponse{}, nil) repo.Type = "git" @@ -880,3 +881,37 @@ func Test_retrieveScopedRepositoriesWithNotProjectAssigned(t *testing.T) { assert.Len(t, scopedRepos, 0) } + +func Test_GetDifferentPathsBetweenStructs(t *testing.T) { + + r1 := argoappv1.Repository{} + r2 := argoappv1.Repository{ + Name: "SomeName", + } + + difference, _ := GetDifferentPathsBetweenStructs(r1, r2) + assert.Equal(t, difference, []string{"Name"}) + +} + +func Test_GenerateSpecIsDifferentErrorMessageWithNoDiff(t *testing.T) { + + r1 := argoappv1.Repository{} + r2 := argoappv1.Repository{} + + msg := GenerateSpecIsDifferentErrorMessage("application", r1, r2) + assert.Equal(t, msg, "existing application spec is different; use upsert flag to force update") + +} + +func Test_GenerateSpecIsDifferentErrorMessageWithDiff(t *testing.T) { + + r1 := argoappv1.Repository{} + r2 := argoappv1.Repository{ + Name: "test", + } + + msg := GenerateSpecIsDifferentErrorMessage("repo", r1, r2) + assert.Equal(t, msg, "existing repo spec is different; use upsert flag to force update; difference in keys \"Name\"") + +} diff --git a/util/cache/redis_hook_test.go b/util/cache/redis_hook_test.go new file mode 100644 index 0000000000000..8a4b02ad9ab27 --- /dev/null +++ b/util/cache/redis_hook_test.go @@ -0,0 +1,38 @@ +package cache + +import ( + "context" + "errors" + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/go-redis/redis/v8" +) + +func Test_ReconnectCallbackHookCalled(t *testing.T) { + called := false + hook := NewArgoRedisHook(func() { + called = true + }) + + cmd := &redis.StringCmd{} + cmd.SetErr(errors.New("Failed to resync revoked tokens. retrying again in 1 minute: dial tcp: lookup argocd-redis on 10.179.0.10:53: no such host")) + + _ = hook.AfterProcess(context.Background(), cmd) + + assert.Equal(t, called, true) +} + +func Test_ReconnectCallbackHookNotCalled(t *testing.T) { + called := false + hook := NewArgoRedisHook(func() { + called = true + }) + cmd := &redis.StringCmd{} + cmd.SetErr(errors.New("Something wrong")) + + _ = hook.AfterProcess(context.Background(), cmd) + + assert.Equal(t, called, false) +} diff --git a/util/cli/cli.go b/util/cli/cli.go index c37b5269f0659..7554fe6712b1d 100644 --- a/util/cli/cli.go +++ b/util/cli/cli.go @@ -18,6 +18,7 @@ import ( "github.com/google/shlex" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" + "github.com/spf13/pflag" terminal "golang.org/x/term" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/client-go/tools/clientcmd" @@ -58,15 +59,21 @@ func NewVersionCmd(cliName string) *cobra.Command { return &versionCmd } -// AddKubectlFlagsToCmd adds kubectl like flags to a command and returns the ClientConfig interface +// AddKubectlFlagsToCmd adds kubectl like flags to a persistent flags of a command and returns the ClientConfig interface // for retrieving the values. func AddKubectlFlagsToCmd(cmd *cobra.Command) clientcmd.ClientConfig { + return AddKubectlFlagsToSet(cmd.PersistentFlags()) +} + +// AddKubectlFlagsToSet adds kubectl like flags to a provided flag set and returns the ClientConfig interface +// for retrieving the values. +func AddKubectlFlagsToSet(flags *pflag.FlagSet) clientcmd.ClientConfig { loadingRules := clientcmd.NewDefaultClientConfigLoadingRules() loadingRules.DefaultClientConfig = &clientcmd.DefaultClientConfig overrides := clientcmd.ConfigOverrides{} kflags := clientcmd.RecommendedConfigOverrideFlags("") - cmd.PersistentFlags().StringVar(&loadingRules.ExplicitPath, "kubeconfig", "", "Path to a kube config. Only required if out-of-cluster") - clientcmd.BindOverrideFlags(&overrides, cmd.PersistentFlags(), kflags) + flags.StringVar(&loadingRules.ExplicitPath, "kubeconfig", "", "Path to a kube config. Only required if out-of-cluster") + clientcmd.BindOverrideFlags(&overrides, flags, kflags) return clientcmd.NewInteractiveDeferredLoadingClientConfig(loadingRules, &overrides, os.Stdin) }