2016-03-08 23:05:22 +01:00
|
|
|
package github
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
|
|
"github.com/hashicorp/terraform/terraform"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Provider returns a terraform.ResourceProvider.
|
|
|
|
func Provider() terraform.ResourceProvider {
|
|
|
|
|
|
|
|
// The actual provider
|
|
|
|
return &schema.Provider{
|
|
|
|
Schema: map[string]*schema.Schema{
|
|
|
|
"token": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("GITHUB_TOKEN", nil),
|
|
|
|
Description: descriptions["token"],
|
|
|
|
},
|
|
|
|
"organization": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("GITHUB_ORGANIZATION", nil),
|
|
|
|
Description: descriptions["organization"],
|
|
|
|
},
|
2016-05-09 20:22:53 +02:00
|
|
|
"base_url": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Optional: true,
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("GITHUB_BASE_URL", ""),
|
|
|
|
Description: descriptions["base_url"],
|
|
|
|
},
|
2016-03-08 23:05:22 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
ResourcesMap: map[string]*schema.Resource{
|
2016-06-02 02:06:35 +02:00
|
|
|
"github_team": resourceGithubTeam(),
|
|
|
|
"github_team_membership": resourceGithubTeamMembership(),
|
|
|
|
"github_team_repository": resourceGithubTeamRepository(),
|
|
|
|
"github_membership": resourceGithubMembership(),
|
2016-10-11 19:05:38 +02:00
|
|
|
"github_repository": resourceGithubRepository(),
|
2017-03-23 10:21:45 +01:00
|
|
|
"github_repository_webhook": resourceGithubRepositoryWebhook(),
|
|
|
|
"github_organization_webhook": resourceGithubOrganizationWebhook(),
|
2016-06-02 02:06:35 +02:00
|
|
|
"github_repository_collaborator": resourceGithubRepositoryCollaborator(),
|
2016-11-18 12:24:37 +01:00
|
|
|
"github_issue_label": resourceGithubIssueLabel(),
|
2017-04-20 20:11:49 +02:00
|
|
|
"github_branch_protection": resourceGithubBranchProtection(),
|
2016-03-08 23:05:22 +01:00
|
|
|
},
|
|
|
|
|
2017-05-17 11:38:23 +02:00
|
|
|
DataSourcesMap: map[string]*schema.Resource{
|
|
|
|
"github_user": dataSourceGithubUser(),
|
2017-05-22 15:29:18 +02:00
|
|
|
"github_team": dataSourceGithubTeam(),
|
2017-05-17 11:38:23 +02:00
|
|
|
},
|
|
|
|
|
2016-03-08 23:05:22 +01:00
|
|
|
ConfigureFunc: providerConfigure,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var descriptions map[string]string
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
descriptions = map[string]string{
|
|
|
|
"token": "The OAuth token used to connect to GitHub.",
|
|
|
|
|
|
|
|
"organization": "The GitHub organization name to manage.",
|
2016-05-09 20:22:53 +02:00
|
|
|
|
|
|
|
"base_url": "The GitHub Base API URL",
|
2016-03-08 23:05:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
|
|
|
|
config := Config{
|
|
|
|
Token: d.Get("token").(string),
|
|
|
|
Organization: d.Get("organization").(string),
|
2016-05-09 20:22:53 +02:00
|
|
|
BaseURL: d.Get("base_url").(string),
|
2016-03-08 23:05:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return config.Client()
|
|
|
|
}
|