From b424c3d870e096c2652c5d62ee350b0e44bd6210 Mon Sep 17 00:00:00 2001 From: Andrey Kostov Date: Mon, 15 Aug 2016 14:35:18 -0700 Subject: [PATCH] Better error handling for GCS credential argument addition Signed-off-by: Andrey Kostov --- registry/storage/driver/gcs/gcs.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/registry/storage/driver/gcs/gcs.go b/registry/storage/driver/gcs/gcs.go index d1276c25..a1dbd195 100644 --- a/registry/storage/driver/gcs/gcs.go +++ b/registry/storage/driver/gcs/gcs.go @@ -151,12 +151,16 @@ func FromParameters(parameters map[string]interface{}) (storagedriver.StorageDri for k, v := range credentialMap { key, ok := k.(string) if !ok { - return nil, fmt.Errorf("One of the credential keys was not a string") + return nil, fmt.Errorf("One of the credential keys was not a string: %s", fmt.Sprint(k)) } stringMap[key] = v } data, err := json.Marshal(stringMap) + if err != nil { + return nil, fmt.Errorf("Failed to marshal gcs credentials to json") + } + jwtConf, err := google.JWTConfigFromJSON(data, storage.ScopeFullControl) if err != nil { return nil, err