feat(cli): add ability to create tasks for other users (#20012)

This commit is contained in:
Cian Johnston
2025-09-29 15:42:03 +01:00
committed by GitHub
parent f2f4ed12e9
commit abdea7213a
2 changed files with 30 additions and 14 deletions
+10 -1
View File
@@ -17,6 +17,7 @@ func (r *RootCmd) taskCreate() *serpent.Command {
var (
orgContext = NewOrganizationContext()
ownerArg string
taskName string
templateName string
templateVersionName string
@@ -40,6 +41,14 @@ func (r *RootCmd) taskCreate() *serpent.Command {
Required: false,
Default: "",
},
{
Name: "owner",
Flag: "owner",
Description: "Specify the owner of the task. Defaults to the current user.",
Value: serpent.StringOf(&ownerArg),
Required: false,
Default: codersdk.Me,
},
{
Name: "template",
Flag: "template",
@@ -177,7 +186,7 @@ func (r *RootCmd) taskCreate() *serpent.Command {
templateVersionPresetID = preset.ID
}
task, err := expClient.CreateTask(ctx, codersdk.Me, codersdk.CreateTaskRequest{
task, err := expClient.CreateTask(ctx, ownerArg, codersdk.CreateTaskRequest{
Name: taskName,
TemplateVersionID: templateVersionID,
TemplateVersionPresetID: templateVersionPresetID,