From dcb32165fa3b59d309ae7d628e43fa683370221f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kayla=20=E3=81=AF=E3=81=AA?= Date: Tue, 28 Apr 2026 13:49:43 -0600 Subject: [PATCH] feat: add `--skip-setup` flag to develop script (#24794) --- scripts/develop/main.go | 65 +++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/scripts/develop/main.go b/scripts/develop/main.go index 023d3a809d..6fa169cc70 100644 --- a/scripts/develop/main.go +++ b/scripts/develop/main.go @@ -127,16 +127,22 @@ func main() { Description: "Start a workspace proxy.", Value: serpent.BoolOf(&cfg.useProxy), }, - { - Flag: "multi-organization", - Description: "Create a second organization.", - Value: serpent.BoolOf(&cfg.multiOrg), - }, { Flag: "debug", Description: "Run under Delve debugger.", Value: serpent.BoolOf(&cfg.debug), }, + { + Flag: "skip-setup", + Env: "CODER_DEV_SKIP_SETUP", + Description: "Don't attempt to create a first user or other resources. Will cause multi-organization, starter-template, and use-proxy to be ignored.", + Value: serpent.BoolOf(&cfg.skipSetup), + }, + { + Flag: "multi-organization", + Description: "Create a second organization.", + Value: serpent.BoolOf(&cfg.multiOrg), + }, { Flag: "starter-template", Env: "CODER_DEV_STARTER_TEMPLATE", @@ -194,8 +200,9 @@ type devConfig struct { accessURL string password string useProxy bool - multiOrg bool debug bool + skipSetup bool + multiOrg bool starterTemplate string dbRollback bool dbReset bool @@ -469,24 +476,6 @@ func develop(ctx context.Context, logger slog.Logger, cfg *devConfig) error { return err } - client, err := setupFirstUser(ctx, logger, cfg, apiURL) - if err != nil { - return xerrors.Errorf("setup: %w", err) - } - - if cfg.multiOrg { - if err := setupMultiOrg(ctx, logger, cfg, client, group); err != nil { - logger.Warn(ctx, "multi-org setup failed, continuing", - slog.Error(err)) - } - } - - if cfg.starterTemplate != "" { - if err := setupStarterTemplate(ctx, logger, cfg, client); err != nil { - logger.Warn(ctx, "starter template setup failed, continuing", slog.Error(err)) - } - } - // Update migration tracking after the server has applied // any new migrations. This keeps the cache current so the // next run detects mismatches correctly. @@ -495,10 +484,30 @@ func develop(ctx context.Context, logger slog.Logger, cfg *devConfig) error { slog.Error(err)) } - if cfg.useProxy { - if err := setupWorkspaceProxy(ctx, cfg, client, group); err != nil { - logger.Warn(ctx, "proxy setup failed, continuing", - slog.Error(err)) + if !cfg.skipSetup { + client, err := setupFirstUser(ctx, logger, cfg, apiURL) + if err != nil { + return xerrors.Errorf("setup: %w", err) + } + + if cfg.multiOrg { + if err := setupMultiOrg(ctx, logger, cfg, client, group); err != nil { + logger.Warn(ctx, "multi-org setup failed, continuing", + slog.Error(err)) + } + } + + if cfg.starterTemplate != "" { + if err := setupStarterTemplate(ctx, logger, cfg, client); err != nil { + logger.Warn(ctx, "starter template setup failed, continuing", slog.Error(err)) + } + } + + if cfg.useProxy { + if err := setupWorkspaceProxy(ctx, cfg, client, group); err != nil { + logger.Warn(ctx, "proxy setup failed, continuing", + slog.Error(err)) + } } }