Skip to content

Commit

Permalink
chore: deprecate VRA7_ environmental variables
Browse files Browse the repository at this point in the history
- Updates `reauthorize_timeout` to accept `VRA_INSECURE`, and `VRA7_INSECURE`. Use of `VRA7_INSECURE` will trigger the depreciation notice.
- Updates `insecure` to accept `VRA_REAUTHORIZE_TIMEOUT`, and `VRA7_REAUTHORIZE_TIMEOUT`. Use of `VRA7_REAUTHORIZE_TIMEOUT` will trigger the depreciation notice.
- Updates documentation.

Ref: #518

Signed-off-by: Ryan Johnson <[email protected]>
  • Loading branch information
tenthirtyam committed Jul 27, 2024
1 parent 5706c9b commit 4d52099
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
32 changes: 28 additions & 4 deletions vra/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package vra

import (
"errors"
"os"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/zclconf/go-cty/cty"
)

// Provider represents the VRA provider
func Provider() *schema.Provider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
Expand All @@ -32,15 +34,37 @@ func Provider() *schema.Provider {
},
"insecure": {
Type: schema.TypeBool,
DefaultFunc: schema.EnvDefaultFunc("VRA7_INSECURE", nil),
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"VRA_INSECURE", "VRA7_INSECURE"}, nil),
Optional: true,
Description: "Specify whether to validate TLS certificates.",
ValidateDiagFunc: func(val interface{}, path cty.Path) diag.Diagnostics {

Check failure on line 40 in vra/provider.go

View workflow job for this annotation

GitHub Actions / gotest

cannot use func(val interface{}, path cty.Path) diag.Diagnostics {…} (value of type func(val interface{}, path "github.com/zclconf/go-cty/cty".Path) "github.com/hashicorp/terraform-plugin-sdk/v2/diag".Diagnostics) as schema.SchemaValidateDiagFunc value in struct literal
var diags diag.Diagnostics
if envVar, ok := os.LookupEnv("VRA7_INSECURE"); ok && envVar != "" {
diags = append(diags, diag.Diagnostic{
Severity: diag.Warning,
Summary: "Deprecated environment variable.",
Detail: "The 'VRA7_INSECURE' environment variable is deprecated. Please use 'VRA_INSECURE' instead.",
})
}
return diags
},
},
"reauthorize_timeout": {
Type: schema.TypeString,
DefaultFunc: schema.EnvDefaultFunc("VRA7_REAUTHORIZE_TIMEOUT", nil),
DefaultFunc: envDefaultFunc("VRA_REAUTHORIZE_TIMEOUT", "VRA7_REAUTHORIZE_TIMEOUT"),

Check failure on line 54 in vra/provider.go

View workflow job for this annotation

GitHub Actions / gotest

undefined: envDefaultFunc
Optional: true,
Description: "Specify timeout for how often to reauthorize the access token",
Description: "Specify timeout for how often to reauthorize the access token.",
ValidateDiagFunc: func(val interface{}, path cty.Path) diag.Diagnostics {

Check failure on line 57 in vra/provider.go

View workflow job for this annotation

GitHub Actions / gotest

cannot use func(val interface{}, path cty.Path) diag.Diagnostics {…} (value of type func(val interface{}, path "github.com/zclconf/go-cty/cty".Path) "github.com/hashicorp/terraform-plugin-sdk/v2/diag".Diagnostics) as schema.SchemaValidateDiagFunc value in struct literal
var diags diag.Diagnostics
if envVar, ok := os.LookupEnv("VRA7_REAUTHORIZE_TIMEOUT"); ok && envVar != "" {
diags = append(diags, diag.Diagnostic{
Severity: diag.Warning,
Summary: "Deprecated environment variable.",
Detail: "The 'VRA7_REAUTHORIZE_TIMEOUT' environment variable is deprecated. Please use 'VRA_REAUTHORIZE_TIMEOUT' instead.",
})
}
return diags
},
},
"api_timeout": {
Type: schema.TypeInt,
Expand Down
12 changes: 6 additions & 6 deletions website/docs/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ Note that in all of the examples you will need to update attributes - such as `u

The following arguments are used to configure the Terraform Provider for VMware Aria Automation:

* `url` - (Required) This is the URL to the VMware Aria Automation endpoint. Can also be specified with the `VRA_URL` environment variable.
* `access_token` - (Optional) This is the access token used to create an API refresh token. Can also be specified with the `VRA_ACCESS_TOKEN` environment variable.
* `refresh_token` - (Optional) This is a refresh token used for API access that has been pre-generated. One of `access_token` or `refresh_token` is required. Can also be specified with the `VRA_REFRESH_TOKEN` environment variable.
* `insecure` - (Optional) This specifies whether if the TLS certificates are validated. Can also be specified with the `VRA7_INSECURE` environment variable.
* `reauthorize_timeout` - (Optional) This specifies the timeout for how often to reauthorize the access token. Can also be specified with the `VRA7_REAUTHORIZE_TIMEOUT` environment variable.
* `api_timeout` - (Optional) This specifies the timeout in seconds for API operations. Can also be specified with the `VRA_API_TIMEOUT` environment variable.
- `url` - (Required) This is the URL to the VMware Aria Automation endpoint. Can also be specified with the `VRA_URL` environment variable.
- `access_token` - (Optional) This is the access token used to create an API refresh token. Can also be specified with the `VRA_ACCESS_TOKEN` environment variable.
- `refresh_token` - (Optional) This is a refresh token used for API access that has been pre-generated. One of `access_token` or `refresh_token` is required. Can also be specified with the `VRA_REFRESH_TOKEN` environment variable.
- `insecure` - (Optional) This specifies whether if the TLS certificates are validated. Can also be specified with the `VRA_INSECURE` environment variable.
- `reauthorize_timeout` - (Optional) This specifies the timeout for how often to reauthorize the access token. Can also be specified with the `VRA_REAUTHORIZE_TIMEOUT` environment variable.
- `api_timeout` - (Optional) This specifies the timeout in seconds for API operations. Can also be specified with the `VRA_API_TIMEOUT` environment variable.

## Bug Reports and Contributing

Expand Down

0 comments on commit 4d52099

Please sign in to comment.