github.com/andresvia/terraform@v0.6.15-0.20160412045437-d51c75946785/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 }, 27 28 ResourcesMap: map[string]*schema.Resource{ 29 "github_team": resourceGithubTeam(), 30 "github_team_membership": resourceGithubTeamMembership(), 31 "github_team_repository": resourceGithubTeamRepository(), 32 "github_membership": resourceGithubMembership(), 33 }, 34 35 ConfigureFunc: providerConfigure, 36 } 37 } 38 39 var descriptions map[string]string 40 41 func init() { 42 descriptions = map[string]string{ 43 "token": "The OAuth token used to connect to GitHub.", 44 45 "organization": "The GitHub organization name to manage.", 46 } 47 } 48 49 func providerConfigure(d *schema.ResourceData) (interface{}, error) { 50 config := Config{ 51 Token: d.Get("token").(string), 52 Organization: d.Get("organization").(string), 53 } 54 55 return config.Client() 56 }