terraform/builtin/providers/pagerduty/provider.go

44 lines
1.3 KiB
Go
Raw Normal View History

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{
"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{
"pagerduty_user": dataSourcePagerDutyUser(),
"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) {
config := Config{Token: data.Get("token").(string)}
2016-09-23 21:43:06 +02:00
log.Println("[INFO] Initializing PagerDuty client")
return config.Client()
}