github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/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_schedule":          dataSourcePagerDutySchedule(),
    24  			"pagerduty_escalation_policy": dataSourcePagerDutyEscalationPolicy(),
    25  			"pagerduty_vendor":            dataSourcePagerDutyVendor(),
    26  		},
    27  
    28  		ResourcesMap: map[string]*schema.Resource{
    29  			"pagerduty_addon":               resourcePagerDutyAddon(),
    30  			"pagerduty_user":                resourcePagerDutyUser(),
    31  			"pagerduty_team":                resourcePagerDutyTeam(),
    32  			"pagerduty_service":             resourcePagerDutyService(),
    33  			"pagerduty_service_integration": resourcePagerDutyServiceIntegration(),
    34  			"pagerduty_schedule":            resourcePagerDutySchedule(),
    35  			"pagerduty_escalation_policy":   resourcePagerDutyEscalationPolicy(),
    36  		},
    37  
    38  		ConfigureFunc: providerConfigure,
    39  	}
    40  }
    41  
    42  func providerConfigure(data *schema.ResourceData) (interface{}, error) {
    43  	config := Config{Token: data.Get("token").(string)}
    44  	log.Println("[INFO] Initializing PagerDuty client")
    45  	return config.Client()
    46  }