github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/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  			"skip_credentials_validation": {
    21  				Type:     schema.TypeBool,
    22  				Optional: true,
    23  				Default:  false,
    24  			},
    25  		},
    26  
    27  		DataSourcesMap: map[string]*schema.Resource{
    28  			"pagerduty_user":              dataSourcePagerDutyUser(),
    29  			"pagerduty_schedule":          dataSourcePagerDutySchedule(),
    30  			"pagerduty_escalation_policy": dataSourcePagerDutyEscalationPolicy(),
    31  			"pagerduty_vendor":            dataSourcePagerDutyVendor(),
    32  		},
    33  
    34  		ResourcesMap: map[string]*schema.Resource{
    35  			"pagerduty_addon":               resourcePagerDutyAddon(),
    36  			"pagerduty_user":                resourcePagerDutyUser(),
    37  			"pagerduty_team":                resourcePagerDutyTeam(),
    38  			"pagerduty_service":             resourcePagerDutyService(),
    39  			"pagerduty_service_integration": resourcePagerDutyServiceIntegration(),
    40  			"pagerduty_schedule":            resourcePagerDutySchedule(),
    41  			"pagerduty_escalation_policy":   resourcePagerDutyEscalationPolicy(),
    42  		},
    43  
    44  		ConfigureFunc: providerConfigure,
    45  	}
    46  }
    47  
    48  func providerConfigure(data *schema.ResourceData) (interface{}, error) {
    49  	config := Config{
    50  		Token:               data.Get("token").(string),
    51  		SkipCredsValidation: data.Get("skip_credentials_validation").(bool),
    52  	}
    53  
    54  	log.Println("[INFO] Initializing PagerDuty client")
    55  	return config.Client()
    56  }