github.com/recobe182/terraform@v0.8.5-0.20170117231232-49ab22a935b7/builtin/providers/pagerduty/provider.go (about) 1 package pagerduty 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 "token": { 15 Type: schema.TypeString, 16 Required: true, 17 DefaultFunc: schema.EnvDefaultFunc("PAGERDUTY_TOKEN", nil), 18 }, 19 }, 20 21 DataSourcesMap: map[string]*schema.Resource{ 22 "pagerduty_user": dataSourcePagerDutyUser(), 23 "pagerduty_vendor": dataSourcePagerDutyVendor(), 24 }, 25 26 ResourcesMap: map[string]*schema.Resource{ 27 "pagerduty_user": resourcePagerDutyUser(), 28 "pagerduty_team": resourcePagerDutyTeam(), 29 "pagerduty_service": resourcePagerDutyService(), 30 "pagerduty_service_integration": resourcePagerDutyServiceIntegration(), 31 "pagerduty_schedule": resourcePagerDutySchedule(), 32 "pagerduty_escalation_policy": resourcePagerDutyEscalationPolicy(), 33 }, 34 35 ConfigureFunc: providerConfigure, 36 } 37 } 38 39 func providerConfigure(data *schema.ResourceData) (interface{}, error) { 40 config := Config{Token: data.Get("token").(string)} 41 log.Println("[INFO] Initializing PagerDuty client") 42 return config.Client() 43 }