github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/builtin/providers/arukas/provider.go (about) 1 package arukas 2 3 import ( 4 "github.com/hashicorp/terraform/helper/schema" 5 "github.com/hashicorp/terraform/terraform" 6 ) 7 8 // Provider returns a terraform.ResourceProvider. 9 func Provider() terraform.ResourceProvider { 10 return &schema.Provider{ 11 Schema: map[string]*schema.Schema{ 12 "token": &schema.Schema{ 13 Type: schema.TypeString, 14 Required: true, 15 DefaultFunc: schema.EnvDefaultFunc(JSONTokenParamName, nil), 16 Description: "your Arukas APIKey(token)", 17 }, 18 "secret": &schema.Schema{ 19 Type: schema.TypeString, 20 Required: true, 21 DefaultFunc: schema.EnvDefaultFunc(JSONSecretParamName, nil), 22 Description: "your Arukas APIKey(secret)", 23 }, 24 "api_url": &schema.Schema{ 25 Type: schema.TypeString, 26 Optional: true, 27 DefaultFunc: schema.EnvDefaultFunc(JSONUrlParamName, "https://app.arukas.io/api/"), 28 Description: "default Arukas API url", 29 }, 30 "trace": &schema.Schema{ 31 Type: schema.TypeString, 32 Optional: true, 33 DefaultFunc: schema.EnvDefaultFunc(JSONDebugParamName, ""), 34 }, 35 "timeout": &schema.Schema{ 36 Type: schema.TypeInt, 37 Optional: true, 38 DefaultFunc: schema.EnvDefaultFunc(JSONTimeoutParamName, "600"), 39 }, 40 }, 41 ResourcesMap: map[string]*schema.Resource{ 42 "arukas_container": resourceArukasContainer(), 43 }, 44 ConfigureFunc: providerConfigure, 45 } 46 } 47 48 func providerConfigure(d *schema.ResourceData) (interface{}, error) { 49 50 config := Config{ 51 Token: d.Get("token").(string), 52 Secret: d.Get("secret").(string), 53 URL: d.Get("api_url").(string), 54 Trace: d.Get("trace").(string), 55 Timeout: d.Get("timeout").(int), 56 } 57 58 return config.NewClient() 59 }