From c30fc51b035e0bc1f8d35cb10b4bec5c7d1c6820 Mon Sep 17 00:00:00 2001 From: Kiril Vladimirov Date: Sat, 21 Feb 2015 19:22:16 +0200 Subject: [PATCH] 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. --- datasource/metadata/cloudsigma/server_context.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datasource/metadata/cloudsigma/server_context.go b/datasource/metadata/cloudsigma/server_context.go index b618e45..d1a5015 100644 --- a/datasource/metadata/cloudsigma/server_context.go +++ b/datasource/metadata/cloudsigma/server_context.go @@ -108,7 +108,7 @@ func (scs *serverContextService) FetchMetadata() (metadata datasource.Metadata, } 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, " ") metadata.SSHPublicKeys[splitted[len(splitted)-1]] = key }