From 919dcebc45272b22d760ac686229b104941e55ad Mon Sep 17 00:00:00 2001 From: Caleb Brose <5447118+cmbrose@users.noreply.github.com> Date: Mon, 13 Jun 2022 19:16:16 +0000 Subject: [PATCH] Rename Context --- pkg/cmd/auth/shared/login_flow.go | 2 +- pkg/cmd/auth/shared/login_flow_test.go | 2 +- pkg/cmd/codespace/ssh.go | 2 +- pkg/ssh/ssh_keys.go | 12 ++++++------ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/cmd/auth/shared/login_flow.go b/pkg/cmd/auth/shared/login_flow.go index a28ef97ce..5888995cb 100644 --- a/pkg/cmd/auth/shared/login_flow.go +++ b/pkg/cmd/auth/shared/login_flow.go @@ -37,7 +37,7 @@ type LoginOptions struct { Executable string GitProtocol string - sshContext ssh.SshContext + sshContext ssh.Context } func Login(opts *LoginOptions) error { diff --git a/pkg/cmd/auth/shared/login_flow_test.go b/pkg/cmd/auth/shared/login_flow_test.go index 3d99d1ebc..d32e2cc87 100644 --- a/pkg/cmd/auth/shared/login_flow_test.go +++ b/pkg/cmd/auth/shared/login_flow_test.go @@ -85,7 +85,7 @@ func TestLogin_ssh(t *testing.T) { HTTPClient: &http.Client{Transport: &tr}, Hostname: "example.com", Interactive: true, - sshContext: ssh.SshContext{ + sshContext: ssh.Context{ ConfigDir: dir, KeygenExe: "ssh-keygen", }, diff --git a/pkg/cmd/codespace/ssh.go b/pkg/cmd/codespace/ssh.go index 5f4a822b9..becafafdf 100644 --- a/pkg/cmd/codespace/ssh.go +++ b/pkg/cmd/codespace/ssh.go @@ -121,7 +121,7 @@ func (a *App) SSH(ctx context.Context, sshArgs []string, opts sshOptions) (err e args = opts.scpArgs } - sshContext := ssh.SshContext{} + sshContext := ssh.Context{} startSSHOptions := liveshare.StartSSHServerOptions{} if shouldGenerateSSHKeys(args, opts) && sshContext.HasKeygen() { diff --git a/pkg/ssh/ssh_keys.go b/pkg/ssh/ssh_keys.go index bd347d4a1..7f4a1e9d9 100644 --- a/pkg/ssh/ssh_keys.go +++ b/pkg/ssh/ssh_keys.go @@ -12,7 +12,7 @@ import ( "github.com/cli/safeexec" ) -type SshContext struct { +type Context struct { ConfigDir string KeygenExe string } @@ -28,7 +28,7 @@ type KeyAlreadyExistsError struct { func (err *KeyAlreadyExistsError) Error() string { return "SSH key already exists: " + err.keyPath } -func (c *SshContext) LocalPublicKeys() ([]string, error) { +func (c *Context) LocalPublicKeys() ([]string, error) { sshDir, err := c.sshDir() if err != nil { return nil, err @@ -37,12 +37,12 @@ func (c *SshContext) LocalPublicKeys() ([]string, error) { return filepath.Glob(filepath.Join(sshDir, "*.pub")) } -func (c *SshContext) HasKeygen() bool { +func (c *Context) HasKeygen() bool { _, err := c.findKeygen() return err == nil } -func (c *SshContext) GenerateSSHKey(keyName string, passphrase string) (*KeyPair, error) { +func (c *Context) GenerateSSHKey(keyName string, passphrase string) (*KeyPair, error) { keygenExe, err := c.findKeygen() if err != nil { return nil, fmt.Errorf("could not find keygen executable") @@ -76,7 +76,7 @@ func (c *SshContext) GenerateSSHKey(keyName string, passphrase string) (*KeyPair return &keyPair, nil } -func (c *SshContext) sshDir() (string, error) { +func (c *Context) sshDir() (string, error) { if c.ConfigDir != "" { return c.ConfigDir, nil } @@ -87,7 +87,7 @@ func (c *SshContext) sshDir() (string, error) { return dir, err } -func (c *SshContext) findKeygen() (string, error) { +func (c *Context) findKeygen() (string, error) { if c.KeygenExe != "" { return c.KeygenExe, nil }