build: Use Go 1.19

Go 1.19's "fmt" has some awareness of the new doc comment formatting
conventions and adjusts the presentation of the source comments to make
it clearer how godoc would interpret them. Therefore this commit includes
various updates made by "go fmt" to acheve that.

In line with our usual convention that we make stylistic/grammar/spelling
tweaks typically only when we're "in the area" changing something else
anyway, I also took this opportunity to review most of the comments that
this updated to see if there were any other opportunities to improve them.
This commit is contained in:
Martin Atkins 2022-08-17 11:46:02 -07:00
parent 023ab3207f
commit 783a07d9e8
38 changed files with 190 additions and 172 deletions

View File

@ -1 +1 @@
1.18.1
1.19.0

View File

@ -3,7 +3,8 @@ package main
// experimentsAllowed can be set to any non-empty string using Go linker
// arguments in order to enable the use of experimental features for a
// particular Terraform build:
// go install -ldflags="-X 'main.experimentsAllowed=yes'"
//
// go install -ldflags="-X 'main.experimentsAllowed=yes'"
//
// By default this variable is initialized as empty, in which case
// experimental features are not available.

View File

@ -59,9 +59,10 @@ func (c checkable) checkableSigil() {
}
// CheckType describes the category of check.
//go:generate go run golang.org/x/tools/cmd/stringer -type=CheckType check.go
type CheckType int
//go:generate go run golang.org/x/tools/cmd/stringer -type=CheckType check.go
const (
InvalidCondition CheckType = 0
ResourcePrecondition CheckType = 1

View File

@ -112,14 +112,16 @@ func NewLegacyProvider(name string) Provider {
}
}
// ParseProviderSourceString parses the source attribute and returns a provider.
// This is intended primarily to parse the FQN-like strings returned by
// terraform-config-inspect.
// ParseProviderSourceString parses a value of the form expected in the "source"
// argument of a required_providers entry and returns the corresponding
// fully-qualified provider address. This is intended primarily to parse the
// FQN-like strings returned by terraform-config-inspect.
//
// The following are valid source string formats:
// name
// namespace/name
// hostname/namespace/name
//
// - name
// - namespace/name
// - hostname/namespace/name
func ParseProviderSourceString(str string) (tfaddr.Provider, tfdiags.Diagnostics) {
var diags tfdiags.Diagnostics

View File

@ -95,18 +95,18 @@ type AbsProviderConfig struct {
var _ ProviderConfig = AbsProviderConfig{}
// ParseAbsProviderConfig parses the given traversal as an absolute provider
// address. The following are examples of traversals that can be successfully
// parsed as absolute provider configuration addresses:
// configuration address. The following are examples of traversals that can be
// successfully parsed as absolute provider configuration addresses:
//
// provider["registry.terraform.io/hashicorp/aws"]
// provider["registry.terraform.io/hashicorp/aws"].foo
// module.bar.provider["registry.terraform.io/hashicorp/aws"]
// module.bar.module.baz.provider["registry.terraform.io/hashicorp/aws"].foo
// - provider["registry.terraform.io/hashicorp/aws"]
// - provider["registry.terraform.io/hashicorp/aws"].foo
// - module.bar.provider["registry.terraform.io/hashicorp/aws"]
// - module.bar.module.baz.provider["registry.terraform.io/hashicorp/aws"].foo
//
// This type of address is used, for example, to record the relationships
// between resources and provider configurations in the state structure.
// This type of address is not generally used in the UI, except in error
// messages that refer to provider configurations.
// This type of address is typically not used prominently in the UI, except in
// error messages that refer to provider configurations.
func ParseAbsProviderConfig(traversal hcl.Traversal) (AbsProviderConfig, tfdiags.Diagnostics) {
modInst, remain, diags := parseModuleInstancePrefix(traversal)
var ret AbsProviderConfig
@ -230,17 +230,22 @@ func ParseLegacyAbsProviderConfigStr(str string) (AbsProviderConfig, tfdiags.Dia
}
// ParseLegacyAbsProviderConfig parses the given traversal as an absolute
// provider address. The following are examples of traversals that can be
// successfully parsed as legacy absolute provider configuration addresses:
// provider address in the legacy form used by Terraform v0.12 and earlier.
// The following are examples of traversals that can be successfully parsed as
// legacy absolute provider configuration addresses:
//
// provider.aws
// provider.aws.foo
// module.bar.provider.aws
// module.bar.module.baz.provider.aws.foo
// - provider.aws
// - provider.aws.foo
// - module.bar.provider.aws
// - module.bar.module.baz.provider.aws.foo
//
// This type of address is used in legacy state and may appear in state v4 if
// the provider config addresses have not been normalized to include provider
// FQN.
// We can encounter this kind of address in a historical state snapshot that
// hasn't yet been upgraded by refreshing or applying a plan with
// Terraform v0.13. Later versions of Terraform reject state snapshots using
// this format, and so users must follow the Terraform v0.13 upgrade guide
// in that case.
//
// We will not use this address form for any new file formats.
func ParseLegacyAbsProviderConfig(traversal hcl.Traversal) (AbsProviderConfig, tfdiags.Diagnostics) {
modInst, remain, diags := parseModuleInstancePrefix(traversal)
var ret AbsProviderConfig
@ -383,12 +388,12 @@ func (pc AbsProviderConfig) LegacyString() string {
return fmt.Sprintf("%s.%s.%s", pc.Module.String(), "provider", pc.Provider.LegacyString())
}
// String() returns a string representation of an AbsProviderConfig in the following format:
// String() returns a string representation of an AbsProviderConfig in a format like the following examples:
//
// provider["example.com/namespace/name"]
// provider["example.com/namespace/name"].alias
// module.module-name.provider["example.com/namespace/name"]
// module.module-name.provider["example.com/namespace/name"].alias
// - provider["example.com/namespace/name"]
// - provider["example.com/namespace/name"].alias
// - module.module-name.provider["example.com/namespace/name"]
// - module.module-name.provider["example.com/namespace/name"].alias
func (pc AbsProviderConfig) String() string {
var parts []string
if len(pc.Module) > 0 {

View File

@ -920,6 +920,7 @@ func (b *Cloud) IsLocalOperations() bool {
// as a helper to wrap any potentially colored strings.
//
// TODO SvH: Rename this back to Colorize as soon as we can pass -no-color.
//
//lint:ignore U1000 see above todo
func (b *Cloud) cliColorize() *colorstring.Colorize {
if b.CLIColor != nil {

View File

@ -294,9 +294,9 @@ type ProviderInstallationMethod struct {
// different installation location types. The concrete implementations of
// this interface are:
//
// ProviderInstallationDirect: install from the provider's origin registry
// ProviderInstallationFilesystemMirror(dir): install from a local filesystem mirror
// ProviderInstallationNetworkMirror(host): install from a network mirror
// - [ProviderInstallationDirect]: install from the provider's origin registry
// - [ProviderInstallationFilesystemMirror] (dir): install from a local filesystem mirror
// - [ProviderInstallationNetworkMirror] (host): install from a network mirror
type ProviderInstallationLocation interface {
providerInstallationLocation()
}

View File

@ -84,7 +84,7 @@ func TestMain(m *testing.M) {
// tempWorkingDir constructs a workdir.Dir object referring to a newly-created
// temporary directory. The temporary directory is automatically removed when
//the test and all its subtests complete.
// the test and all its subtests complete.
//
// Although workdir.Dir is built to support arbitrary base directories, the
// not-yet-migrated behaviors in command.Meta tend to expect the root module
@ -92,8 +92,8 @@ func TestMain(m *testing.M) {
// to use the result inside a command.Meta object you must use a pattern
// similar to the following when initializing your test:
//
// wd := tempWorkingDir(t)
// defer testChdir(t, wd.RootModuleDir())()
// wd := tempWorkingDir(t)
// defer testChdir(t, wd.RootModuleDir())()
//
// Note that testChdir modifies global state for the test process, and so a
// test using this pattern must never call t.Parallel().
@ -327,9 +327,9 @@ func testStateMgrCurrentLineage(mgr statemgr.Persistent) string {
// The given mark string is returned verbatim, to allow the following pattern
// in tests:
//
// mark := markStateForMatching(state, "foo")
// // (do stuff to the state)
// assertStateHasMarker(state, mark)
// mark := markStateForMatching(state, "foo")
// // (do stuff to the state)
// assertStateHasMarker(state, mark)
func markStateForMatching(state *states.State, mark string) string {
state.RootModule().SetOutputValue("testing_mark", cty.StringVal(mark), false)
return mark
@ -704,10 +704,10 @@ func testInputMap(t *testing.T, answers map[string]string) func() {
// When using this function, the configuration fixture for the test must
// include an empty configuration block for the HTTP backend, like this:
//
// terraform {
// backend "http" {
// }
// }
// terraform {
// backend "http" {
// }
// }
//
// If such a block isn't present, or if it isn't empty, then an error will
// be returned about the backend configuration having changed and that

View File

@ -1,5 +1,5 @@
// Package e2etest contains a small number of tests that run against a real
// Terraform binary, compiled on the fly at the start of the test run.
// Package e2etest contains a set of tests that run against a real Terraform
// binary, compiled on the fly at the start of the test run.
//
// These tests help ensure that key end-to-end Terraform use-cases are working
// for a real binary, whereas other tests always have at least _some_ amount
@ -12,7 +12,7 @@
// These tests can be used in two ways. The simplest way is to just run them
// with "go test" as normal:
//
// go test -v github.com/hashicorp/terraform/internal/command/e2etest
// go test -v github.com/hashicorp/terraform/internal/command/e2etest
//
// This will compile on the fly a Terraform binary and run the tests against
// it.
@ -20,8 +20,8 @@
// Alternatively, the make-archive.sh script can be used to produce a
// self-contained zip file that can be shipped to another machine to run
// the tests there without needing a locally-installed Go compiler. This
// is primarily useful for testing cross-compiled builds. For more information,
// see the commentary in make-archive.sh.
// is primarily useful for testing cross-compiled builds during our release
// process. For more information, see the commentary in make-archive.sh.
//
// The TF_ACC environment variable must be set for the tests to reach out
// to external network services. Since these are end-to-end tests, only a

View File

@ -8,7 +8,7 @@
# archive that can be extracted on a Windows system to run the e2e tests there:
# $ GOOS=windows GOARCH=amd64 ./make-archive.sh
#
# This will produce a zip file build/terraform-s2stest_windows_amd64.zip which
# This will produce a zip file build/terraform-e2etest_windows_amd64.zip which
# can be shipped off to a Windows amd64 system, extracted to some directory,
# and then executed as follows:
# set TF_ACC=1

View File

@ -809,7 +809,7 @@ func TestImportModuleVarFile(t *testing.T) {
//
// The specific example has a variable "foo" which is a nested object:
//
// foo = { bar = { baz = true } }
// foo = { bar = { baz = true } }
//
// This is used as foo = var.foo in the call to the child module, which then
// uses the traversal foo.bar.baz in a local. A default value in the child

View File

@ -708,7 +708,7 @@ func actionString(action string) []string {
// encodePaths lossily encodes a cty.PathSet into an array of arrays of step
// values, such as:
//
// [["length"],["triggers",0,"value"]]
// [["length"],["triggers",0,"value"]]
//
// The lossiness is that we cannot distinguish between an IndexStep with string
// key and a GetAttr step. This is fine with JSON output, because JSON's type
@ -716,8 +716,8 @@ func actionString(action string) []string {
// indexes.
//
// JavaScript (or similar dynamic language) consumers of these values can
// recursively apply the steps to a given object using an index operation for
// each step.
// iterate over the the steps starting from the root object to reach the
// value that each path is describing.
func encodePaths(pathSet cty.PathSet) (json.RawMessage, error) {
if pathSet.Empty() {
return nil, nil

View File

@ -21,7 +21,7 @@ import (
// like the following, which again should be needed only in test code which
// might need to inspect the filesystem in order to make assertions:
//
// filepath.Join(d.RootModuleDir(), normalizePathResult)
// filepath.Join(d.RootModuleDir(), normalizePathResult)
//
// The above is suitable only for situations where the given path is known
// to be beneath the working directory, which is the typical situation for

View File

@ -117,7 +117,7 @@ func (l *Loader) IsConfigDir(path string) bool {
return l.parser.IsConfigDir(path)
}
// ImportSources writes into the receiver's source code the given source
// ImportSources writes into the receiver's source code map the given source
// code buffers.
//
// This is useful in the situation where an ancillary loader is created for
@ -125,7 +125,7 @@ func (l *Loader) IsConfigDir(path string) bool {
// code from that loader must be imported into the "main" loader in order
// to return source code snapshots in diagnostic messages.
//
// loader.ImportSources(otherLoader.Sources())
// loader.ImportSources(otherLoader.Sources())
func (l *Loader) ImportSources(sources map[string][]byte) {
p := l.Parser()
for name, src := range sources {

View File

@ -208,9 +208,10 @@ func TestModule_required_provider_overrides(t *testing.T) {
// Resources without explicit provider configuration are assigned a provider
// implied based on the resource type. For example, this resource:
//
// resource foo_instance "test" { }
// resource "foo_instance" "test" {}
//
// is assigned a provider with type "foo".
// ...is assigned to whichever provider has local name "foo" in the current
// module.
//
// To find the correct provider, we first look in the module's provider
// requirements map for a local name matching the resource type, and fall back

View File

@ -156,8 +156,8 @@ func (p *Provider) moduleUniqueKey() string {
// that can be successfully parsed as compact relative provider configuration
// addresses:
//
// aws
// aws.foo
// - aws
// - aws.foo
//
// This function will panic if given a relative traversal.
//

View File

@ -14,9 +14,9 @@ package configs
// are in the documentation for each constant in this enumeration, but in
// summary:
//
// TypeHintString requires a primitive type
// TypeHintList requires a type that could be converted to a tuple
// TypeHintMap requires a type that could be converted to an object
// - TypeHintString requires a primitive type
// - TypeHintList requires a type that could be converted to a tuple
// - TypeHintMap requires a type that could be converted to an object
type VariableTypeHint rune
//go:generate go run golang.org/x/tools/cmd/stringer -type VariableTypeHint

View File

@ -12,7 +12,7 @@ import (
// that the original tables can be restored at the conclusion of the calling
// test:
//
// defer experiments.OverrideForTesting(t, current, concluded)()
// defer experiments.OverrideForTesting(t, current, concluded)()
//
// This function modifies global variables that are normally fixed throughout
// our execution, so this function must not be called from non-test code and

View File

@ -382,11 +382,11 @@ type signatureAuthentication struct {
// in turn until one is successful. If such a key is found, there are three
// possible successful authentication results:
//
// 1. If the signing key is the HashiCorp official key, it is an official
// provider;
// 2. Otherwise, if the signing key has a trust signature from the HashiCorp
// Partners key, it is a partner provider;
// 3. If neither of the above is true, it is a community provider.
// 1. If the signing key is the HashiCorp official key, it is an official
// provider;
// 2. Otherwise, if the signing key has a trust signature from the HashiCorp
// Partners key, it is a partner provider;
// 3. If neither of the above is true, it is a community provider.
//
// Any failure in the process of validating the signature will result in an
// unauthenticated result.

View File

@ -10,9 +10,7 @@ import (
"testing"
)
//
// Lean on the standard net lib as much as possible.
//
type IPMask = stdnet.IPMask
var IPv4Mask = stdnet.IPv4Mask

View File

@ -670,8 +670,10 @@ func Index(list, value cty.Value) (cty.Value, error) {
return IndexFunc.Call([]cty.Value{list, value})
}
// List takes any number of list arguments and returns a list containing those
// values in the same order.
// List takes any number of arguments of types that can unify into a single
// type and returns a list containing those values in the same order, or
// returns an error if there is no single element type that all values can
// convert to.
func List(args ...cty.Value) (cty.Value, error) {
return ListFunc.Call(args)
}

View File

@ -153,7 +153,6 @@ func unsupportedTimeoutKeyError(key string) error {
//
// StateEncode encodes the timeout into the ResourceData's InstanceState for
// saving to state
//
func (t *ResourceTimeout) DiffEncode(id *terraform.InstanceDiff) error {
return t.metaEncode(id)
}

View File

@ -92,7 +92,9 @@ func (r *ResourceAddress) String() string {
// HasResourceSpec returns true if the address has a resource spec, as
// defined in the documentation:
// https://www.terraform.io/docs/cli/state/resource-addressing.html
//
// https://www.terraform.io/docs/cli/state/resource-addressing.html
//
// In particular, this returns false if the address contains only
// a module path, thus addressing the entire module.
func (r *ResourceAddress) HasResourceSpec() bool {

View File

@ -1425,7 +1425,6 @@ func ParseResourceStateKey(k string) (*ResourceStateKey, error) {
//
// Extra is just extra data that a provider can return that we store
// for later, but is not exposed in any way to the user.
//
type ResourceState struct {
// This is filled in and managed by Terraform, and is the resource
// type itself such as "mycloud_instance". If a resource provider sets

View File

@ -106,7 +106,8 @@ func (c *Changes) ResourceInstanceDeposed(addr addrs.AbsResourceInstance, key st
}
// OutputValue returns the planned change for the output value with the
// given address, if any. Returns nil if no change is planned.
//
// given address, if any. Returns nil if no change is planned.
func (c *Changes) OutputValue(addr addrs.AbsOutputValue) *OutputChangeSrc {
for _, oc := range c.Outputs {
if oc.Addr.Equal(addr) {
@ -279,12 +280,12 @@ func (rc *ResourceInstanceChange) Moved() bool {
//
// The following table shows the simplification behavior:
//
// Action Destroying? New Action
// --------+-------------+-----------
// Create true NoOp
// Delete false NoOp
// Replace true Delete
// Replace false Create
// Action Destroying? New Action
// --------+-------------+-----------
// Create true NoOp
// Delete false NoOp
// Replace true Delete
// Replace false Create
//
// For any combination not in the above table, the Simplify just returns the
// receiver as-is.

View File

@ -517,14 +517,14 @@ type Change struct {
// the documentation for any message that embeds Change.
Action Action `protobuf:"varint,1,opt,name=action,proto3,enum=tfplan.Action" json:"action,omitempty"`
// msgpack-encoded HCL values involved in the change.
// - For update and replace, two values are provided that give the old and new values,
// respectively.
// - For create, one value is provided that gives the new value to be created
// - For delete, one value is provided that describes the value being deleted
// - For read, two values are provided that give the prior value for this object
// (or null, if no prior value exists) and the value that was or will be read,
// respectively.
// - For no-op, one value is provided that is left unmodified by this non-change.
// - For update and replace, two values are provided that give the old and new values,
// respectively.
// - For create, one value is provided that gives the new value to be created
// - For delete, one value is provided that describes the value being deleted
// - For read, two values are provided that give the prior value for this object
// (or null, if no prior value exists) and the value that was or will be read,
// respectively.
// - For no-op, one value is provided that is left unmodified by this non-change.
Values []*DynamicValue `protobuf:"bytes,2,rep,name=values,proto3" json:"values,omitempty"`
// An unordered set of paths into the old value which are marked as
// sensitive. Values at these paths should be obscured in human-readable
@ -810,6 +810,7 @@ type ConditionResult struct {
// condition depends on values which are only known at apply time.
//
// Types that are assignable to Result:
//
// *ConditionResult_Value
// *ConditionResult_Unknown
Result isConditionResult_Result `protobuf_oneof:"result"`
@ -1086,6 +1087,7 @@ type Path_Step struct {
unknownFields protoimpl.UnknownFields
// Types that are assignable to Selector:
//
// *Path_Step_AttributeName
// *Path_Step_ElementKey
Selector isPath_Step_Selector `protobuf_oneof:"selector"`

View File

@ -19,7 +19,7 @@ type Storage interface {
// of the implementing type that will fail at compile time if the interface
// isn't satisfied, such as:
//
// var _ statemgr.Full = (*ImplementingType)(nil)
// var _ statemgr.Full = (*ImplementingType)(nil)
type Full interface {
Storage
Locker

View File

@ -2924,7 +2924,7 @@ func TestContext2Plan_countIncreaseFromOneCorrupted(t *testing.T) {
// A common pattern in TF configs is to have a set of resources with the same
// count and to use count.index to create correspondences between them:
//
// foo_id = "${foo.bar.*.id[count.index]}"
// foo_id = "${foo.bar.*.id[count.index]}"
//
// This test is for the situation where some instances already exist and the
// count is increased. In that case, we should see only the create diffs

View File

@ -47,11 +47,11 @@ func simpleMockPluginLibrary() *contextPlugins {
//
// The returned schema contains the following optional attributes:
//
// test_string, of type string
// test_number, of type number
// test_bool, of type bool
// test_list, of type list(string)
// test_map, of type map(string)
// - test_string, of type string
// - test_number, of type number
// - test_bool, of type bool
// - test_list, of type list(string)
// - test_map, of type map(string)
//
// Each call to this function produces an entirely new schema instance, so
// callers can feel free to modify it once returned.

View File

@ -10,17 +10,18 @@ import (
"github.com/hashicorp/terraform/internal/tfdiags"
)
// PlanGraphBuilder implements GraphBuilder and is responsible for building
// a graph for planning (creating a Terraform Diff).
// PlanGraphBuilder is a GraphBuilder implementation that builds a graph for
// planning and for other "plan-like" operations which don't require an
// already-calculated plan as input.
//
// The primary difference between this graph and others:
// Unlike the apply graph builder, this graph builder:
//
// * Based on the config since it represents the target state
//
// * Ignores lifecycle options since no lifecycle events occur here. This
// simplifies the graph significantly since complex transforms such as
// create-before-destroy can be completely ignored.
// - Makes its decisions primarily based on the given configuration, which
// represents the desired state.
//
// - Ignores certain lifecycle concerns like create_before_destroy, because
// those are only important once we already know what action we're planning
// to take against a particular resource instance.
type PlanGraphBuilder struct {
// Config is the configuration tree to build a plan from.
Config *configs.Config

View File

@ -323,10 +323,10 @@ func TestNodeApplyableProvider_Validate(t *testing.T) {
})
}
//This test specifically tests responses from the
//providers.ValidateProviderConfigFn. See
//TestNodeApplyableProvider_ConfigProvider_config_fn_err for
//providers.ConfigureProviderRequest responses.
// This test specifically tests responses from the
// providers.ValidateProviderConfigFn. See
// TestNodeApplyableProvider_ConfigProvider_config_fn_err for
// providers.ConfigureProviderRequest responses.
func TestNodeApplyableProvider_ConfigProvider(t *testing.T) {
provider := mockProviderWithConfigSchema(&configschema.Block{
Attributes: map[string]*configschema.Attribute{
@ -409,7 +409,7 @@ func TestNodeApplyableProvider_ConfigProvider(t *testing.T) {
}
//This test is similar to TestNodeApplyableProvider_ConfigProvider, but tests responses from the providers.ConfigureProviderRequest
// This test is similar to TestNodeApplyableProvider_ConfigProvider, but tests responses from the providers.ConfigureProviderRequest
func TestNodeApplyableProvider_ConfigProvider_config_fn_err(t *testing.T) {
provider := mockProviderWithConfigSchema(&configschema.Block{
Attributes: map[string]*configschema.Attribute{

View File

@ -466,16 +466,16 @@ func (n *NodeAbstractResource) readResourceInstanceStateDeposed(ctx EvalContext,
// graphNodesAreResourceInstancesInDifferentInstancesOfSameModule is an
// annoyingly-task-specific helper function that returns true if and only if
// the following conditions hold:
// - Both of the given vertices represent specific resource instances, as
// opposed to unexpanded resources or any other non-resource-related object.
// - The module instance addresses for both of the resource instances belong
// to the same static module.
// - The module instance addresses for both of the resource instances are
// not equal, indicating that they belong to different instances of the
// same module.
// - Both of the given vertices represent specific resource instances, as
// opposed to unexpanded resources or any other non-resource-related object.
// - The module instance addresses for both of the resource instances belong
// to the same static module.
// - The module instance addresses for both of the resource instances are
// not equal, indicating that they belong to different instances of the
// same module.
//
// This result can be used as a way to compensate for the effects of
// conservative analyses passes in our graph builders which make their
// conservative analysis passes in our graph builders which make their
// decisions based only on unexpanded addresses, often so that they can behave
// correctly for interactions between expanded and not-yet-expanded objects.
//

View File

@ -92,17 +92,17 @@ func (t *ForcedCBDTransformer) hasCBDDescendent(g *Graph, v dag.Vertex) bool {
return false
}
// CBDEdgeTransformer modifies the edges of CBD nodes that went through
// the DestroyEdgeTransformer to have the right dependencies. There are
// two real tasks here:
// CBDEdgeTransformer modifies the edges of create-before-destroy ("CBD") nodes
// that went through the DestroyEdgeTransformer so that they will have the
// correct dependencies. There are two parts to this:
//
// 1. With CBD, the destroy edge is inverted: the destroy depends on
// the creation.
// 1. With CBD, the destroy edge is inverted: the destroy depends on
// the creation.
//
// 2. A_d must depend on resources that depend on A. This is to enable
// the destroy to only happen once nodes that depend on A successfully
// update to A. Example: adding a web server updates the load balancer
// before deleting the old web server.
// 2. Destroy for A must depend on resources that depend on A. This is to
// allow the destroy to only happen once nodes that depend on A successfully
// update to A. Example: adding a web server updates the load balancer
// before deleting the old web server.
//
// This transformer requires that a previous transformer has already forced
// create_before_destroy on for nodes that are depended on by explicit CBD

View File

@ -30,7 +30,7 @@ type GraphNodeCreator interface {
//
// That is complicated. Visually:
//
// B_d -> A_d -> A -> B
// B_d -> A_d -> A -> B
//
// Notice that A destroy depends on B destroy, while B create depends on
// A create. They're inverted. This must be done for example because often

View File

@ -27,17 +27,17 @@ type Diagnostics []Diagnostic
//
// The usual pattern for a function that natively "speaks" diagnostics is:
//
// // Create a nil Diagnostics at the start of the function
// var diags diag.Diagnostics
// // Create a nil Diagnostics at the start of the function
// var diags diag.Diagnostics
//
// // At later points, build on it if errors / warnings occur:
// foo, err := DoSomethingRisky()
// if err != nil {
// diags = diags.Append(err)
// }
// // At later points, build on it if errors / warnings occur:
// foo, err := DoSomethingRisky()
// if err != nil {
// diags = diags.Append(err)
// }
//
// // Eventually return the result and diagnostics in place of error
// return result, diags
// // Eventually return the result and diagnostics in place of error
// return result, diags
//
// Append accepts a variety of different diagnostic-like types, including
// native Go errors and HCL diagnostics. It also knows how to unwrap
@ -129,11 +129,11 @@ func (diags Diagnostics) ForRPC() Diagnostics {
// if the diagnostics list does not include any error-level diagnostics.
//
// This can be used to smuggle diagnostics through an API that deals in
// native errors, but unfortunately it will lose naked warnings (warnings
// that aren't accompanied by at least one error) since such APIs have no
// mechanism through which to report these.
// native errors, but unfortunately it will lose any warnings that aren't
// accompanied by at least one error since such APIs have no mechanism through
// which to report those.
//
// return result, diags.Error()
// return result, diags.Error()
func (diags Diagnostics) Err() error {
if !diags.HasErrors() {
return nil

View File

@ -1065,6 +1065,7 @@ type AttributePath_Step struct {
unknownFields protoimpl.UnknownFields
// Types that are assignable to Selector:
//
// *AttributePath_Step_AttributeName
// *AttributePath_Step_ElementKeyString
// *AttributePath_Step_ElementKeyInt
@ -2473,9 +2474,9 @@ type PlanResourceChange_Response struct {
// specific details of the legacy SDK type system, and are not a general
// mechanism to avoid proper type handling in providers.
//
// ==== DO NOT USE THIS ====
// ==== THIS MUST BE LEFT UNSET IN ALL OTHER SDKS ====
// ==== DO NOT USE THIS ====
// ==== DO NOT USE THIS ====
// ==== THIS MUST BE LEFT UNSET IN ALL OTHER SDKS ====
// ==== DO NOT USE THIS ====
LegacyTypeSystem bool `protobuf:"varint,5,opt,name=legacy_type_system,json=legacyTypeSystem,proto3" json:"legacy_type_system,omitempty"`
}
@ -2649,9 +2650,9 @@ type ApplyResourceChange_Response struct {
// specific details of the legacy SDK type system, and are not a general
// mechanism to avoid proper type handling in providers.
//
// ==== DO NOT USE THIS ====
// ==== THIS MUST BE LEFT UNSET IN ALL OTHER SDKS ====
// ==== DO NOT USE THIS ====
// ==== DO NOT USE THIS ====
// ==== THIS MUST BE LEFT UNSET IN ALL OTHER SDKS ====
// ==== DO NOT USE THIS ====
LegacyTypeSystem bool `protobuf:"varint,4,opt,name=legacy_type_system,json=legacyTypeSystem,proto3" json:"legacy_type_system,omitempty"`
}
@ -4701,21 +4702,21 @@ const _ = grpc.SupportPackageIsVersion6
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ProviderClient interface {
//////// Information about what a provider supports/expects
// ////// Information about what a provider supports/expects
GetSchema(ctx context.Context, in *GetProviderSchema_Request, opts ...grpc.CallOption) (*GetProviderSchema_Response, error)
PrepareProviderConfig(ctx context.Context, in *PrepareProviderConfig_Request, opts ...grpc.CallOption) (*PrepareProviderConfig_Response, error)
ValidateResourceTypeConfig(ctx context.Context, in *ValidateResourceTypeConfig_Request, opts ...grpc.CallOption) (*ValidateResourceTypeConfig_Response, error)
ValidateDataSourceConfig(ctx context.Context, in *ValidateDataSourceConfig_Request, opts ...grpc.CallOption) (*ValidateDataSourceConfig_Response, error)
UpgradeResourceState(ctx context.Context, in *UpgradeResourceState_Request, opts ...grpc.CallOption) (*UpgradeResourceState_Response, error)
//////// One-time initialization, called before other functions below
// ////// One-time initialization, called before other functions below
Configure(ctx context.Context, in *Configure_Request, opts ...grpc.CallOption) (*Configure_Response, error)
//////// Managed Resource Lifecycle
// ////// Managed Resource Lifecycle
ReadResource(ctx context.Context, in *ReadResource_Request, opts ...grpc.CallOption) (*ReadResource_Response, error)
PlanResourceChange(ctx context.Context, in *PlanResourceChange_Request, opts ...grpc.CallOption) (*PlanResourceChange_Response, error)
ApplyResourceChange(ctx context.Context, in *ApplyResourceChange_Request, opts ...grpc.CallOption) (*ApplyResourceChange_Response, error)
ImportResourceState(ctx context.Context, in *ImportResourceState_Request, opts ...grpc.CallOption) (*ImportResourceState_Response, error)
ReadDataSource(ctx context.Context, in *ReadDataSource_Request, opts ...grpc.CallOption) (*ReadDataSource_Response, error)
//////// Graceful Shutdown
// ////// Graceful Shutdown
Stop(ctx context.Context, in *Stop_Request, opts ...grpc.CallOption) (*Stop_Response, error)
}
@ -4837,21 +4838,21 @@ func (c *providerClient) Stop(ctx context.Context, in *Stop_Request, opts ...grp
// ProviderServer is the server API for Provider service.
type ProviderServer interface {
//////// Information about what a provider supports/expects
// ////// Information about what a provider supports/expects
GetSchema(context.Context, *GetProviderSchema_Request) (*GetProviderSchema_Response, error)
PrepareProviderConfig(context.Context, *PrepareProviderConfig_Request) (*PrepareProviderConfig_Response, error)
ValidateResourceTypeConfig(context.Context, *ValidateResourceTypeConfig_Request) (*ValidateResourceTypeConfig_Response, error)
ValidateDataSourceConfig(context.Context, *ValidateDataSourceConfig_Request) (*ValidateDataSourceConfig_Response, error)
UpgradeResourceState(context.Context, *UpgradeResourceState_Request) (*UpgradeResourceState_Response, error)
//////// One-time initialization, called before other functions below
// ////// One-time initialization, called before other functions below
Configure(context.Context, *Configure_Request) (*Configure_Response, error)
//////// Managed Resource Lifecycle
// ////// Managed Resource Lifecycle
ReadResource(context.Context, *ReadResource_Request) (*ReadResource_Response, error)
PlanResourceChange(context.Context, *PlanResourceChange_Request) (*PlanResourceChange_Response, error)
ApplyResourceChange(context.Context, *ApplyResourceChange_Request) (*ApplyResourceChange_Response, error)
ImportResourceState(context.Context, *ImportResourceState_Request) (*ImportResourceState_Response, error)
ReadDataSource(context.Context, *ReadDataSource_Request) (*ReadDataSource_Response, error)
//////// Graceful Shutdown
// ////// Graceful Shutdown
Stop(context.Context, *Stop_Request) (*Stop_Response, error)
}

View File

@ -1006,6 +1006,7 @@ type AttributePath_Step struct {
unknownFields protoimpl.UnknownFields
// Types that are assignable to Selector:
//
// *AttributePath_Step_AttributeName
// *AttributePath_Step_ElementKeyString
// *AttributePath_Step_ElementKeyInt
@ -2492,9 +2493,9 @@ type PlanResourceChange_Response struct {
// specific details of the legacy SDK type system, and are not a general
// mechanism to avoid proper type handling in providers.
//
// ==== DO NOT USE THIS ====
// ==== THIS MUST BE LEFT UNSET IN ALL OTHER SDKS ====
// ==== DO NOT USE THIS ====
// ==== DO NOT USE THIS ====
// ==== THIS MUST BE LEFT UNSET IN ALL OTHER SDKS ====
// ==== DO NOT USE THIS ====
LegacyTypeSystem bool `protobuf:"varint,5,opt,name=legacy_type_system,json=legacyTypeSystem,proto3" json:"legacy_type_system,omitempty"`
}
@ -2668,9 +2669,9 @@ type ApplyResourceChange_Response struct {
// specific details of the legacy SDK type system, and are not a general
// mechanism to avoid proper type handling in providers.
//
// ==== DO NOT USE THIS ====
// ==== THIS MUST BE LEFT UNSET IN ALL OTHER SDKS ====
// ==== DO NOT USE THIS ====
// ==== DO NOT USE THIS ====
// ==== THIS MUST BE LEFT UNSET IN ALL OTHER SDKS ====
// ==== DO NOT USE THIS ====
LegacyTypeSystem bool `protobuf:"varint,4,opt,name=legacy_type_system,json=legacyTypeSystem,proto3" json:"legacy_type_system,omitempty"`
}
@ -4269,21 +4270,21 @@ const _ = grpc.SupportPackageIsVersion6
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ProviderClient interface {
//////// Information about what a provider supports/expects
// ////// Information about what a provider supports/expects
GetProviderSchema(ctx context.Context, in *GetProviderSchema_Request, opts ...grpc.CallOption) (*GetProviderSchema_Response, error)
ValidateProviderConfig(ctx context.Context, in *ValidateProviderConfig_Request, opts ...grpc.CallOption) (*ValidateProviderConfig_Response, error)
ValidateResourceConfig(ctx context.Context, in *ValidateResourceConfig_Request, opts ...grpc.CallOption) (*ValidateResourceConfig_Response, error)
ValidateDataResourceConfig(ctx context.Context, in *ValidateDataResourceConfig_Request, opts ...grpc.CallOption) (*ValidateDataResourceConfig_Response, error)
UpgradeResourceState(ctx context.Context, in *UpgradeResourceState_Request, opts ...grpc.CallOption) (*UpgradeResourceState_Response, error)
//////// One-time initialization, called before other functions below
// ////// One-time initialization, called before other functions below
ConfigureProvider(ctx context.Context, in *ConfigureProvider_Request, opts ...grpc.CallOption) (*ConfigureProvider_Response, error)
//////// Managed Resource Lifecycle
// ////// Managed Resource Lifecycle
ReadResource(ctx context.Context, in *ReadResource_Request, opts ...grpc.CallOption) (*ReadResource_Response, error)
PlanResourceChange(ctx context.Context, in *PlanResourceChange_Request, opts ...grpc.CallOption) (*PlanResourceChange_Response, error)
ApplyResourceChange(ctx context.Context, in *ApplyResourceChange_Request, opts ...grpc.CallOption) (*ApplyResourceChange_Response, error)
ImportResourceState(ctx context.Context, in *ImportResourceState_Request, opts ...grpc.CallOption) (*ImportResourceState_Response, error)
ReadDataSource(ctx context.Context, in *ReadDataSource_Request, opts ...grpc.CallOption) (*ReadDataSource_Response, error)
//////// Graceful Shutdown
// ////// Graceful Shutdown
StopProvider(ctx context.Context, in *StopProvider_Request, opts ...grpc.CallOption) (*StopProvider_Response, error)
}
@ -4405,21 +4406,21 @@ func (c *providerClient) StopProvider(ctx context.Context, in *StopProvider_Requ
// ProviderServer is the server API for Provider service.
type ProviderServer interface {
//////// Information about what a provider supports/expects
// ////// Information about what a provider supports/expects
GetProviderSchema(context.Context, *GetProviderSchema_Request) (*GetProviderSchema_Response, error)
ValidateProviderConfig(context.Context, *ValidateProviderConfig_Request) (*ValidateProviderConfig_Response, error)
ValidateResourceConfig(context.Context, *ValidateResourceConfig_Request) (*ValidateResourceConfig_Response, error)
ValidateDataResourceConfig(context.Context, *ValidateDataResourceConfig_Request) (*ValidateDataResourceConfig_Response, error)
UpgradeResourceState(context.Context, *UpgradeResourceState_Request) (*UpgradeResourceState_Response, error)
//////// One-time initialization, called before other functions below
// ////// One-time initialization, called before other functions below
ConfigureProvider(context.Context, *ConfigureProvider_Request) (*ConfigureProvider_Response, error)
//////// Managed Resource Lifecycle
// ////// Managed Resource Lifecycle
ReadResource(context.Context, *ReadResource_Request) (*ReadResource_Response, error)
PlanResourceChange(context.Context, *PlanResourceChange_Request) (*PlanResourceChange_Response, error)
ApplyResourceChange(context.Context, *ApplyResourceChange_Request) (*ApplyResourceChange_Response, error)
ImportResourceState(context.Context, *ImportResourceState_Request) (*ImportResourceState_Response, error)
ReadDataSource(context.Context, *ReadDataSource_Request) (*ReadDataSource_Response, error)
//////// Graceful Shutdown
// ////// Graceful Shutdown
StopProvider(context.Context, *StopProvider_Request) (*StopProvider_Response, error)
}

View File

@ -43,7 +43,8 @@ func TypeConstraintFromVal(v cty.Value) cty.Type {
// ConvertFunc is a cty function that implements type conversions.
//
// Its signature is as follows:
// convert(value, type_constraint)
//
// convert(value, type_constraint)
//
// ...where type_constraint is a type constraint expression as defined by
// typeexpr.TypeConstraint.