Remove deprecated key_file and bastion_key_file
These were deprecated in the 0.6.x series. Their functionality was broken in a recent release which whould have removed them as well.
This commit is contained in:
parent
77d76a69ba
commit
8174037a2b
|
@ -32,7 +32,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// connectionInfo is decoded from the ConnInfo of the resource. These are the
|
// connectionInfo is decoded from the ConnInfo of the resource. These are the
|
||||||
// only keys we look at. If a KeyFile is given, that is used instead
|
// only keys we look at. If a PrivateKey is given, that is used instead
|
||||||
// of a password.
|
// of a password.
|
||||||
type connectionInfo struct {
|
type connectionInfo struct {
|
||||||
User string
|
User string
|
||||||
|
@ -50,10 +50,6 @@ type connectionInfo struct {
|
||||||
BastionPrivateKey string `mapstructure:"bastion_private_key"`
|
BastionPrivateKey string `mapstructure:"bastion_private_key"`
|
||||||
BastionHost string `mapstructure:"bastion_host"`
|
BastionHost string `mapstructure:"bastion_host"`
|
||||||
BastionPort int `mapstructure:"bastion_port"`
|
BastionPort int `mapstructure:"bastion_port"`
|
||||||
|
|
||||||
// Deprecated
|
|
||||||
KeyFile string `mapstructure:"key_file"`
|
|
||||||
BastionKeyFile string `mapstructure:"bastion_key_file"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseConnectionInfo is used to convert the ConnInfo of the InstanceState into
|
// parseConnectionInfo is used to convert the ConnInfo of the InstanceState into
|
||||||
|
@ -101,15 +97,6 @@ func parseConnectionInfo(s *terraform.InstanceState) (*connectionInfo, error) {
|
||||||
connInfo.TimeoutVal = DefaultTimeout
|
connInfo.TimeoutVal = DefaultTimeout
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load deprecated fields; we can handle either path or contents in
|
|
||||||
// underlying implementation.
|
|
||||||
if connInfo.PrivateKey == "" && connInfo.KeyFile != "" {
|
|
||||||
connInfo.PrivateKey = connInfo.KeyFile
|
|
||||||
}
|
|
||||||
if connInfo.BastionPrivateKey == "" && connInfo.BastionKeyFile != "" {
|
|
||||||
connInfo.BastionPrivateKey = connInfo.BastionKeyFile
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default all bastion config attrs to their non-bastion counterparts
|
// Default all bastion config attrs to their non-bastion counterparts
|
||||||
if connInfo.BastionHost != "" {
|
if connInfo.BastionHost != "" {
|
||||||
// Format the bastion host if needed.
|
// Format the bastion host if needed.
|
||||||
|
|
|
@ -127,27 +127,3 @@ func TestProvisioner_connInfoHostname(t *testing.T) {
|
||||||
t.Fatalf("bad %v", conf)
|
t.Fatalf("bad %v", conf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProvisioner_connInfoLegacy(t *testing.T) {
|
|
||||||
r := &terraform.InstanceState{
|
|
||||||
Ephemeral: terraform.EphemeralState{
|
|
||||||
ConnInfo: map[string]string{
|
|
||||||
"type": "ssh",
|
|
||||||
"key_file": "/my/key/file.pem",
|
|
||||||
"bastion_host": "127.0.1.1",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
conf, err := parseConnectionInfo(r)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("err: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if conf.PrivateKey != "/my/key/file.pem" {
|
|
||||||
t.Fatalf("bad: %v", conf)
|
|
||||||
}
|
|
||||||
if conf.BastionPrivateKey != "/my/key/file.pem" {
|
|
||||||
t.Fatalf("bad: %v", conf)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue