- Notifications
You must be signed in to change notification settings - Fork1k
feat(cli): add enterprise external-workspaces CLI command#19287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
1420bb3
8fd1729
888c97e
9bd7ae5
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -29,7 +29,12 @@ const PresetNone = "none" | ||
var ErrNoPresetFound = xerrors.New("no preset found") | ||
type CreateOptions struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Maybe you should put a comment here explaining what these are for. E.g. "CreateOptions provides middleware for the workspace creation command so it can be extended for other create commands." | ||
BeforeCreate func(ctx context.Context, client *codersdk.Client, template codersdk.Template, templateVersionID uuid.UUID) error | ||
AfterCreate func(ctx context.Context, inv *serpent.Invocation, client *codersdk.Client, workspace codersdk.Workspace) error | ||
} | ||
func (r *RootCmd) Create(opts CreateOptions) *serpent.Command { | ||
var ( | ||
templateName string | ||
templateVersion string | ||
@@ -305,6 +310,13 @@ func (r *RootCmd) create() *serpent.Command { | ||
_, _ = fmt.Fprintf(inv.Stdout, "%s", cliui.Bold("No preset applied.")) | ||
} | ||
if opts.BeforeCreate != nil { | ||
err = opts.BeforeCreate(inv.Context(), client, template, templateVersionID) | ||
if err != nil { | ||
return xerrors.Errorf("before create: %w", err) | ||
} | ||
} | ||
richParameters, err := prepWorkspaceBuild(inv, client, prepWorkspaceBuildArgs{ | ||
Action: WorkspaceCreate, | ||
TemplateVersionID: templateVersionID, | ||
@@ -366,6 +378,14 @@ func (r *RootCmd) create() *serpent.Command { | ||
cliui.Keyword(workspace.Name), | ||
cliui.Timestamp(time.Now()), | ||
) | ||
if opts.AfterCreate != nil { | ||
err = opts.AfterCreate(inv.Context(), inv, client, workspace) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
}, | ||
} | ||
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.