|
|
|
|
@ -17,71 +17,113 @@ func Provider() terraform.ResourceProvider {
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Required: true,
|
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("OS_AUTH_URL", nil),
|
|
|
|
|
Description: descriptions["auth_url"],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
"user_name": &schema.Schema{
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("OS_USERNAME", ""),
|
|
|
|
|
Description: descriptions["user_name"],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
"user_id": &schema.Schema{
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
Default: "",
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("OS_USER_ID", ""),
|
|
|
|
|
Description: descriptions["user_name"],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
"tenant_id": &schema.Schema{
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
Default: "",
|
|
|
|
|
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
|
|
|
|
|
"OS_TENANT_ID",
|
|
|
|
|
"OS_PROJECT_ID",
|
|
|
|
|
}, ""),
|
|
|
|
|
Description: descriptions["tenant_id"],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
"tenant_name": &schema.Schema{
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("OS_TENANT_NAME", nil),
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
|
|
|
|
|
"OS_TENANT_NAME",
|
|
|
|
|
"OS_PROJECT_NAME",
|
|
|
|
|
}, ""),
|
|
|
|
|
Description: descriptions["tenant_name"],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
"password": &schema.Schema{
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
Sensitive: true,
|
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("OS_PASSWORD", ""),
|
|
|
|
|
Description: descriptions["password"],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
"token": &schema.Schema{
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("OS_AUTH_TOKEN", ""),
|
|
|
|
|
Description: descriptions["token"],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
"domain_id": &schema.Schema{
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("OS_DOMAIN_ID", ""),
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
|
|
|
|
|
"OS_USER_DOMAIN_ID",
|
|
|
|
|
"OS_PROJECT_DOMAIN_ID",
|
|
|
|
|
"OS_DOMAIN_ID",
|
|
|
|
|
}, ""),
|
|
|
|
|
Description: descriptions["domain_id"],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
"domain_name": &schema.Schema{
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("OS_DOMAIN_NAME", ""),
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
|
|
|
|
|
"OS_USER_DOMAIN_NAME",
|
|
|
|
|
"OS_PROJECT_DOMAIN_NAME",
|
|
|
|
|
"OS_DOMAIN_NAME",
|
|
|
|
|
"OS_DEFAULT_DOMAIN",
|
|
|
|
|
}, ""),
|
|
|
|
|
Description: descriptions["domain_name"],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
"insecure": &schema.Schema{
|
|
|
|
|
Type: schema.TypeBool,
|
|
|
|
|
Optional: true,
|
|
|
|
|
Default: false,
|
|
|
|
|
Type: schema.TypeBool,
|
|
|
|
|
Optional: true,
|
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("OS_INSECURE", ""),
|
|
|
|
|
Description: descriptions["insecure"],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
"endpoint_type": &schema.Schema{
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("OS_ENDPOINT_TYPE", ""),
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
"cacert_file": &schema.Schema{
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("OS_CACERT", ""),
|
|
|
|
|
Description: descriptions["cacert_file"],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
"cert": &schema.Schema{
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("OS_CERT", ""),
|
|
|
|
|
Description: descriptions["cert"],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
"key": &schema.Schema{
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Optional: true,
|
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("OS_KEY", ""),
|
|
|
|
|
Description: descriptions["key"],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
@ -121,22 +163,58 @@ func Provider() terraform.ResourceProvider {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var descriptions map[string]string
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
descriptions = map[string]string{
|
|
|
|
|
"auth_url": "The Identity authentication URL.",
|
|
|
|
|
|
|
|
|
|
"user_name": "Username to login with.",
|
|
|
|
|
|
|
|
|
|
"user_id": "User ID to login with.",
|
|
|
|
|
|
|
|
|
|
"tenant_id": "The ID of the Tenant (Identity v2) or Project (Identity v3)\n" +
|
|
|
|
|
"to login with.",
|
|
|
|
|
|
|
|
|
|
"tenant_name": "The name of the Tenant (Identity v2) or Project (Identity v3)\n" +
|
|
|
|
|
"to login with.",
|
|
|
|
|
|
|
|
|
|
"password": "Password to login with.",
|
|
|
|
|
|
|
|
|
|
"token": "Authentication token to use as an alternative to username/password.",
|
|
|
|
|
|
|
|
|
|
"domain_id": "The ID of the Domain to scope to (Identity v3).",
|
|
|
|
|
|
|
|
|
|
"domain_name": "The name of the Domain to scope to (Identity v3).",
|
|
|
|
|
|
|
|
|
|
"insecure": "Trust self-signed certificates.",
|
|
|
|
|
|
|
|
|
|
"cacert_file": "A Custom CA certificate.",
|
|
|
|
|
|
|
|
|
|
"endpoint_type": "The catalog endpoint type to use.",
|
|
|
|
|
|
|
|
|
|
"cert": "A client certificate to authenticate with.",
|
|
|
|
|
|
|
|
|
|
"key": "A client private key to authenticate with.",
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func configureProvider(d *schema.ResourceData) (interface{}, error) {
|
|
|
|
|
config := Config{
|
|
|
|
|
CACertFile: d.Get("cacert_file").(string),
|
|
|
|
|
ClientCertFile: d.Get("cert").(string),
|
|
|
|
|
ClientKeyFile: d.Get("key").(string),
|
|
|
|
|
DomainID: d.Get("domain_id").(string),
|
|
|
|
|
DomainName: d.Get("domain_name").(string),
|
|
|
|
|
EndpointType: d.Get("endpoint_type").(string),
|
|
|
|
|
IdentityEndpoint: d.Get("auth_url").(string),
|
|
|
|
|
Username: d.Get("user_name").(string),
|
|
|
|
|
UserID: d.Get("user_id").(string),
|
|
|
|
|
Insecure: d.Get("insecure").(bool),
|
|
|
|
|
Password: d.Get("password").(string),
|
|
|
|
|
Token: d.Get("token").(string),
|
|
|
|
|
TenantID: d.Get("tenant_id").(string),
|
|
|
|
|
TenantName: d.Get("tenant_name").(string),
|
|
|
|
|
DomainID: d.Get("domain_id").(string),
|
|
|
|
|
DomainName: d.Get("domain_name").(string),
|
|
|
|
|
Insecure: d.Get("insecure").(bool),
|
|
|
|
|
EndpointType: d.Get("endpoint_type").(string),
|
|
|
|
|
CACertFile: d.Get("cacert_file").(string),
|
|
|
|
|
ClientCertFile: d.Get("cert").(string),
|
|
|
|
|
ClientKeyFile: d.Get("key").(string),
|
|
|
|
|
Username: d.Get("user_name").(string),
|
|
|
|
|
UserID: d.Get("user_id").(string),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := config.loadAndValidate(); err != nil {
|
|
|
|
|
|