Merge pull request #29719 from hashicorp/megan_invalid_creds

add better error if credentials are invalid
This commit is contained in:
megan07 2021-10-08 10:26:53 -05:00 committed by GitHub
commit 71cbb2a81a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -4,6 +4,7 @@ package gcs
import (
"context"
"encoding/base64"
"encoding/json"
"fmt"
"os"
"strings"
@ -141,6 +142,10 @@ func (b *Backend) configure(ctx context.Context) error {
return fmt.Errorf("Error loading credentials: %s", err)
}
if !json.Valid([]byte(contents)) {
return fmt.Errorf("contents of credentials are invalid json")
}
credOptions = append(credOptions, option.WithCredentialsJSON([]byte(contents)))
}