github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/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 "github_branch_protection": resourceGithubBranchProtection(), 45 }, 46 47 ConfigureFunc: providerConfigure, 48 } 49 } 50 51 var descriptions map[string]string 52 53 func init() { 54 descriptions = map[string]string{ 55 "token": "The OAuth token used to connect to GitHub.", 56 57 "organization": "The GitHub organization name to manage.", 58 59 "base_url": "The GitHub Base API URL", 60 } 61 } 62 63 func providerConfigure(d *schema.ResourceData) (interface{}, error) { 64 config := Config{ 65 Token: d.Get("token").(string), 66 Organization: d.Get("organization").(string), 67 BaseURL: d.Get("base_url").(string), 68 } 69 70 return config.Client() 71 }