This repository has been archived by the owner on Dec 1, 2022. It is now read-only.
/
provider.go
50 lines (47 loc) · 1.6 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
45
46
47
48
49
50
package harbor
import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)
func Provider() terraform.ResourceProvider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"host": {
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("HARBOR_HOST", nil),
Description: "The hostname (in form of URI) of the Harbor server.",
},
"username": {
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("HARBOR_USERNAME", nil),
Description: "The username to use for HTTP basic authentication when accessing the Harbor server.",
},
"password": {
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("HARBOR_PASSWORD", nil),
Description: "The password to use for HTTP basic authentication when accessing the Harbor server.",
},
},
ResourcesMap: map[string]*schema.Resource{
"harbor_project": resourceHarborProject(),
"harbor_project_robot_account": resourceHarborProjectRobotAccount(),
"harbor_project_member": resourceHarborProjectMember(),
},
DataSourcesMap: map[string]*schema.Resource{
"harbor_system_info": dataSourceHarborSystemInfo(),
"harbor_project": dataSourceHarborProject(),
},
ConfigureFunc: providerConfigure,
}
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
cfg := &Config{
Host: d.Get("host").(string),
Username: d.Get("username").(string),
Password: d.Get("password").(string),
}
return cfg.Config()
}