@@ -222,16 +222,16 @@ func SetupRepoAuth(options *Options) transport.AuthMethod {
222222
223223 // If we have no signer but we have a Coder URL and agent token, try to fetch
224224 // 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 )
227227 ctx , cancel := context .WithTimeout (context .Background (), 10 * time .Second )
228228 defer cancel ()
229229 s , err := FetchCoderSSHKey (ctx , options .CoderAgentURL , options .CoderAgentToken )
230230 if err == nil {
231231 signer = s
232232 options .Logger (codersdk .LogLevelInfo , "#1: 🔑 Fetched %s key %s !" , signer .PublicKey ().Type (), keyFingerprint (signer )[:8 ])
233233 } 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 )
235235 }
236236 }
237237
@@ -271,8 +271,12 @@ func SetupRepoAuth(options *Options) transport.AuthMethod {
271271
272272// FetchCoderSSHKey fetches the user's Git SSH key from Coder using the supplied
273273// 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 )
276280 client .SetSessionToken (agentToken )
277281 key , err := client .GitSSHKey (ctx )
278282 if err != nil {
0 commit comments