File tree 3 files changed +11
-6
lines changed
3 files changed +11
-6
lines changed Original file line number Diff line number Diff line change 6
6
"errors"
7
7
"fmt"
8
8
"net/http"
9
+ "net/url"
9
10
"os"
10
11
"slices"
11
12
"strings"
@@ -31,10 +32,14 @@ func main() {
31
32
Handler : func (inv * serpent.Invocation ) error {
32
33
var sendLogs func (ctx context.Context , log ... agentsdk.Log ) error
33
34
if options .CoderAgentToken != "" {
34
- if options .CoderAgentURL == nil {
35
+ if options .CoderAgentURL == "" {
35
36
return errors .New ("CODER_AGENT_URL must be set if CODER_AGENT_TOKEN is set" )
36
37
}
37
- client := agentsdk .New (options .CoderAgentURL )
38
+ u , err := url .Parse (options .CoderAgentURL )
39
+ if err != nil {
40
+ return fmt .Errorf ("unable to parse CODER_AGENT_URL as URL: %w" , err )
41
+ }
42
+ client := agentsdk .New (u )
38
43
client .SetSessionToken (options .CoderAgentToken )
39
44
client .SDK .HTTPClient = & http.Client {
40
45
Transport : & http.Transport {
Original file line number Diff line number Diff line change 1
1
package envbuilder
2
2
3
3
import (
4
- "net/url"
5
4
"strings"
6
5
7
6
"github.com/coder/coder/v2/codersdk"
@@ -132,7 +131,8 @@ type Options struct {
132
131
Filesystem billy.Filesystem
133
132
// These options are specifically used when envbuilder is invoked as part of a
134
133
// Coder workspace.
135
- CoderAgentURL * url.URL
134
+ // Revert to `*url.URL` once https://github.com/coder/serpent/issues/14 is fixed.
135
+ CoderAgentURL string
136
136
// CoderAgentToken is the authentication token for a Coder agent.
137
137
CoderAgentToken string
138
138
// CoderAgentSubsystem is the Coder agent subsystems to report when forwarding
@@ -375,7 +375,7 @@ func (o *Options) CLI() serpent.OptionSet {
375
375
{
376
376
Flag : "coder-agent-url" ,
377
377
Env : "CODER_AGENT_URL" ,
378
- Value : serpent .URLOf ( o .CoderAgentURL ),
378
+ Value : serpent .StringOf ( & o .CoderAgentURL ),
379
379
Description : "URL of the Coder deployment. If CODER_AGENT_TOKEN is also " +
380
380
"set, logs from envbuilder will be forwarded here and will be " +
381
381
"visible in the workspace build logs." ,
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ OPTIONS:
28
28
Authentication token for a Coder agent. If this is set, then
29
29
CODER_AGENT_URL must also be set.
30
30
31
- --coder-agent-url url , $CODER_AGENT_URL
31
+ --coder-agent-url string , $CODER_AGENT_URL
32
32
URL of the Coder deployment. If CODER_AGENT_TOKEN is also set, logs
33
33
from envbuilder will be forwarded here and will be visible in the
34
34
workspace build logs.
You can’t perform that action at this time.
0 commit comments