Merge pull request #29521 from hashicorp/alisdair/disable-experiment-warnings
configs: Disable experiment warnings at link time
This commit is contained in:
commit
a9dfe7ba7b
|
@ -9,6 +9,16 @@ import (
|
||||||
"github.com/zclconf/go-cty/cty"
|
"github.com/zclconf/go-cty/cty"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// When developing UI for experimental features, you can temporarily disable
|
||||||
|
// the experiment warning by setting this package-level variable to a non-empty
|
||||||
|
// value using a link-time flag:
|
||||||
|
//
|
||||||
|
// go install -ldflags="-X 'github.com/hashicorp/terraform/internal/configs.disableExperimentWarnings=yes'"
|
||||||
|
//
|
||||||
|
// This functionality is for development purposes only and is not a feature we
|
||||||
|
// are committing to supporting for end users.
|
||||||
|
var disableExperimentWarnings = ""
|
||||||
|
|
||||||
// sniffActiveExperiments does minimal parsing of the given body for
|
// sniffActiveExperiments does minimal parsing of the given body for
|
||||||
// "terraform" blocks with "experiments" attributes, returning the
|
// "terraform" blocks with "experiments" attributes, returning the
|
||||||
// experiments found.
|
// experiments found.
|
||||||
|
@ -126,17 +136,19 @@ func decodeExperimentsAttr(attr *hcl.Attribute) (experiments.Set, hcl.Diagnostic
|
||||||
// No error at all means it's valid and current.
|
// No error at all means it's valid and current.
|
||||||
ret.Add(exp)
|
ret.Add(exp)
|
||||||
|
|
||||||
// However, experimental features are subject to breaking changes
|
if disableExperimentWarnings == "" {
|
||||||
// in future releases, so we'll warn about them to help make sure
|
// However, experimental features are subject to breaking changes
|
||||||
// folks aren't inadvertently using them in places where that'd be
|
// in future releases, so we'll warn about them to help make sure
|
||||||
// inappropriate, particularly if the experiment is active in a
|
// folks aren't inadvertently using them in places where that'd be
|
||||||
// shared module they depend on.
|
// inappropriate, particularly if the experiment is active in a
|
||||||
diags = diags.Append(&hcl.Diagnostic{
|
// shared module they depend on.
|
||||||
Severity: hcl.DiagWarning,
|
diags = diags.Append(&hcl.Diagnostic{
|
||||||
Summary: fmt.Sprintf("Experimental feature %q is active", exp.Keyword()),
|
Severity: hcl.DiagWarning,
|
||||||
Detail: "Experimental features are subject to breaking changes in future minor or patch releases, based on feedback.\n\nIf you have feedback on the design of this feature, please open a GitHub issue to discuss it.",
|
Summary: fmt.Sprintf("Experimental feature %q is active", exp.Keyword()),
|
||||||
Subject: expr.Range().Ptr(),
|
Detail: "Experimental features are subject to breaking changes in future minor or patch releases, based on feedback.\n\nIf you have feedback on the design of this feature, please open a GitHub issue to discuss it.",
|
||||||
})
|
Subject: expr.Range().Ptr(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// This should never happen, because GetCurrent is not documented
|
// This should never happen, because GetCurrent is not documented
|
||||||
|
|
Loading…
Reference in New Issue