Skip to content

Commit

Permalink
Add optional command line option to disable default project creation …
Browse files Browse the repository at this point in the history
…in headless mode

Signed-off-by: Henrik Huitti <henrik.huitti@henhu.fi>
  • Loading branch information
henkka committed Sep 19, 2023
1 parent 054749d commit d105162
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cmd/argocd/commands/headless/headless.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func testAPI(ctx context.Context, clientOpts *apiclient.ClientOptions) error {

// StartLocalServer 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 StartLocalServer(ctx context.Context, clientOpts *apiclient.ClientOptions, ctxStr string, port *int, address *string, compression cache.RedisCompressionType) error {
func StartLocalServer(ctx context.Context, clientOpts *apiclient.ClientOptions, ctxStr string, port *int, address *string, compression cache.RedisCompressionType, disableDefaultProjectCreation bool) error {
flags := pflag.NewFlagSet("tmp", pflag.ContinueOnError)
clientConfig := cli.AddKubectlFlagsToSet(flags)
startInProcessAPI := clientOpts.Core
Expand Down Expand Up @@ -222,7 +222,7 @@ func StartLocalServer(ctx context.Context, clientOpts *apiclient.ClientOptions,
ListenHost: *address,
RepoClientset: &forwardRepoClientset{namespace: namespace, context: ctxStr, repoServerName: clientOpts.RepoServerName},
EnableProxyExtension: false,
DisableDefaultProjectCreation: true,
DisableDefaultProjectCreation: disableDefaultProjectCreation,
})
srv.Init(ctx)

Expand Down Expand Up @@ -251,8 +251,12 @@ func StartLocalServer(ctx context.Context, clientOpts *apiclient.ClientOptions,
func NewClientOrDie(opts *apiclient.ClientOptions, c *cobra.Command) apiclient.Client {
ctx := c.Context()

var disableDefaultProjectCreation bool

c.Flags().BoolVar(&disableDefaultProjectCreation, "disable-default-project-creation", false, "Disable default project creation")

ctxStr := initialize.RetrieveContextIfChanged(c.Flag("context"))
err := StartLocalServer(ctx, opts, ctxStr, nil, nil, cache.RedisCompressionNone)
err := StartLocalServer(ctx, opts, ctxStr, nil, nil, cache.RedisCompressionNone, disableDefaultProjectCreation)
if err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit d105162

Please sign in to comment.