@@ -222,16 +222,16 @@ func SetupRepoAuth(options *Options) transport.AuthMethod {
222
222
223
223
// If we have no signer but we have a Coder URL and agent token, try to fetch
224
224
// an SSH key from Coder!
225
- if signer == nil && options .CoderAgentURL != nil && options .CoderAgentToken != "" {
226
- options .Logger (codersdk .LogLevelInfo , "#1: 🔑 Fetching key from %s!" , options .CoderAgentURL . String () )
225
+ if signer == nil && options .CoderAgentURL != "" && options .CoderAgentToken != "" {
226
+ options .Logger (codersdk .LogLevelInfo , "#1: 🔑 Fetching key from %s!" , options .CoderAgentURL )
227
227
ctx , cancel := context .WithTimeout (context .Background (), 10 * time .Second )
228
228
defer cancel ()
229
229
s , err := FetchCoderSSHKey (ctx , options .CoderAgentURL , options .CoderAgentToken )
230
230
if err == nil {
231
231
signer = s
232
232
options .Logger (codersdk .LogLevelInfo , "#1: 🔑 Fetched %s key %s !" , signer .PublicKey ().Type (), keyFingerprint (signer )[:8 ])
233
233
} else {
234
- options .Logger (codersdk .LogLevelInfo , "#1: ❌ Failed to fetch SSH key: %w" , options .CoderAgentURL . String () , err )
234
+ options .Logger (codersdk .LogLevelInfo , "#1: ❌ Failed to fetch SSH key: %w" , options .CoderAgentURL , err )
235
235
}
236
236
}
237
237
@@ -271,8 +271,12 @@ func SetupRepoAuth(options *Options) transport.AuthMethod {
271
271
272
272
// FetchCoderSSHKey fetches the user's Git SSH key from Coder using the supplied
273
273
// Coder URL and agent token.
274
- func FetchCoderSSHKey (ctx context.Context , coderURL url.URL , agentToken string ) (gossh.Signer , error ) {
275
- client := agentsdk .New (& coderURL )
274
+ func FetchCoderSSHKey (ctx context.Context , coderURL string , agentToken string ) (gossh.Signer , error ) {
275
+ u , err := url .Parse (coderURL )
276
+ if err != nil {
277
+ return nil , fmt .Errorf ("invalid Coder URL: %w" , err )
278
+ }
279
+ client := agentsdk .New (u )
276
280
client .SetSessionToken (agentToken )
277
281
key , err := client .GitSSHKey (ctx )
278
282
if err != nil {
0 commit comments