Merge pull request #29719 from hashicorp/megan_invalid_creds
add better error if credentials are invalid
This commit is contained in:
commit
71cbb2a81a
|
@ -4,6 +4,7 @@ package gcs
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -141,6 +142,10 @@ func (b *Backend) configure(ctx context.Context) error {
|
||||||
return fmt.Errorf("Error loading credentials: %s", err)
|
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)))
|
credOptions = append(credOptions, option.WithCredentialsJSON([]byte(contents)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue