github.com/koding/terraform@v0.6.4-0.20170608090606-5d7e0339779d/builtin/providers/gitlab/provider.go (about) 1 package gitlab 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": { 15 Type: schema.TypeString, 16 Required: true, 17 DefaultFunc: schema.EnvDefaultFunc("GITLAB_TOKEN", nil), 18 Description: descriptions["token"], 19 }, 20 "base_url": { 21 Type: schema.TypeString, 22 Optional: true, 23 DefaultFunc: schema.EnvDefaultFunc("GITLAB_BASE_URL", ""), 24 Description: descriptions["base_url"], 25 }, 26 }, 27 ResourcesMap: map[string]*schema.Resource{ 28 "gitlab_group": resourceGitlabGroup(), 29 "gitlab_project": resourceGitlabProject(), 30 "gitlab_project_hook": resourceGitlabProjectHook(), 31 "gitlab_deploy_key": resourceGitlabDeployKey(), 32 }, 33 34 ConfigureFunc: providerConfigure, 35 } 36 } 37 38 var descriptions map[string]string 39 40 func init() { 41 descriptions = map[string]string{ 42 "token": "The OAuth token used to connect to GitLab.", 43 44 "base_url": "The GitLab Base API URL", 45 } 46 } 47 48 func providerConfigure(d *schema.ResourceData) (interface{}, error) { 49 config := Config{ 50 Token: d.Get("token").(string), 51 BaseURL: d.Get("base_url").(string), 52 } 53 54 return config.Client() 55 }