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{
|
|
|
|
"github_team": resourceGithubTeam(),
|
|
|
|
"github_team_membership": resourceGithubTeamMembership(),
|
|
|
|
"github_team_repository": resourceGithubTeamRepository(),
|
|
|
|
"github_membership": resourceGithubMembership(),
|
|
|
|
},
|
|
|
|
|
|
|
|
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()
|
|
|
|
}
|