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

Commit68c9194

Browse files
committed
make URL not a pointer in AgentAuth
1 parent813a69e commit68c9194

File tree

5 files changed

+18
-28
lines changed

5 files changed

+18
-28
lines changed

‎cli/agent.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func workspaceAgent() *serpent.Command {
5757
devcontainerProjectDiscoverybool
5858
devcontainerDiscoveryAutostartbool
5959
)
60-
agentAuth:=NewAgentAuth()
60+
agentAuth:=&AgentAuth{}
6161
cmd:=&serpent.Command{
6262
Use:"agent",
6363
Short:`Starts the Coder workspace agent.`,
@@ -191,7 +191,7 @@ func workspaceAgent() *serpent.Command {
191191
client.SDK.HTTPClient.Timeout=30*time.Second
192192
// Attach header transport so we process --agent-header and
193193
// --agent-header-command flags
194-
headerTransport,err:=headerTransport(ctx,agentAuth.agentURL,agentHeader,agentHeaderCommand)
194+
headerTransport,err:=headerTransport(ctx,&agentAuth.agentURL,agentHeader,agentHeaderCommand)
195195
iferr!=nil {
196196
returnxerrors.Errorf("configure header transport: %w",err)
197197
}

‎cli/exp_mcp.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func mcpConfigureClaudeCode() *serpent.Command {
131131

132132
deprecatedCoderMCPClaudeAPIKeystring
133133
)
134-
agentAuth:=NewAgentAuth()
134+
agentAuth:=&AgentAuth{}
135135
cmd:=&serpent.Command{
136136
Use:"claude-code <project-directory>",
137137
Short:"Configure the Claude Code server. You will need to run this command for each project you want to use. Specify the project directory as the first argument.",
@@ -405,7 +405,7 @@ func (r *RootCmd) mcpServer() *serpent.Command {
405405
appStatusSlugstring
406406
aiAgentAPIURL url.URL
407407
)
408-
agentAuth:=NewAgentAuth()
408+
agentAuth:=&AgentAuth{}
409409
cmd:=&serpent.Command{
410410
Use:"server",
411411
Handler:func(inv*serpent.Invocation)error {

‎cli/externalauth.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func externalAuth() *serpent.Command {
2727

2828
funcexternalAuthAccessToken()*serpent.Command {
2929
varextrastring
30-
agentAuth:=NewAgentAuth()
30+
agentAuth:=&AgentAuth{}
3131
cmd:=&serpent.Command{
3232
Use:"access-token <provider>",
3333
Short:"Print auth for an external provider",

‎cli/gitssh.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
)
2020

2121
funcgitssh()*serpent.Command {
22-
agentAuth:=NewAgentAuth()
22+
agentAuth:=&AgentAuth{}
2323
cmd:=&serpent.Command{
2424
Use:"gitssh",
2525
Hidden:true,

‎cli/root.go‎

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ var (
6060
const (
6161
varURL="url"
6262
varToken="token"
63-
varAgentToken="agent-token"
64-
varAgentTokenFile="agent-token-file"
65-
varAgentURL="agent-url"
66-
varAgentAuth="auth"
6763
varHeader="header"
6864
varHeaderCommand="header-command"
6965
varNoOpen="no-open"
@@ -201,7 +197,7 @@ func (r *RootCmd) RunWithSubcommands(subcommands []*serpent.Command) {
201197
func (r*RootCmd)Command(subcommands []*serpent.Command) (*serpent.Command,error) {
202198
fmtLong:=`Coder %s — A tool for provisioning self-hosted development environments with Terraform.
203199
`
204-
hiddenAgentAuth:=NewAgentAuth()
200+
hiddenAgentAuth:=&AgentAuth{}
205201
cmd:=&serpent.Command{
206202
Use:"coder [global-flags] <subcommand>",
207203
Long:fmt.Sprintf(fmtLong,buildinfo.Version())+FormatExamples(
@@ -652,42 +648,36 @@ type AgentAuth struct {
652648
// Agent Client config
653649
agentTokenstring
654650
agentTokenFilestring
655-
agentURL*url.URL
651+
agentURL url.URL
656652
agentAuthstring
657653
}
658654

659-
funcNewAgentAuth()*AgentAuth {
660-
return&AgentAuth{
661-
agentURL:new(url.URL),
662-
}
663-
}
664-
665655
func (a*AgentAuth)AttachOptions(cmd*serpent.Command,hiddenbool) {
666656
cmd.Options=append(cmd.Options, serpent.Option{
667657
Name:"Agent Token",
668658
Description:"An agent authentication token.",
669-
Flag:varAgentToken,
659+
Flag:"agent-token",
670660
Env:envAgentToken,
671661
Value:serpent.StringOf(&a.agentToken),
672662
Hidden:hidden,
673663
}, serpent.Option{
674664
Name:"Agent Token File",
675665
Description:"A file containing an agent authentication token.",
676-
Flag:varAgentTokenFile,
666+
Flag:"agent-token-file",
677667
Env:envAgentTokenFile,
678668
Value:serpent.StringOf(&a.agentTokenFile),
679669
Hidden:hidden,
680670
}, serpent.Option{
681671
Name:"Agent URL",
682672
Description:"URL for an agent to access your deployment.",
683-
Flag:varAgentURL,
673+
Flag:"agent-url",
684674
Env:envAgentURL,
685-
Value:serpent.URLOf(a.agentURL),
675+
Value:serpent.URLOf(&a.agentURL),
686676
Hidden:hidden,
687677
}, serpent.Option{
688678
Name:"Agent Auth",
689679
Description:"Specify the authentication type to use for the agent.",
690-
Flag:varAgentAuth,
680+
Flag:"auth",
691681
Env:envAgentAuth,
692682
Default:"token",
693683
Value:serpent.StringOf(&a.agentAuth),
@@ -699,7 +689,7 @@ func (a *AgentAuth) AttachOptions(cmd *serpent.Command, hidden bool) {
699689
// just like InitClient, but uses the agent token and URL instead.
700690
func (a*AgentAuth)CreateClient(ctx context.Context) (*agentsdk.Client,error) {
701691
agentURL:=a.agentURL
702-
ifagentURL==nil||agentURL.String()=="" {
692+
ifagentURL.String()=="" {
703693
returnnil,xerrors.Errorf("%s must be set",envAgentURL)
704694
}
705695

@@ -719,7 +709,7 @@ func (a *AgentAuth) CreateClient(ctx context.Context) (*agentsdk.Client, error)
719709
iftoken=="" {
720710
returnnil,xerrors.Errorf("CODER_AGENT_TOKEN or CODER_AGENT_TOKEN_FILE must be set for token auth")
721711
}
722-
returnagentsdk.New(a.agentURL,agentsdk.WithFixedToken(token)),nil
712+
returnagentsdk.New(&a.agentURL,agentsdk.WithFixedToken(token)),nil
723713
case"google-instance-identity":
724714

725715
// This is *only* done for testing to mock client authentication.
@@ -729,9 +719,9 @@ func (a *AgentAuth) CreateClient(ctx context.Context) (*agentsdk.Client, error)
729719
ifgcpClientRaw!=nil {
730720
gcpClient,_=gcpClientRaw.(*metadata.Client)
731721
}
732-
returnagentsdk.New(a.agentURL,agentsdk.WithGoogleInstanceIdentity("",gcpClient)),nil
722+
returnagentsdk.New(&a.agentURL,agentsdk.WithGoogleInstanceIdentity("",gcpClient)),nil
733723
case"aws-instance-identity":
734-
client:=agentsdk.New(a.agentURL,agentsdk.WithAWSInstanceIdentity())
724+
client:=agentsdk.New(&a.agentURL,agentsdk.WithAWSInstanceIdentity())
735725
// This is *only* done for testing to mock client authentication.
736726
// This will never be set in a production scenario.
737727
varawsClient*http.Client
@@ -744,7 +734,7 @@ func (a *AgentAuth) CreateClient(ctx context.Context) (*agentsdk.Client, error)
744734
}
745735
returnclient,nil
746736
case"azure-instance-identity":
747-
client:=agentsdk.New(a.agentURL,agentsdk.WithAzureInstanceIdentity())
737+
client:=agentsdk.New(&a.agentURL,agentsdk.WithAzureInstanceIdentity())
748738
// This is *only* done for testing to mock client authentication.
749739
// This will never be set in a production scenario.
750740
varazureClient*http.Client

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp