diff --git a/pkg/config/ssh.go b/pkg/config/ssh.go index 7a46cacf..3afeae98 100644 --- a/pkg/config/ssh.go +++ b/pkg/config/ssh.go @@ -67,7 +67,6 @@ type Bastion struct { Hosts []Host `yaml:"hosts"` IdentityFile string `yaml:"identity_file"` - User string `yaml:"user"` SSHExecCommand *SSHExecCommand `yaml:"ssh_exec_command,omitempty"` } diff --git a/pkg/config/ssh_test.go b/pkg/config/ssh_test.go index aa5c8b00..ce65d4db 100644 --- a/pkg/config/ssh_test.go +++ b/pkg/config/ssh_test.go @@ -6,6 +6,7 @@ import ( "github.com/chanzuckerberg/blessclient/pkg/config" "github.com/stretchr/testify/require" + yaml "gopkg.in/yaml.v2" ) func TestSSHConfig(t *testing.T) { @@ -61,8 +62,8 @@ func TestUserOverride(t *testing.T) { { Host: config.Host{ Pattern: "test0", + User: "foo", }, - User: "foo", Hosts: []config.Host{ { User: "bar", @@ -97,3 +98,39 @@ Host 10.0.0.* r.NoError(err) r.Contains(config, expected) } + +func TestUnmarshalConfig(t *testing.T) { + // test we can roundtrip a config through yaml + t.Parallel() + r := require.New(t) + + sshConf := &config.SSHConfig{ + Bastions: []config.Bastion{ + { + Host: config.Host{ + Pattern: "test0", + User: "foo", + }, + Hosts: []config.Host{ + { + User: "bar", + Pattern: "10.0.0.*", + }, + { + // no user override here + Pattern: "10.0.0.*", + }, + }, + }, + }, + } + + data, err := yaml.Marshal(sshConf) + r.NoError(err) + + newConf := &config.SSHConfig{} + err = yaml.Unmarshal(data, newConf) + r.NoError(err) + + r.Equal(sshConf, newConf) +}