fix(datasource/CloudSigma): Make sure public ssh key is not empty

Even when public ssh key is not set by the user, CloudSigma's server
context has a key `meta.ssh_public_key` which is just an empty string.
So instead of just relying on the "comma ok" idiom I make sure the value
is not an empty string.
This commit is contained in:
Kiril Vladimirov 2015-02-21 19:22:16 +02:00
parent b429eaab84
commit c30fc51b03

View File

@ -108,7 +108,7 @@ func (scs *serverContextService) FetchMetadata() (metadata datasource.Metadata,
} }
metadata.SSHPublicKeys = map[string]string{} metadata.SSHPublicKeys = map[string]string{}
if key, ok := inputMetadata.Meta["ssh_public_key"]; ok { if key, _ := inputMetadata.Meta["ssh_public_key"]; len(key) > 0 {
splitted := strings.Split(key, " ") splitted := strings.Split(key, " ")
metadata.SSHPublicKeys[splitted[len(splitted)-1]] = key metadata.SSHPublicKeys[splitted[len(splitted)-1]] = key
} }