Merge pull request #12668 from hashicorp/paddy_deprecate_google_credentials_file

provider/google: remove deprecated account_file field.
This commit is contained in:
Paddy 2017-03-14 13:23:59 -07:00 committed by GitHub
commit 93196f3907
2 changed files with 4 additions and 52 deletions

View File

@ -5,7 +5,6 @@ import (
"fmt" "fmt"
"strings" "strings"
"github.com/hashicorp/terraform/helper/pathorcontents"
"github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
"google.golang.org/api/compute/v1" "google.golang.org/api/compute/v1"
@ -20,8 +19,7 @@ func Provider() terraform.ResourceProvider {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
DefaultFunc: schema.EnvDefaultFunc("GOOGLE_ACCOUNT_FILE", nil), DefaultFunc: schema.EnvDefaultFunc("GOOGLE_ACCOUNT_FILE", nil),
ValidateFunc: validateAccountFile, Removed: "Use the credentials field instead",
Deprecated: "Use the credentials field instead",
}, },
"credentials": &schema.Schema{ "credentials": &schema.Schema{
@ -115,9 +113,6 @@ func Provider() terraform.ResourceProvider {
func providerConfigure(d *schema.ResourceData) (interface{}, error) { func providerConfigure(d *schema.ResourceData) (interface{}, error) {
credentials := d.Get("credentials").(string) credentials := d.Get("credentials").(string)
if credentials == "" {
credentials = d.Get("account_file").(string)
}
config := Config{ config := Config{
Credentials: credentials, Credentials: credentials,
Project: d.Get("project").(string), Project: d.Get("project").(string),
@ -131,36 +126,6 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
return &config, nil return &config, nil
} }
func validateAccountFile(v interface{}, k string) (warnings []string, errors []error) {
if v == nil {
return
}
value := v.(string)
if value == "" {
return
}
contents, wasPath, err := pathorcontents.Read(value)
if err != nil {
errors = append(errors, fmt.Errorf("Error loading Account File: %s", err))
}
if wasPath {
warnings = append(warnings, `account_file was provided as a path instead of
as file contents. This support will be removed in the future. Please update
your configuration to use ${file("filename.json")} instead.`)
}
var account accountFile
if err := json.Unmarshal([]byte(contents), &account); err != nil {
errors = append(errors,
fmt.Errorf("account_file not valid JSON '%s': %s", contents, err))
}
return
}
func validateCredentials(v interface{}, k string) (warnings []string, errors []error) { func validateCredentials(v interface{}, k string) (warnings []string, errors []error) {
if v == nil || v.(string) == "" { if v == nil || v.(string) == "" {
return return

View File

@ -62,19 +62,6 @@ The following keys can be used to configure the provider.
* `GCLOUD_REGION` * `GCLOUD_REGION`
* `CLOUDSDK_COMPUTE_REGION` * `CLOUDSDK_COMPUTE_REGION`
The following keys are supported for backwards compatibility, and may be
removed in a future version:
* `account_file` - __Deprecated: please use `credentials` instead.__
Path to or contents of the JSON file used to describe your
account credentials, downloaded from Google Cloud Console. More details on
retrieving this file are below. The `account file` can be "" if you are running
terraform from a GCE instance with a properly-configured [Compute Engine
Service Account](https://cloud.google.com/compute/docs/authentication). This
can also be specified with the `GOOGLE_ACCOUNT_FILE` shell environment
variable.
## Authentication JSON File ## Authentication JSON File
Authenticating with Google Cloud services requires a JSON Authenticating with Google Cloud services requires a JSON