github.com/richardbowden/terraform@v0.6.12-0.20160901200758-30ea22c25211/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_collaborator": resourceGithubRepositoryCollaborator(), 40 }, 41 42 ConfigureFunc: providerConfigure, 43 } 44 } 45 46 var descriptions map[string]string 47 48 func init() { 49 descriptions = map[string]string{ 50 "token": "The OAuth token used to connect to GitHub.", 51 52 "organization": "The GitHub organization name to manage.", 53 54 "base_url": "The GitHub Base API URL", 55 } 56 } 57 58 func providerConfigure(d *schema.ResourceData) (interface{}, error) { 59 config := Config{ 60 Token: d.Get("token").(string), 61 Organization: d.Get("organization").(string), 62 BaseURL: d.Get("base_url").(string), 63 } 64 65 return config.Client() 66 }