Skip to content

Commit e9b236a

Browse files
committed
use new org context
1 parent b4c2853 commit e9b236a

File tree

7 files changed

+24
-8
lines changed

7 files changed

+24
-8
lines changed

cli/templatedelete.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
)
1616

1717
func (r *RootCmd) templateDelete() *serpent.Command {
18+
orgContext := NewOrganizationContext()
1819
client := new(codersdk.Client)
1920
cmd := &serpent.Command{
2021
Use: "delete [name...]",
@@ -32,7 +33,7 @@ func (r *RootCmd) templateDelete() *serpent.Command {
3233
templates = []codersdk.Template{}
3334
)
3435

35-
organization, err := CurrentOrganization(r, inv, client)
36+
organization, err := orgContext.Selected(inv, client)
3637
if err != nil {
3738
return err
3839
}
@@ -81,6 +82,7 @@ func (r *RootCmd) templateDelete() *serpent.Command {
8182
return nil
8283
},
8384
}
85+
orgContext.AttachOptions(cmd)
8486

8587
return cmd
8688
}

cli/templateedit.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func (r *RootCmd) templateEdit() *serpent.Command {
3636
requireActiveVersion bool
3737
deprecationMessage string
3838
disableEveryone bool
39+
orgContext = NewOrganizationContext()
3940
)
4041
client := new(codersdk.Client)
4142

@@ -77,7 +78,7 @@ func (r *RootCmd) templateEdit() *serpent.Command {
7778
}
7879
}
7980

80-
organization, err := CurrentOrganization(r, inv, client)
81+
organization, err := orgContext.Selected(inv, client)
8182
if err != nil {
8283
return xerrors.Errorf("get current organization: %w", err)
8384
}
@@ -324,6 +325,7 @@ func (r *RootCmd) templateEdit() *serpent.Command {
324325
},
325326
cliui.SkipPromptOption(),
326327
}
328+
orgContext.AttachOptions(cmd)
327329

328330
return cmd
329331
}

cli/templatelist.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
)
1212

1313
func (r *RootCmd) templateList() *serpent.Command {
14+
orgContext := NewOrganizationContext()
1415
formatter := cliui.NewOutputFormatter(
1516
cliui.TableFormat([]templateTableRow{}, []string{"name", "last updated", "used by"}),
1617
cliui.JSONFormat(),
@@ -25,7 +26,7 @@ func (r *RootCmd) templateList() *serpent.Command {
2526
r.InitClient(client),
2627
),
2728
Handler: func(inv *serpent.Invocation) error {
28-
organization, err := CurrentOrganization(r, inv, client)
29+
organization, err := orgContext.Selected(inv, client)
2930
if err != nil {
3031
return err
3132
}
@@ -52,5 +53,6 @@ func (r *RootCmd) templateList() *serpent.Command {
5253
}
5354

5455
formatter.AttachOptions(&cmd.Options)
56+
orgContext.AttachOptions(cmd)
5557
return cmd
5658
}

cli/templatepull.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func (r *RootCmd) templatePull() *serpent.Command {
2020
tarMode bool
2121
zipMode bool
2222
versionName string
23+
orgContext = NewOrganizationContext()
2324
)
2425

2526
client := new(codersdk.Client)
@@ -45,7 +46,7 @@ func (r *RootCmd) templatePull() *serpent.Command {
4546
return xerrors.Errorf("either tar or zip can be selected")
4647
}
4748

48-
organization, err := CurrentOrganization(r, inv, client)
49+
organization, err := orgContext.Selected(inv, client)
4950
if err != nil {
5051
return xerrors.Errorf("get current organization: %w", err)
5152
}
@@ -187,6 +188,7 @@ func (r *RootCmd) templatePull() *serpent.Command {
187188
},
188189
cliui.SkipPromptOption(),
189190
}
191+
orgContext.AttachOptions(cmd)
190192

191193
return cmd
192194
}

