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

Commit6fb72b5

Browse files
committed
621 problems remaining...
1 parent274c84d commit6fb72b5

File tree

58 files changed

+191
-237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+191
-237
lines changed

‎cli/agent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
"github.com/coder/coder/codersdk/agentsdk"
2929
)
3030

31-
funcworkspaceAgent()*clibase.Cmd {
31+
func(r*RootCmd)workspaceAgent()*clibase.Cmd {
3232
var (
3333
authstring
3434
logDirstring

‎cli/clibase/cmd.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,5 +245,20 @@ func RequireNArgs(want int) MiddlewareFunc {
245245
}
246246
}
247247

248+
funcRequireRangeArgs(start,endint)MiddlewareFunc {
249+
returnfunc(nextHandlerFunc)HandlerFunc {
250+
returnfunc(i*Invokation)error {
251+
iflen(i.Args)<start||len(i.Args)>end {
252+
returnfmt.Errorf(
253+
"wanted between %v and %v args but got %v",
254+
start,end,
255+
len(i.Args),
256+
)
257+
}
258+
returnnext(i)
259+
}
260+
}
261+
}
262+
248263
// HandlerFunc handles an Invokation of a command.
249264
typeHandlerFuncfunc(i*Invokation)error

‎cli/configssh.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,20 @@ func sshPrepareWorkspaceConfigs(ctx context.Context, client *codersdk.Client) (r
132132
}
133133
}
134134

135-
funcconfigSSH()*clibase.Cmd {
135+
func(r*RootCmd)configSSH()*clibase.Cmd {
136136
var (
137137
sshConfigFilestring
138138
sshConfigOptssshConfigOptions
139139
usePreviousOptsbool
140140
dryRunbool
141141
skipProxyCommandbool
142142
)
143+
varclient*codersdk.Client
143144
cmd:=&clibase.Cmd{
144145
Annotations:workspaceCommand,
145146
Use:"config-ssh",
146147
Short:"Add an SSH Host entry for your workspaces\"ssh coder.workspace\"",
147-
Example:formatExamples(
148+
Long:formatExamples(
148149
example{
149150
Description:"You can use -o (or --ssh-option) so set SSH options to be used for all your workspaces",
150151
Command:"coder config-ssh -o ForwardAgent=yes",
@@ -154,13 +155,11 @@ func configSSH() *clibase.Cmd {
154155
Command:"coder config-ssh --dry-run",
155156
},
156157
),
157-
Middleware:clibase.RequireNArgs(0),
158+
Middleware:clibase.Chain(
159+
clibase.RequireNArgs(0),
160+
r.useClient(client),
161+
),
158162
Handler:func(inv*clibase.Invokation)error {
159-
client,err:=useClient(cmd)
160-
iferr!=nil {
161-
returnerr
162-
}
163-
164163
recvWorkspaceConfigs:=sshPrepareWorkspaceConfigs(inv.Context(),client)
165164

166165
out:=inv.Stdout

‎cli/create.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"github.com/coder/coder/codersdk"
1717
)
1818

19-
funccreate()*clibase.Cmd {
19+
func(r*RootCmd)create()*clibase.Cmd {
2020
var (
2121
parameterFilestring
2222
richParameterFilestring
@@ -25,17 +25,14 @@ func create() *clibase.Cmd {
2525
stopAfter time.Duration
2626
workspaceNamestring
2727
)
28+
varclient*codersdk.Client
2829
cmd:=&clibase.Cmd{
2930
Annotations:workspaceCommand,
3031
Use:"create [name]",
3132
Short:"Create a workspace",
33+
Middleware:clibase.Chain(r.useClient(client)),
3234
Handler:func(inv*clibase.Invokation)error {
33-
client,err:=useClient(cmd)
34-
iferr!=nil {
35-
returnerr
36-
}
37-
38-
organization,err:=CurrentOrganization(cmd,client)
35+
organization,err:=CurrentOrganization(inv,client)
3936
iferr!=nil {
4037
returnerr
4138
}
@@ -193,7 +190,7 @@ type buildParameters struct {
193190

194191
// prepWorkspaceBuild will ensure a workspace build will succeed on the latest template version.
195192
// Any missing params will be prompted to the user. It supports legacy and rich parameters.
196-
funcprepWorkspaceBuild(cmd*clibase.Cmd,client*codersdk.Client,inv.ArgsprepWorkspaceBuildArgs) (*buildParameters,error) {
193+
funcprepWorkspaceBuild(cmd*clibase.Cmd,client*codersdk.Client,argsprepWorkspaceBuildArgs) (*buildParameters,error) {
197194
ctx:=inv.Context()
198195

199196
varuseRichParametersbool

‎cli/delete.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
// nolint
13-
funcdeleteWorkspace()*clibase.Cmd {
13+
func(r*RootCmd)deleteWorkspace()*clibase.Cmd {
1414
varorphanbool
1515
cmd:=&clibase.Cmd{
1616
Annotations:workspaceCommand,
@@ -32,7 +32,7 @@ func deleteWorkspace() *clibase.Cmd {
3232
iferr!=nil {
3333
returnerr
3434
}
35-
workspace,err:=namedWorkspace(cmd,client,inv.Args[0])
35+
workspace,err:=namedWorkspace(inv.Context(),client,inv.Args[0])
3636
iferr!=nil {
3737
returnerr
3838
}

‎cli/dotfiles.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ import (
1717
"github.com/coder/coder/cli/cliui"
1818
)
1919

20-
funcdotfiles()*clibase.Cmd {
20+
func(r*RootCmd)dotfiles()*clibase.Cmd {
2121
varsymlinkDirstring
2222
cmd:=&clibase.Cmd{
2323
Use:"dotfiles [git_repo_url]",
2424
Middleware:clibase.RequireNArgs(1),
2525
Short:"Checkout and install a dotfiles repository from a Git URL",
26-
Example:formatExamples(
26+
Long:formatExamples(
2727
example{
2828
Description:"Check out and install a dotfiles repository without prompts",
2929
Command:"coder dotfiles --yes git@github.com:example/dotfiles.git",

‎cli/gitaskpass.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818

1919
// gitAskpass is used by the Coder agent to automatically authenticate
2020
// with Git providers based on a hostname.
21-
funcgitAskpass()*clibase.Cmd {
21+
func(r*RootCmd)gitAskpass()*clibase.Cmd {
2222
return&clibase.Cmd{
2323
Use:"gitaskpass",
2424
Hidden:true,

‎cli/gitssh.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"github.com/coder/coder/cli/cliui"
1919
)
2020

21-
funcgitssh()*clibase.Cmd {
21+
func(r*RootCmd)gitssh()*clibase.Cmd {
2222
cmd:=&clibase.Cmd{
2323
Use:"gitssh",
2424
Hidden:true,
@@ -166,7 +166,7 @@ func parseIdentityFilesForHost(ctx context.Context, args, env []string) (identit
166166
// OpenSSH on Windows is weird, it supports using (and does
167167
// use) mixed \ and / in paths.
168168
//
169-
//Example: C:\Users\ZeroCool/.ssh/known_hosts
169+
//Long: C:\Users\ZeroCool/.ssh/known_hosts
170170
//
171171
// To check the file existence in Go, though, we want to use
172172
// proper Windows paths.

‎cli/list.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func workspaceListRowFromWorkspace(now time.Time, usersByID map[uuid.UUID]coders
6464
}
6565
}
6666

67-
funclist()*clibase.Cmd {
67+
func(r*RootCmd)list()*clibase.Cmd {
6868
var (
6969
allbool
7070
defaultQuery="owner:me"
@@ -81,12 +81,8 @@ func list() *clibase.Cmd {
8181
Short:"List workspaces",
8282
Aliases: []string{"ls"},
8383
Middleware:clibase.RequireNArgs(0),
84+
Middleware:clibase.Chain(r.useClient(client)),
8485
Handler:func(inv*clibase.Invokation)error {
85-
client,err:=useClient(cmd)
86-
iferr!=nil {
87-
returnerr
88-
}
89-
9086
filter:= codersdk.WorkspaceFilter{
9187
FilterQuery:searchQuery,
9288
}

‎cli/login.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func init() {
3939
browser.Stdout=io.Discard
4040
}
4141

42-
funclogin()*clibase.Cmd {
42+
func(r*RootCmd)login()*clibase.Cmd {
4343
constfirstUserTrialEnv="CODER_FIRST_USER_TRIAL"
4444

4545
var (

‎cli/logout.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,12 @@ import (
1111
"github.com/coder/coder/cli/cliui"
1212
)
1313

14-
funclogout()*clibase.Cmd {
14+
func(r*RootCmd)logout()*clibase.Cmd {
1515
cmd:=&clibase.Cmd{
16-
Use:"logout",
17-
Short:"Unauthenticate your local session",
16+
Use:"logout",
17+
Short:"Unauthenticate your local session",
18+
Middleware:clibase.Chain(r.useClient(client)),
1819
Handler:func(inv*clibase.Invokation)error {
19-
client,err:=useClient(cmd)
20-
iferr!=nil {
21-
returnerr
22-
}
23-
2420
varerrors []error
2521

2622
config:=createConfig(cmd)

‎cli/parameters.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import (
55
"gvisor.dev/gvisor/runsc/cmd"
66
)
77

8-
funcparameters()*clibase.Cmd {
8+
func(r*RootCmd)parameters()*clibase.Cmd {
99
cmd:=&clibase.Cmd{
1010
Short:"List parameters for a given scope",
11-
Example:formatExamples(
11+
Long:formatExamples(
1212
example{
1313
Command:"coder parameters list workspace my-workspace",
1414
},

‎cli/parameterslist.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/coder/coder/codersdk"
1212
)
1313

14-
funcparameterList()*clibase.Cmd {
14+
func(r*RootCmd)parameterList()*clibase.Cmd {
1515
formatter:=cliui.NewOutputFormatter(
1616
cliui.TableFormat([]codersdk.Parameter{}, []string{"name","scope","destination scheme"}),
1717
cliui.JSONFormat(),
@@ -29,15 +29,15 @@ func parameterList() *clibase.Cmd {
2929
returnerr
3030
}
3131

32-
organization,err:=CurrentOrganization(cmd,client)
32+
organization,err:=CurrentOrganization(inv,client)
3333
iferr!=nil {
3434
returnxerrors.Errorf("get current organization: %w",err)
3535
}
3636

3737
varscopeID uuid.UUID
3838
switchcodersdk.ParameterScope(scope) {
3939
casecodersdk.ParameterWorkspace:
40-
workspace,err:=namedWorkspace(cmd,client,name)
40+
workspace,err:=namedWorkspace(inv.Context(),client,name)
4141
iferr!=nil {
4242
returnerr
4343
}

‎cli/ping.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"github.com/coder/coder/codersdk"
1616
)
1717

18-
funcping()*clibase.Cmd {
18+
func(r*RootCmd)ping()*clibase.Cmd {
1919
var (
2020
pingNumint
2121
pingTimeout time.Duration

‎cli/portforward.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"github.com/coder/coder/codersdk"
2222
)
2323

24-
funcportForward()*clibase.Cmd {
24+
func(r*RootCmd)portForward()*clibase.Cmd {
2525
var (
2626
tcpForwards []string// <port>:<port>
2727
udpForwards []string// <port>:<port>
@@ -30,8 +30,8 @@ func portForward() *clibase.Cmd {
3030
Use:"port-forward <workspace>",
3131
Short:"Forward ports from machine to a workspace",
3232
Aliases: []string{"tunnel"},
33-
Middleware:clibase.RequireNArgs(1),,
34-
Example:formatExamples(
33+
Middleware:clibase.RequireNArgs(1),
34+
Long:formatExamples(
3535
example{
3636
Description:"Port forward a single TCP port from 1234 in the workspace to port 5678 on your local machine",
3737
Command:"coder port-forward <workspace> --tcp 5678:1234",

‎cli/publickey.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/coder/coder/codersdk"
1111
)
1212

13-
funcpublickey()*clibase.Cmd {
13+
func(r*RootCmd)publickey()*clibase.Cmd {
1414
varresetbool
1515

1616
cmd:=&clibase.Cmd{

‎cli/rename.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,15 @@ import (
1010
"github.com/coder/coder/codersdk"
1111
)
1212

13-
funcrename()*clibase.Cmd {
13+
func(r*RootCmd)rename()*clibase.Cmd {
1414
cmd:=&clibase.Cmd{
1515
Annotations:workspaceCommand,
1616
Use:"rename <workspace> <new name>",
1717
Short:"Rename a workspace",
1818
Middleware:clibase.RequireNArgs(2),
19+
Middleware:clibase.Chain(r.useClient(client)),
1920
Handler:func(inv*clibase.Invokation)error {
20-
client,err:=useClient(cmd)
21-
iferr!=nil {
22-
returnerr
23-
}
24-
workspace,err:=namedWorkspace(cmd,client,inv.Args[0])
21+
workspace,err:=namedWorkspace(inv.Context(),client,inv.Args[0])
2522
iferr!=nil {
2623
returnxerrors.Errorf("get workspace: %w",err)
2724
}

‎cli/resetpassword.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/coder/coder/coderd/userpassword"
1515
)
1616

17-
funcresetPassword()*clibase.Cmd {
17+
func(r*RootCmd)resetPassword()*clibase.Cmd {
1818
varpostgresURLstring
1919

2020
root:=&clibase.Cmd{

‎cli/restart.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/coder/coder/codersdk"
1010
)
1111

12-
funcrestart()*clibase.Cmd {
12+
func(r*RootCmd)restart()*clibase.Cmd {
1313
cmd:=&clibase.Cmd{
1414
Annotations:workspaceCommand,
1515
Use:"restart <workspace>",
@@ -31,7 +31,7 @@ func restart() *clibase.Cmd {
3131
iferr!=nil {
3232
returnerr
3333
}
34-
workspace,err:=namedWorkspace(cmd,client,inv.Args[0])
34+
workspace,err:=namedWorkspace(inv.Context(),client,inv.Args[0])
3535
iferr!=nil {
3636
returnerr
3737
}

‎cli/root.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ func LoggerFromContext(ctx context.Context) (slog.Logger, bool) {
233233
}
234234

235235
// versionCmd prints the coder version
236-
funcversionCmd()*clibase.Cmd {
236+
func(r*RootCmd)versionCmd()*clibase.Cmd {
237237
return&clibase.Cmd{
238238
Use:"version",
239239
Short:"Show coder version",
@@ -266,6 +266,7 @@ func isTest() bool {
266266
returnflag.Lookup("test.v")!=nil
267267
}
268268

269+
// RootCmd contains parameters and helpers useful to all commands.
269270
typeRootCmdstruct {
270271
clientURL clibase.URL
271272
token clibase.String
@@ -402,7 +403,7 @@ func createAgentClient(cmd *clibase.Cmd) (*agentsdk.Client, error) {
402403
}
403404

404405
// CurrentOrganization returns the currently active organization for the authenticated user.
405-
funcCurrentOrganization(cmd*clibase.Cmd,client*codersdk.Client) (codersdk.Organization,error) {
406+
funcCurrentOrganization(inv*clibase.Invokation,client*codersdk.Client) (codersdk.Organization,error) {
406407
orgs,err:=client.OrganizationsByUser(inv.Context(),codersdk.Me)
407408
iferr!=nil {
408409
return codersdk.Organization{},nil

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp