2016-09-23 21:43:06 +02:00
|
|
|
package pagerduty
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
|
|
"github.com/hashicorp/terraform/terraform"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Provider represents a resource provider in Terraform
|
|
|
|
func Provider() terraform.ResourceProvider {
|
|
|
|
return &schema.Provider{
|
|
|
|
Schema: map[string]*schema.Schema{
|
2016-10-24 16:43:53 +02:00
|
|
|
"token": {
|
2016-09-23 21:43:06 +02:00
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("PAGERDUTY_TOKEN", nil),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2016-10-18 23:43:25 +02:00
|
|
|
DataSourcesMap: map[string]*schema.Resource{
|
2016-12-05 23:42:58 +01:00
|
|
|
"pagerduty_user": dataSourcePagerDutyUser(),
|
2016-10-20 06:53:51 +02:00
|
|
|
"pagerduty_vendor": dataSourcePagerDutyVendor(),
|
2016-10-18 23:43:25 +02:00
|
|
|
},
|
|
|
|
|
2016-09-23 21:43:06 +02:00
|
|
|
ResourcesMap: map[string]*schema.Resource{
|
2016-10-16 13:18:06 +02:00
|
|
|
"pagerduty_user": resourcePagerDutyUser(),
|
|
|
|
"pagerduty_team": resourcePagerDutyTeam(),
|
|
|
|
"pagerduty_service": resourcePagerDutyService(),
|
|
|
|
"pagerduty_service_integration": resourcePagerDutyServiceIntegration(),
|
|
|
|
"pagerduty_schedule": resourcePagerDutySchedule(),
|
|
|
|
"pagerduty_escalation_policy": resourcePagerDutyEscalationPolicy(),
|
2016-09-23 21:43:06 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
ConfigureFunc: providerConfigure,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func providerConfigure(data *schema.ResourceData) (interface{}, error) {
|
2016-10-20 06:53:51 +02:00
|
|
|
config := Config{Token: data.Get("token").(string)}
|
2016-09-23 21:43:06 +02:00
|
|
|
log.Println("[INFO] Initializing PagerDuty client")
|
|
|
|
return config.Client()
|
|
|
|
}
|