github.com/dougneal/terraform@v0.6.15-0.20170330092735-b6a3840768a4/builtin/providers/github/provider.go (about) 1 package github 2 3 import ( 4 "github.com/hashicorp/terraform/helper/schema" 5 "github.com/hashicorp/terraform/terraform" 6 ) 7 8 // Provider returns a terraform.ResourceProvider. 9 func Provider() terraform.ResourceProvider { 10 11 // The actual provider 12 return &schema.Provider{ 13 Schema: map[string]*schema.Schema{ 14 "token": &schema.Schema{ 15 Type: schema.TypeString, 16 Required: true, 17 DefaultFunc: schema.EnvDefaultFunc("GITHUB_TOKEN", nil), 18 Description: descriptions["token"], 19 }, 20 "organization": &schema.Schema{ 21 Type: schema.TypeString, 22 Required: true, 23 DefaultFunc: schema.EnvDefaultFunc("GITHUB_ORGANIZATION", nil), 24 Description: descriptions["organization"], 25 }, 26 "base_url": &schema.Schema{ 27 Type: schema.TypeString, 28 Optional: true, 29 DefaultFunc: schema.EnvDefaultFunc("GITHUB_BASE_URL", ""), 30 Description: descriptions["base_url"], 31 }, 32 }, 33 34 ResourcesMap: map[string]*schema.Resource{ 35 "github_team": resourceGithubTeam(), 36 "github_team_membership": resourceGithubTeamMembership(), 37 "github_team_repository": resourceGithubTeamRepository(), 38 "github_membership": resourceGithubMembership(), 39 "github_repository": resourceGithubRepository(), 40 "github_repository_webhook": resourceGithubRepositoryWebhook(), 41 "github_organization_webhook": resourceGithubOrganizationWebhook(), 42 "github_repository_collaborator": resourceGithubRepositoryCollaborator(), 43 "github_issue_label": resourceGithubIssueLabel(), 44 }, 45 46 ConfigureFunc: providerConfigure, 47 } 48 } 49 50 var descriptions map[string]string 51 52 func init() { 53 descriptions = map[string]string{ 54 "token": "The OAuth token used to connect to GitHub.", 55 56 "organization": "The GitHub organization name to manage.", 57 58 "base_url": "The GitHub Base API URL", 59 } 60 } 61 62 func providerConfigure(d *schema.ResourceData) (interface{}, error) { 63 config := Config{ 64 Token: d.Get("token").(string), 65 Organization: d.Get("organization").(string), 66 BaseURL: d.Get("base_url").(string), 67 } 68 69 return config.Client() 70 }