Improve beta documentation (#414)
* replace BETA with beta * improve beta error text * remove reference to guide
This commit is contained in:
parent
a07ff3f9ba
commit
50d74e6695
2 changed files with 8 additions and 8 deletions
|
|
@ -69,15 +69,15 @@ func LogAndAddWarning(ctx context.Context, diags *diag.Diagnostics, summary, det
|
|||
}
|
||||
|
||||
func LogAndAddWarningBeta(ctx context.Context, diags *diag.Diagnostics, name string) {
|
||||
warnTitle := fmt.Sprintf("The resource %q is in BETA", name)
|
||||
warnContent := fmt.Sprintf("The resource %q is in BETA and may be subject to breaking changes in the future. Use with caution.", name)
|
||||
warnTitle := fmt.Sprintf("The resource %q is in beta", name)
|
||||
warnContent := fmt.Sprintf("The resource %q is in beta and may be subject to breaking changes in the future. Use with caution.", name)
|
||||
tflog.Warn(ctx, fmt.Sprintf("%s | %s", warnTitle, warnContent))
|
||||
diags.AddWarning(warnTitle, warnContent)
|
||||
}
|
||||
|
||||
func LogAndAddErrorBeta(ctx context.Context, diags *diag.Diagnostics, name string) {
|
||||
errTitle := fmt.Sprintf("The resource %q is in BETA and BETA is not enabled", name)
|
||||
errContent := fmt.Sprintf("The resource %q is in BETA and the BETA functionality is currently not enabled. Please refer to the documentation on how to enable the BETA functionality.", name)
|
||||
errTitle := fmt.Sprintf("The resource %q is in beta and beta is not enabled", name)
|
||||
errContent := fmt.Sprintf(`The resource %q is in beta and the beta functionality is currently not enabled. To enable it, set the environment variable STACKIT_TF_ENABLE_BETA_RESOURCES to "true" or set the "enable_beta_resources" provider field to true.`, name)
|
||||
tflog.Error(ctx, fmt.Sprintf("%s | %s", errTitle, errContent))
|
||||
diags.AddError(errTitle, errContent)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
|
||||
)
|
||||
|
||||
// BetaResourcesEnabled returns whether this provider has BETA functionality enabled.
|
||||
// BetaResourcesEnabled returns whether this provider has beta functionality enabled.
|
||||
//
|
||||
// In order of precedence, beta functionality can be managed by:
|
||||
// - Environment Variable `STACKIT_TF_ENABLE_BETA_RESOURCES` - `true` is enabled, `false` is disabled.
|
||||
|
|
@ -24,7 +24,7 @@ func BetaResourcesEnabled(ctx context.Context, data *core.ProviderData, diags *d
|
|||
if strings.EqualFold(value, "false") {
|
||||
return false
|
||||
}
|
||||
warnDetails := fmt.Sprintf(`The value of the environment variable that enables BETA functionality must be either "true" or "false", got %q.
|
||||
warnDetails := fmt.Sprintf(`The value of the environment variable that enables beta functionality must be either "true" or "false", got %q.
|
||||
Defaulting to the provider feature flag.`, value)
|
||||
core.LogAndAddWarning(ctx, diags, "Invalid value for STACKIT_TF_ENABLE_BETA_RESOURCES environment variable.", warnDetails)
|
||||
}
|
||||
|
|
@ -35,9 +35,9 @@ Defaulting to the provider feature flag.`, value)
|
|||
return data.EnableBetaResources
|
||||
}
|
||||
|
||||
// CheckBetaResourcesEnabled is a helper function to log and add a warning or error if the BETA functionality is not enabled.
|
||||
// CheckBetaResourcesEnabled is a helper function to log and add a warning or error if the beta functionality is not enabled.
|
||||
//
|
||||
// Should be called in the Configure method of a BETA resource.
|
||||
// Should be called in the Configure method of a beta resource.
|
||||
// Then, check for Errors in the diags using the diags.HasError() method.
|
||||
func CheckBetaResourcesEnabled(ctx context.Context, data *core.ProviderData, diags *diag.Diagnostics, resourceName string) {
|
||||
if !BetaResourcesEnabled(ctx, data, diags) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue