mirror of https://github.com/coder/coder.git
fix: Write agent URL to file for gitssh (#1123)
This was broken because gitssh couldn't find the URL.
Now it can, and SSH is confirmed to work on dogfood! 🥳
This commit is contained in:
parent
68f67c54b6
commit
8ff0c8b02a
|
@ -120,6 +120,10 @@ func workspaceAgent() *cobra.Command {
|
|||
if err != nil {
|
||||
return xerrors.Errorf("writing agent session token to config: %w", err)
|
||||
}
|
||||
err = cfg.URL().Write(client.URL.String())
|
||||
if err != nil {
|
||||
return xerrors.Errorf("writing agent url to config: %w", err)
|
||||
}
|
||||
|
||||
closer := agent.New(client.ListenWorkspaceAgent, logger)
|
||||
<-cmd.Context().Done()
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/coder/coder/codersdk"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/xerrors"
|
||||
)
|
||||
|
@ -14,15 +16,20 @@ func gitssh() *cobra.Command {
|
|||
Hidden: true,
|
||||
Short: `Wraps the "ssh" command and uses the coder gitssh key for authentication`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
client, err := createClient(cmd)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("create codersdk client: %w", err)
|
||||
}
|
||||
cfg := createConfig(cmd)
|
||||
rawURL, err := cfg.URL().Read()
|
||||
if err != nil {
|
||||
return xerrors.Errorf("read agent url from config: %w", err)
|
||||
}
|
||||
parsedURL, err := url.Parse(rawURL)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("parse agent url from config: %w", err)
|
||||
}
|
||||
session, err := cfg.AgentSession().Read()
|
||||
if err != nil {
|
||||
return xerrors.Errorf("read agent session from config: %w", err)
|
||||
}
|
||||
client := codersdk.New(parsedURL)
|
||||
client.SessionToken = session
|
||||
|
||||
key, err := client.AgentGitSSHKey(cmd.Context())
|
||||
|
|
Loading…
Reference in New Issue