github.com/recobe182/terraform@v0.8.5-0.20170117231232-49ab22a935b7/builtin/providers/opsgenie/provider.go (about) 1 package opsgenie 2 3 import ( 4 "log" 5 6 "github.com/hashicorp/terraform/helper/schema" 7 "github.com/hashicorp/terraform/terraform" 8 ) 9 10 // Provider represents a resource provider in Terraform 11 func Provider() terraform.ResourceProvider { 12 return &schema.Provider{ 13 Schema: map[string]*schema.Schema{ 14 "api_key": { 15 Type: schema.TypeString, 16 Required: true, 17 DefaultFunc: schema.EnvDefaultFunc("OPSGENIE_API_KEY", nil), 18 }, 19 }, 20 21 DataSourcesMap: map[string]*schema.Resource{ 22 "opsgenie_user": dataSourceOpsGenieUser(), 23 }, 24 25 ResourcesMap: map[string]*schema.Resource{ 26 "opsgenie_team": resourceOpsGenieTeam(), 27 "opsgenie_user": resourceOpsGenieUser(), 28 }, 29 30 ConfigureFunc: providerConfigure, 31 } 32 } 33 34 func providerConfigure(data *schema.ResourceData) (interface{}, error) { 35 log.Println("[INFO] Initializing OpsGenie client") 36 37 config := Config{ 38 ApiKey: data.Get("api_key").(string), 39 } 40 41 return config.Client() 42 }