diff --git a/cmd/argocd/commands/headless/headless.go b/cmd/argocd/commands/headless/headless.go index f4d4503a9b723..0e1d7953b8226 100644 --- a/cmd/argocd/commands/headless/headless.go +++ b/cmd/argocd/commands/headless/headless.go @@ -15,7 +15,8 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/runtime" + "k8s.io/apimachinery/pkg/runtime" + runtimeUtil "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/client-go/dynamic" "k8s.io/client-go/kubernetes" cache2 "k8s.io/client-go/tools/cache" @@ -202,7 +203,7 @@ func MaybeStartLocalServer(ctx context.Context, clientOpts *apiclient.ClientOpti } // get rid of logging error handler - runtime.ErrorHandlers = runtime.ErrorHandlers[1:] + runtimeUtil.ErrorHandlers = runtimeUtil.ErrorHandlers[1:] cli.SetLogLevel(log.ErrorLevel.String()) log.SetLevel(log.ErrorLevel) os.Setenv(v1alpha1.EnvVarFakeInClusterConfig, "true") @@ -237,7 +238,14 @@ func MaybeStartLocalServer(ctx context.Context, clientOpts *apiclient.ClientOpti return fmt.Errorf("error creating kubernetes dynamic clientset: %w", err) } - controllerClientset, err := client.New(restConfig, client.Options{}) + scheme := runtime.NewScheme() + err = v1alpha1.AddToScheme(scheme) + if err != nil { + return fmt.Errorf("error adding argo resources to scheme: %w", err) + } + controllerClientset, err := client.New(restConfig, client.Options{ + Scheme: scheme, + }) if err != nil { return fmt.Errorf("error creating kubernetes controller clientset: %w", err) }