55 lines
1.3 KiB
Go
55 lines
1.3 KiB
Go
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{
|
|
"token": {
|
|
Type: schema.TypeString,
|
|
Required: true,
|
|
DefaultFunc: schema.EnvDefaultFunc("GITLAB_TOKEN", nil),
|
|
Description: descriptions["token"],
|
|
},
|
|
"base_url": {
|
|
Type: schema.TypeString,
|
|
Optional: true,
|
|
DefaultFunc: schema.EnvDefaultFunc("GITLAB_BASE_URL", ""),
|
|
Description: descriptions["base_url"],
|
|
},
|
|
},
|
|
ResourcesMap: map[string]*schema.Resource{
|
|
"gitlab_project": resourceGitlabProject(),
|
|
"gitlab_project_hook": resourceGitlabProjectHook(),
|
|
"gitlab_deploy_key": resourceGitlabDeployKey(),
|
|
},
|
|
|
|
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()
|
|
}
|