cli/templatepush.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func (r *RootCmd) templatePush() *serpent.Command {
3434
provisionerTags []string
3535
uploadFlags templateUploadFlags
3636
activate bool
37+
orgContext = NewOrganizationContext()
3738
)
3839
client := new(codersdk.Client)
3940
cmd := &serpent.Command{
@@ -46,7 +47,7 @@ func (r *RootCmd) templatePush() *serpent.Command {
4647
Handler: func(inv *serpent.Invocation) error {
4748
uploadFlags.setWorkdir(workdir)
4849

49-
organization, err := CurrentOrganization(r, inv, client)
50+
organization, err := orgContext.Selected(inv, client)
5051
if err != nil {
5152
return err
5253
}
@@ -226,6 +227,7 @@ func (r *RootCmd) templatePush() *serpent.Command {
226227
cliui.SkipPromptOption(),
227228
}
228229
cmd.Options = append(cmd.Options, uploadFlags.options()...)
230+
orgContext.AttachOptions(cmd)
229231
return cmd
230232
}
231233

cli/templateversionarchive.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func (r *RootCmd) setArchiveTemplateVersion(archive bool) *serpent.Command {
3131
pastVerb = "unarchived"
3232
}
3333

34+
orgContext := NewOrganizationContext()
3435
client := new(codersdk.Client)
3536
cmd := &serpent.Command{
3637
Use: presentVerb + " <template-name> [template-version-names...] ",
@@ -47,7 +48,7 @@ func (r *RootCmd) setArchiveTemplateVersion(archive bool) *serpent.Command {
4748
versions []codersdk.TemplateVersion
4849
)
4950

50-
organization, err := CurrentOrganization(r, inv, client)
51+
organization, err := orgContext.Selected(inv, client)
5152
if err != nil {
5253
return err
5354
}
@@ -92,13 +93,15 @@ func (r *RootCmd) setArchiveTemplateVersion(archive bool) *serpent.Command {
9293
return nil
9394
},
9495
}
96+
orgContext.AttachOptions(cmd)
9597

9698
return cmd
9799
}
98100

99101
func (r *RootCmd) archiveTemplateVersions() *serpent.Command {
100102
var all serpent.Bool
101103
client := new(codersdk.Client)
104+
orgContext := NewOrganizationContext()
102105
cmd := &serpent.Command{
103106
Use: "archive [template-name...] ",
104107
Short: "Archive unused or failed template versions from a given template(s)",
@@ -121,7 +124,7 @@ func (r *RootCmd) archiveTemplateVersions() *serpent.Command {
121124
templates = []codersdk.Template{}
122125
)
123126

124-
organization, err := CurrentOrganization(r, inv, client)
127+
organization, err := orgContext.Selected(inv, client)
125128
if err != nil {
126129
return err
127130
}
@@ -179,6 +182,7 @@ func (r *RootCmd) archiveTemplateVersions() *serpent.Command {
179182
return nil
180183
},
181184
}
185+
orgContext.AttachOptions(cmd)
182186

183187
return cmd
184188
}

cli/templateversions.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func (r *RootCmd) templateVersionsList() *serpent.Command {
5151
cliui.JSONFormat(),
5252
)
5353
client := new(codersdk.Client)
54+
orgContext := NewOrganizationContext()
5455

5556
var includeArchived serpent.Bool
5657

@@ -93,7 +94,7 @@ func (r *RootCmd) templateVersionsList() *serpent.Command {
9394
},
9495
},
9596
Handler: func(inv *serpent.Invocation) error {
96-
organization, err := CurrentOrganization(r, inv, client)
97+
organization, err := orgContext.Selected(inv, client)
9798
if err != nil {
9899
return xerrors.Errorf("get current organization: %w", err)
99100
}
@@ -122,6 +123,7 @@ func (r *RootCmd) templateVersionsList() *serpent.Command {
122123
},
123124
}
124125

126+
orgContext.AttachOptions(cmd)
125127
formatter.AttachOptions(&cmd.Options)
126128
return cmd
127129
}

0 commit comments

Comments
 (0)