2016-10-19 16:25:12 +02:00
|
|
|
package gitlab
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
|
|
"github.com/hashicorp/terraform/terraform"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Provider returns a terraform.ResourceProvider.
|
|
|
|
func Provider() terraform.ResourceProvider {
|
|
|
|
|
|
|
|
// The actual provider
|
|
|
|
return &schema.Provider{
|
|
|
|
Schema: map[string]*schema.Schema{
|
2017-04-26 19:44:05 +02:00
|
|
|
"token": {
|
2016-10-19 16:25:12 +02:00
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("GITLAB_TOKEN", nil),
|
|
|
|
Description: descriptions["token"],
|
|
|
|
},
|
2017-04-26 19:44:05 +02:00
|
|
|
"base_url": {
|
2016-10-19 16:25:12 +02:00
|
|
|
Type: schema.TypeString,
|
|
|
|
Optional: true,
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("GITLAB_BASE_URL", ""),
|
|
|
|
Description: descriptions["base_url"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ResourcesMap: map[string]*schema.Resource{
|
|
|
|
"gitlab_project": resourceGitlabProject(),
|
|
|
|
},
|
|
|
|
|
|
|
|
ConfigureFunc: providerConfigure,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var descriptions map[string]string
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
descriptions = map[string]string{
|
|
|
|
"token": "The OAuth token used to connect to GitLab.",
|
|
|
|
|
|
|
|
"base_url": "The GitLab Base API URL",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
|
|
|
|
config := Config{
|
|
|
|
Token: d.Get("token").(string),
|
|
|
|
BaseURL: d.Get("base_url").(string),
|
|
|
|
}
|
|
|
|
|
|
|
|
return config.Client()
|
|
|
|
}
|