/
provider.go
44 lines (41 loc) · 1.36 KB
/
provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package circleci
import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
)
func Provider() terraform.ResourceProvider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"api_token": {
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("CIRCLECI_TOKEN", nil),
Description: "The token key for API operations.",
},
"vcs_type": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("CIRCLECI_VCS_TYPE", "github"),
Description: "The VCS type for the organization.",
},
"organization": {
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("CIRCLECI_ORGANIZATION", nil),
Description: "The CircleCI organization.",
},
},
ResourcesMap: map[string]*schema.Resource{
"circleci_environment_variable": resourceCircleCIEnvironmentVariable(),
"circleci_project": resourceCircleCIProject(),
"circleci_ssh_key": resourceCircleCISSHKey(),
},
ConfigureFunc: providerConfigure,
}
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
token := d.Get("api_token").(string)
vcsType := d.Get("vcs_type").(string)
organization := d.Get("organization").(string)
return NewConfig(token, vcsType, organization), nil
}