mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-03-13 01:00:50 -04:00
``` % make testacc TEST=./builtin/providers/gitlab ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2017/04/27 05:37:02 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/gitlab -v -timeout 120m === RUN TestProvider --- PASS: TestProvider (0.00s) === RUN TestProvider_impl --- PASS: TestProvider_impl (0.00s) === RUN TestAccGitlabProject_basic --- PASS: TestAccGitlabProject_basic (41.11s) === RUN TestGitlab_validation --- PASS: TestGitlab_validation (0.00s) === RUN TestGitlab_visbilityHelpers --- PASS: TestGitlab_visbilityHelpers (0.00s) PASS ok github.com/hashicorp/terraform/builtin/providers/gitlab 41.125s ```
53 lines
1.2 KiB
Go
53 lines
1.2 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(),
|
|
},
|
|
|
|
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()
|
|
}
|