Skip to content

Commit dcb3216

Browse files
authored
feat: add --skip-setup flag to develop script (#24794)
1 parent 12e9f5b commit dcb3216

1 file changed

Lines changed: 37 additions & 28 deletions

File tree

scripts/develop/main.go

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,22 @@ func main() {
127127
Description: "Start a workspace proxy.",
128128
Value: serpent.BoolOf(&cfg.useProxy),
129129
},
130-
{
131-
Flag: "multi-organization",
132-
Description: "Create a second organization.",
133-
Value: serpent.BoolOf(&cfg.multiOrg),
134-
},
135130
{
136131
Flag: "debug",
137132
Description: "Run under Delve debugger.",
138133
Value: serpent.BoolOf(&cfg.debug),
139134
},
135+
{
136+
Flag: "skip-setup",
137+
Env: "CODER_DEV_SKIP_SETUP",
138+
Description: "Don't attempt to create a first user or other resources. Will cause multi-organization, starter-template, and use-proxy to be ignored.",
139+
Value: serpent.BoolOf(&cfg.skipSetup),
140+
},
141+
{
142+
Flag: "multi-organization",
143+
Description: "Create a second organization.",
144+
Value: serpent.BoolOf(&cfg.multiOrg),
145+
},
140146
{
141147
Flag: "starter-template",
142148
Env: "CODER_DEV_STARTER_TEMPLATE",
@@ -194,8 +200,9 @@ type devConfig struct {
194200
accessURL string
195201
password string
196202
useProxy bool
197-
multiOrg bool
198203
debug bool
204+
skipSetup bool
205+
multiOrg bool
199206
starterTemplate string
200207
dbRollback bool
201208
dbReset bool
@@ -469,24 +476,6 @@ func develop(ctx context.Context, logger slog.Logger, cfg *devConfig) error {
469476
return err
470477
}
471478

472-
client, err := setupFirstUser(ctx, logger, cfg, apiURL)
473-
if err != nil {
474-
return xerrors.Errorf("setup: %w", err)
475-
}
476-
477-
if cfg.multiOrg {
478-
if err := setupMultiOrg(ctx, logger, cfg, client, group); err != nil {
479-
logger.Warn(ctx, "multi-org setup failed, continuing",
480-
slog.Error(err))
481-
}
482-
}
483-
484-
if cfg.starterTemplate != "" {
485-
if err := setupStarterTemplate(ctx, logger, cfg, client); err != nil {
486-
logger.Warn(ctx, "starter template setup failed, continuing", slog.Error(err))
487-
}
488-
}
489-
490479
// Update migration tracking after the server has applied
491480
// any new migrations. This keeps the cache current so the
492481
// next run detects mismatches correctly.
@@ -495,10 +484,30 @@ func develop(ctx context.Context, logger slog.Logger, cfg *devConfig) error {
495484
slog.Error(err))
496485
}
497486

498-
if cfg.useProxy {
499-
if err := setupWorkspaceProxy(ctx, cfg, client, group); err != nil {
500-
logger.Warn(ctx, "proxy setup failed, continuing",
501-
slog.Error(err))
487+
if !cfg.skipSetup {
488+
client, err := setupFirstUser(ctx, logger, cfg, apiURL)
489+
if err != nil {
490+
return xerrors.Errorf("setup: %w", err)
491+
}
492+
493+
if cfg.multiOrg {
494+
if err := setupMultiOrg(ctx, logger, cfg, client, group); err != nil {
495+
logger.Warn(ctx, "multi-org setup failed, continuing",
496+
slog.Error(err))
497+
}
498+
}
499+
500+
if cfg.starterTemplate != "" {
501+
if err := setupStarterTemplate(ctx, logger, cfg, client); err != nil {
502+
logger.Warn(ctx, "starter template setup failed, continuing", slog.Error(err))
503+
}
504+
}
505+
506+
if cfg.useProxy {
507+
if err := setupWorkspaceProxy(ctx, cfg, client, group); err != nil {
508+
logger.Warn(ctx, "proxy setup failed, continuing",
509+
slog.Error(err))
510+
}
502511
}
503512
}
504513

0 commit comments

Comments
 (0)