mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-03 08:42:39 +00:00
Move duplicated envDefaultFunc out of each provider and into Schema.
This commit is contained in:
parent
80facc343c
commit
57273b4844
20
provider.go
20
provider.go
|
@ -1,8 +1,6 @@
|
|||
package google
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
@ -14,25 +12,25 @@ func Provider() terraform.ResourceProvider {
|
|||
"account_file": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
DefaultFunc: envDefaultFunc("GOOGLE_ACCOUNT_FILE"),
|
||||
DefaultFunc: schema.EnvDefaultFunc("GOOGLE_ACCOUNT_FILE", nil),
|
||||
},
|
||||
|
||||
"client_secrets_file": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
DefaultFunc: envDefaultFunc("GOOGLE_CLIENT_FILE"),
|
||||
DefaultFunc: schema.EnvDefaultFunc("GOOGLE_CLIENT_FILE", nil),
|
||||
},
|
||||
|
||||
"project": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
DefaultFunc: envDefaultFunc("GOOGLE_PROJECT"),
|
||||
DefaultFunc: schema.EnvDefaultFunc("GOOGLE_PROJECT", nil),
|
||||
},
|
||||
|
||||
"region": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
DefaultFunc: envDefaultFunc("GOOGLE_REGION"),
|
||||
DefaultFunc: schema.EnvDefaultFunc("GOOGLE_REGION", nil),
|
||||
},
|
||||
},
|
||||
|
||||
|
@ -49,16 +47,6 @@ func Provider() terraform.ResourceProvider {
|
|||
}
|
||||
}
|
||||
|
||||
func envDefaultFunc(k string) schema.SchemaDefaultFunc {
|
||||
return func() (interface{}, error) {
|
||||
if v := os.Getenv(k); v != "" {
|
||||
return v, nil
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
|
||||
config := Config{
|
||||
AccountFile: d.Get("account_file").(string),
|
||||
|
|
Loading…
Reference in New Issue
Block a user