Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit184f062

Browse files
authored
coder licenses add CLI command (#3632)
* coder licenses add CLI commandSigned-off-by: Spike Curtis <spike@coder.com>* Fix up lintSigned-off-by: Spike Curtis <spike@coder.com>* Fix t.parallel callSigned-off-by: Spike Curtis <spike@coder.com>* Code review improvementsSigned-off-by: Spike Curtis <spike@coder.com>* LintSigned-off-by: Spike Curtis <spike@coder.com>Signed-off-by: Spike Curtis <spike@coder.com>
1 parent6dacf70 commit184f062

32 files changed

+357
-38
lines changed

‎cli/clitest/clitest.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ import (
2121
// New creates a CLI instance with a configuration pointed to a
2222
// temporary testing directory.
2323
funcNew(t*testing.T,args...string) (*cobra.Command, config.Root) {
24-
cmd:=cli.Root(cli.AGPL())
24+
returnNewWithSubcommands(t,cli.AGPL(),args...)
25+
}
26+
27+
funcNewWithSubcommands(
28+
t*testing.T,subcommands []*cobra.Command,args...string,
29+
) (*cobra.Command, config.Root) {
30+
cmd:=cli.Root(subcommands)
2531
dir:=t.TempDir()
2632
root:=config.Root(dir)
2733
cmd.SetArgs(append([]string{"--global-config",dir},args...))

‎cli/configssh.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func configSSH() *cobra.Command {
158158
),
159159
Args:cobra.ExactArgs(0),
160160
RunE:func(cmd*cobra.Command,_ []string)error {
161-
client,err:=createClient(cmd)
161+
client,err:=CreateClient(cmd)
162162
iferr!=nil {
163163
returnerr
164164
}

‎cli/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func create() *cobra.Command {
2727
Use:"create [name]",
2828
Short:"Create a workspace from a template",
2929
RunE:func(cmd*cobra.Command,args []string)error {
30-
client,err:=createClient(cmd)
30+
client,err:=CreateClient(cmd)
3131
iferr!=nil {
3232
returnerr
3333
}

‎cli/delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func deleteWorkspace() *cobra.Command {
2828
returnerr
2929
}
3030

31-
client,err:=createClient(cmd)
31+
client,err:=CreateClient(cmd)
3232
iferr!=nil {
3333
returnerr
3434
}

‎cli/features.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func featuresList() *cobra.Command {
3636
Use:"list",
3737
Aliases: []string{"ls"},
3838
RunE:func(cmd*cobra.Command,args []string)error {
39-
client,err:=createClient(cmd)
39+
client,err:=CreateClient(cmd)
4040
iferr!=nil {
4141
returnerr
4242
}

‎cli/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func list() *cobra.Command {
6565
Aliases: []string{"ls"},
6666
Args:cobra.ExactArgs(0),
6767
RunE:func(cmd*cobra.Command,args []string)error {
68-
client,err:=createClient(cmd)
68+
client,err:=CreateClient(cmd)
6969
iferr!=nil {
7070
returnerr
7171
}

‎cli/logout.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func logout() *cobra.Command {
1616
Use:"logout",
1717
Short:"Remove the local authenticated session",
1818
RunE:func(cmd*cobra.Command,args []string)error {
19-
client,err:=createClient(cmd)
19+
client,err:=CreateClient(cmd)
2020
iferr!=nil {
2121
returnerr
2222
}

‎cli/parameterslist.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func parameterList() *cobra.Command {
2222
RunE:func(cmd*cobra.Command,args []string)error {
2323
scope,name:=args[0],args[1]
2424

25-
client,err:=createClient(cmd)
25+
client,err:=CreateClient(cmd)
2626
iferr!=nil {
2727
returnerr
2828
}

‎cli/portforward.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func portForward() *cobra.Command {
7070
returnxerrors.New("no port-forwards requested")
7171
}
7272

73-
client,err:=createClient(cmd)
73+
client,err:=CreateClient(cmd)
7474
iferr!=nil {
7575
returnerr
7676
}

‎cli/publickey.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func publickey() *cobra.Command {
2020
Aliases: []string{"pubkey"},
2121
Short:"Output your public key for Git operations",
2222
RunE:func(cmd*cobra.Command,args []string)error {
23-
client,err:=createClient(cmd)
23+
client,err:=CreateClient(cmd)
2424
iferr!=nil {
2525
returnxerrors.Errorf("create codersdk client: %w",err)
2626
}

‎cli/root.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func Root(subcommands []*cobra.Command) *cobra.Command {
114114
returnnil
115115
}
116116

117-
client,err:=createClient(cmd)
117+
client,err:=CreateClient(cmd)
118118
// If the client is unauthenticated we can ignore the check.
119119
// The child commands should handle an unauthenticated client.
120120
ifxerrors.Is(err,errUnauthenticated) {
@@ -190,9 +190,9 @@ func isTest() bool {
190190
returnflag.Lookup("test.v")!=nil
191191
}
192192

193-
//createClient returns a new client from the command context.
193+
//CreateClient returns a new client from the command context.
194194
// It reads from global configuration files if flags are not set.
195-
funccreateClient(cmd*cobra.Command) (*codersdk.Client,error) {
195+
funcCreateClient(cmd*cobra.Command) (*codersdk.Client,error) {
196196
root:=createConfig(cmd)
197197
rawURL,err:=cmd.Flags().GetString(varURL)
198198
iferr!=nil||rawURL=="" {
@@ -226,7 +226,7 @@ func createClient(cmd *cobra.Command) (*codersdk.Client, error) {
226226
}
227227

228228
// createAgentClient returns a new client from the command context.
229-
// It works just likecreateClient, but uses the agent token and URL instead.
229+
// It works just likeCreateClient, but uses the agent token and URL instead.
230230
funccreateAgentClient(cmd*cobra.Command) (*codersdk.Client,error) {
231231
rawURL,err:=cmd.Flags().GetString(varAgentURL)
232232
iferr!=nil {

‎cli/schedule.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func scheduleShow() *cobra.Command {
7777
Long:scheduleShowDescriptionLong,
7878
Args:cobra.ExactArgs(1),
7979
RunE:func(cmd*cobra.Command,args []string)error {
80-
client,err:=createClient(cmd)
80+
client,err:=CreateClient(cmd)
8181
iferr!=nil {
8282
returnerr
8383
}
@@ -106,7 +106,7 @@ func scheduleStart() *cobra.Command {
106106
Long:scheduleStartDescriptionLong,
107107
Args:cobra.RangeArgs(2,4),
108108
RunE:func(cmd*cobra.Command,args []string)error {
109-
client,err:=createClient(cmd)
109+
client,err:=CreateClient(cmd)
110110
iferr!=nil {
111111
returnerr
112112
}
@@ -156,7 +156,7 @@ func scheduleStop() *cobra.Command {
156156
Short:"Edit workspace stop schedule",
157157
Long:scheduleStopDescriptionLong,
158158
RunE:func(cmd*cobra.Command,args []string)error {
159-
client,err:=createClient(cmd)
159+
client,err:=CreateClient(cmd)
160160
iferr!=nil {
161161
returnerr
162162
}
@@ -207,7 +207,7 @@ func scheduleOverride() *cobra.Command {
207207
returnerr
208208
}
209209

210-
client,err:=createClient(cmd)
210+
client,err:=CreateClient(cmd)
211211
iferr!=nil {
212212
returnxerrors.Errorf("create client: %w",err)
213213
}

‎cli/show.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func show() *cobra.Command {
1414
Short:"Show details of a workspace's resources and agents",
1515
Args:cobra.ExactArgs(1),
1616
RunE:func(cmd*cobra.Command,args []string)error {
17-
client,err:=createClient(cmd)
17+
client,err:=CreateClient(cmd)
1818
iferr!=nil {
1919
returnerr
2020
}

‎cli/ssh.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func ssh() *cobra.Command {
5454
ctx,cancel:=context.WithCancel(cmd.Context())
5555
defercancel()
5656

57-
client,err:=createClient(cmd)
57+
client,err:=CreateClient(cmd)
5858
iferr!=nil {
5959
returnerr
6060
}

‎cli/start.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func start() *cobra.Command {
1717
Short:"Build a workspace with the start state",
1818
Args:cobra.ExactArgs(1),
1919
RunE:func(cmd*cobra.Command,args []string)error {
20-
client,err:=createClient(cmd)
20+
client,err:=CreateClient(cmd)
2121
iferr!=nil {
2222
returnerr
2323
}

‎cli/state.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func statePull() *cobra.Command {
2727
Use:"pull <workspace> [file]",
2828
Args:cobra.MinimumNArgs(1),
2929
RunE:func(cmd*cobra.Command,args []string)error {
30-
client,err:=createClient(cmd)
30+
client,err:=CreateClient(cmd)
3131
iferr!=nil {
3232
returnerr
3333
}
@@ -68,7 +68,7 @@ func statePush() *cobra.Command {
6868
Use:"push <workspace> <file>",
6969
Args:cobra.ExactArgs(2),
7070
RunE:func(cmd*cobra.Command,args []string)error {
71-
client,err:=createClient(cmd)
71+
client,err:=CreateClient(cmd)
7272
iferr!=nil {
7373
returnerr
7474
}

‎cli/stop.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func stop() *cobra.Command {
2525
returnerr
2626
}
2727

28-
client,err:=createClient(cmd)
28+
client,err:=CreateClient(cmd)
2929
iferr!=nil {
3030
returnerr
3131
}

‎cli/templatecreate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func templateCreate() *cobra.Command {
3232
Short:"Create a template from the current directory or as specified by flag",
3333
Args:cobra.MaximumNArgs(1),
3434
RunE:func(cmd*cobra.Command,args []string)error {
35-
client,err:=createClient(cmd)
35+
client,err:=CreateClient(cmd)
3636
iferr!=nil {
3737
returnerr
3838
}

‎cli/templatedelete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func templateDelete() *cobra.Command {
2323
templates= []codersdk.Template{}
2424
)
2525

26-
client,err:=createClient(cmd)
26+
client,err:=CreateClient(cmd)
2727
iferr!=nil {
2828
returnerr
2929
}

‎cli/templateedit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func templateEdit() *cobra.Command {
2525
Args:cobra.ExactArgs(1),
2626
Short:"Edit the metadata of a template by name.",
2727
RunE:func(cmd*cobra.Command,args []string)error {
28-
client,err:=createClient(cmd)
28+
client,err:=CreateClient(cmd)
2929
iferr!=nil {
3030
returnxerrors.Errorf("create client: %w",err)
3131
}

‎cli/templatelist.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func templateList() *cobra.Command {
1616
Short:"List all the templates available for the organization",
1717
Aliases: []string{"ls"},
1818
RunE:func(cmd*cobra.Command,args []string)error {
19-
client,err:=createClient(cmd)
19+
client,err:=CreateClient(cmd)
2020
iferr!=nil {
2121
returnerr
2222
}

‎cli/templatepull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func templatePull() *cobra.Command {
2929
dest=args[1]
3030
}
3131

32-
client,err:=createClient(cmd)
32+
client,err:=CreateClient(cmd)
3333
iferr!=nil {
3434
returnxerrors.Errorf("create client: %w",err)
3535
}

‎cli/templatepush.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func templatePush() *cobra.Command {
2929
Args:cobra.MaximumNArgs(1),
3030
Short:"Push a new template version from the current directory or as specified by flag",
3131
RunE:func(cmd*cobra.Command,args []string)error {
32-
client,err:=createClient(cmd)
32+
client,err:=CreateClient(cmd)
3333
iferr!=nil {
3434
returnerr
3535
}

‎cli/templateversions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func templateVersionsList() *cobra.Command {
3838
Args:cobra.ExactArgs(1),
3939
Short:"List all the versions of the specified template",
4040
RunE:func(cmd*cobra.Command,args []string)error {
41-
client,err:=createClient(cmd)
41+
client,err:=CreateClient(cmd)
4242
iferr!=nil {
4343
returnxerrors.Errorf("create client: %w",err)
4444
}

‎cli/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func update() *cobra.Command {
2222
Args:cobra.ExactArgs(1),
2323
Short:"Update a workspace to the latest template version",
2424
RunE:func(cmd*cobra.Command,args []string)error {
25-
client,err:=createClient(cmd)
25+
client,err:=CreateClient(cmd)
2626
iferr!=nil {
2727
returnerr
2828
}

‎cli/usercreate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func userCreate() *cobra.Command {
2121
cmd:=&cobra.Command{
2222
Use:"create",
2323
RunE:func(cmd*cobra.Command,args []string)error {
24-
client,err:=createClient(cmd)
24+
client,err:=CreateClient(cmd)
2525
iferr!=nil {
2626
returnerr
2727
}

‎cli/userlist.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func userList() *cobra.Command {
2626
Use:"list",
2727
Aliases: []string{"ls"},
2828
RunE:func(cmd*cobra.Command,args []string)error {
29-
client,err:=createClient(cmd)
29+
client,err:=CreateClient(cmd)
3030
iferr!=nil {
3131
returnerr
3232
}
@@ -76,7 +76,7 @@ func userSingle() *cobra.Command {
7676
),
7777
Args:cobra.ExactArgs(1),
7878
RunE:func(cmd*cobra.Command,args []string)error {
79-
client,err:=createClient(cmd)
79+
client,err:=CreateClient(cmd)
8080
iferr!=nil {
8181
returnerr
8282
}

‎cli/userstatus.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func createUserStatusCommand(sdkStatus codersdk.UserStatus) *cobra.Command {
4343
},
4444
),
4545
RunE:func(cmd*cobra.Command,args []string)error {
46-
client,err:=createClient(cmd)
46+
client,err:=CreateClient(cmd)
4747
iferr!=nil {
4848
returnerr
4949
}

‎cli/wireguardtunnel.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func wireguardPortForward() *cobra.Command {
6767
returnxerrors.New("no port-forwards requested")
6868
}
6969

70-
client,err:=createClient(cmd)
70+
client,err:=CreateClient(cmd)
7171
iferr!=nil {
7272
returnerr
7373
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp