Vendor early8 (#3453)

This commit is contained in:
Riley Karson 2019-04-17 18:03:07 -07:00 committed by Paddy
parent 9ac574e185
commit 334552e8c8
9 changed files with 77 additions and 17 deletions

2
go.mod
View File

@ -12,7 +12,7 @@ require (
github.com/hashicorp/go-multierror v1.0.0
github.com/hashicorp/go-version v1.1.0
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/terraform v0.12.0-alpha4.0.20190416181449-bd1a215580c8
github.com/hashicorp/terraform v0.12.0-alpha4.0.20190417210818-177a7afb781f
github.com/hashicorp/vault v1.0.1 // indirect
github.com/keybase/go-crypto v0.0.0-20181127160227-255a5089e85a // indirect
github.com/mitchellh/hashstructure v1.0.0

6
go.sum
View File

@ -60,7 +60,7 @@ github.com/chzyer/readline v0.0.0-20161106042343-c914be64f07d/go.mod h1:nSuG5e5P
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/coreos/bbolt v1.3.0/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible h1:KjVWqrZ5U0wa3CxY2AxlH6/UcB+PK2td1DcsYhA+HRs=
github.com/coreos/etcd v3.3.10+incompatible h1:jFneRYjIvLMLhDLCzuTuU4rSJUjRplcJQ7pD7MnhC04=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-semver v0.2.0 h1:3Jm3tLmsgAYcjC+4Up7hJrFBPr+n7rAqYeSw/SZazuY=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
@ -187,8 +187,8 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO
github.com/hashicorp/memberlist v0.1.0/go.mod h1:ncdBp14cuox2iFOq3kDiquKU6fqsTBc3W6JvZwjxxsE=
github.com/hashicorp/serf v0.0.0-20160124182025-e4ec8cc423bb h1:ZbgmOQt8DOg796figP87/EFCVx2v2h9yRvwHF/zceX4=
github.com/hashicorp/serf v0.0.0-20160124182025-e4ec8cc423bb/go.mod h1:h/Ru6tmZazX7WO/GDmwdpS975F019L4t5ng5IgwbNrE=
github.com/hashicorp/terraform v0.12.0-alpha4.0.20190416181449-bd1a215580c8 h1:MJnhmLPKcF5CvkWO466RWSE2O9Y/7qRQKOwbsbT1ioQ=
github.com/hashicorp/terraform v0.12.0-alpha4.0.20190416181449-bd1a215580c8/go.mod h1:A3NsI7WT87OMgpcD15cu6dK2YNpihchZp5fxUf8EHBg=
github.com/hashicorp/terraform v0.12.0-alpha4.0.20190417210818-177a7afb781f h1:Gl7Ig3E2XpntOCaGMZrMR9zSfNJl4JXHiqP64zJCzak=
github.com/hashicorp/terraform v0.12.0-alpha4.0.20190417210818-177a7afb781f/go.mod h1:A3NsI7WT87OMgpcD15cu6dK2YNpihchZp5fxUf8EHBg=
github.com/hashicorp/terraform-config-inspect v0.0.0-20190327195015-8022a2663a70 h1:oZm5nE11yhzsTRz/YrUyDMSvixePqjoZihwn8ipuOYI=
github.com/hashicorp/terraform-config-inspect v0.0.0-20190327195015-8022a2663a70/go.mod h1:ItvqtvbC3K23FFET62ZwnkwtpbKZm8t8eMcWjmVVjD8=
github.com/hashicorp/vault v0.10.4/go.mod h1:KfSyffbKxoVyspOdlaGVjIuwLobi07qD1bAbosPMpP0=

View File

@ -266,7 +266,8 @@ type Schema struct {
// guaranteed to be of the proper Schema type, and it can yield warnings or
// errors based on inspection of that value.
//
// ValidateFunc currently only works for primitive types.
// ValidateFunc is honored only when the schema's Type is set to TypeInt,
// TypeFloat, TypeString, TypeBool, or TypeMap. It is ignored for all other types.
ValidateFunc SchemaValidateFunc
// Sensitive ensures that the attribute's value does not get displayed in

View File

@ -133,9 +133,10 @@ func LegacyResourceSchema(r *Resource) *Resource {
return newResource
}
// LegacySchema takes a *Schema and returns a deep copy with 0.12 specific
// features removed. This is used by the shims to get a configschema that
// directly matches the structure of the schema.Resource.
// LegacySchema takes a *Schema and returns a deep copy with some 0.12-specific
// features disabled. This is used by the shims to get a configschema that
// better reflects the given schema.Resource, without any adjustments we
// make for when sending a schema to Terraform Core.
func LegacySchema(s *Schema) *Schema {
if s == nil {
return nil
@ -143,7 +144,6 @@ func LegacySchema(s *Schema) *Schema {
// start with a shallow copy
newSchema := new(Schema)
*newSchema = *s
newSchema.ConfigMode = SchemaConfigModeAuto
newSchema.SkipCoreTypeCheck = false
switch e := newSchema.Elem.(type) {

View File

@ -19,7 +19,7 @@ type ResourceInstanceObject struct {
// Terraform.
Value cty.Value
// Internal is an opaque value set by the provider when this object was
// Private is an opaque value set by the provider when this object was
// last created or updated. Terraform Core does not use this value in
// any way and it is not exposed anywhere in the user interface, so
// a provider can use it for retaining any necessary private state.

View File

@ -646,8 +646,10 @@ func (d *InstanceDiff) applyBlockDiff(path []string, attrs map[string]string, sc
func (d *InstanceDiff) applyAttrDiff(path []string, attrs map[string]string, attrSchema *configschema.Attribute) (map[string]string, error) {
ty := attrSchema.Type
switch {
case ty.IsListType(), ty.IsTupleType(), ty.IsMapType(), ty.IsSetType():
case ty.IsListType(), ty.IsTupleType(), ty.IsMapType():
return d.applyCollectionDiff(path, attrs, attrSchema)
case ty.IsSetType():
return d.applySetDiff(path, attrs, attrSchema)
default:
return d.applySingleAttrDiff(path, attrs, attrSchema)
}
@ -873,6 +875,46 @@ func (d *InstanceDiff) applyCollectionDiff(path []string, attrs map[string]strin
return result, nil
}
func (d *InstanceDiff) applySetDiff(path []string, attrs map[string]string, attrSchema *configschema.Attribute) (map[string]string, error) {
// We only need this special behavior for sets of object.
if !attrSchema.Type.ElementType().IsObjectType() {
// The normal collection apply behavior will work okay for this one, then.
return d.applyCollectionDiff(path, attrs, attrSchema)
}
// When we're dealing with a set of an object type we actually want to
// use our normal _block type_ apply behaviors, so we'll construct ourselves
// a synthetic schema that treats the object type as a block type and
// then delegate to our block apply method.
synthSchema := &configschema.Block{
Attributes: make(map[string]*configschema.Attribute),
}
for name, ty := range attrSchema.Type.ElementType().AttributeTypes() {
// We can safely make everything into an attribute here because in the
// event that there are nested set attributes we'll end up back in
// here again recursively and can then deal with the next level of
// expansion.
synthSchema.Attributes[name] = &configschema.Attribute{
Type: ty,
Optional: true,
}
}
parentPath := path[:len(path)-1]
childName := path[len(path)-1]
containerSchema := &configschema.Block{
BlockTypes: map[string]*configschema.NestedBlock{
childName: {
Nesting: configschema.NestingSet,
Block: *synthSchema,
},
},
}
return d.applyBlockDiff(parentPath, attrs, containerSchema)
}
// countFlatmapContainerValues returns the number of values in the flatmapped container
// (set, map, list) indexed by key. The key argument is expected to include the
// trailing ".#", or ".%".

View File

@ -247,11 +247,11 @@ func (n *EvalApply) Eval(ctx EvalContext) (interface{}, error) {
}
// Sometimes providers return a null value when an operation fails for some
// reason, but for any action other than delete we'd rather keep the prior
// state so that the error can be corrected on a subsequent run. We must
// only do this for null new value though, or else we may discard partial
// updates the provider was able to complete.
if change.Action != plans.Delete && diags.HasErrors() && newVal.IsNull() {
// reason, but we'd rather keep the prior state so that the error can be
// corrected on a subsequent run. We must only do this for null new value
// though, or else we may discard partial updates the provider was able to
// complete.
if diags.HasErrors() && newVal.IsNull() {
// Otherwise, we'll continue but using the prior state as the new value,
// making this effectively a no-op. If the item really _has_ been
// deleted then our next refresh will detect that and fix it up.

View File

@ -215,6 +215,23 @@ func (d *evaluationStateData) GetInputVariable(addr addrs.InputVariable, rng tfd
d.Evaluator.VariableValuesLock.Lock()
defer d.Evaluator.VariableValuesLock.Unlock()
// During the validate walk, input variables are always unknown so
// that we are validating the configuration for all possible input values
// rather than for a specific set. Checking against a specific set of
// input values then happens during the plan walk.
//
// This is important because otherwise the validation walk will tend to be
// overly strict, requiring expressions throughout the configuration to
// be complicated to accommodate all possible inputs, whereas returning
// known here allows for simpler patterns like using input values as
// guards to broadly enable/disable resources, avoid processing things
// that are disabled, etc. Terraform's static validation leans towards
// being liberal in what it accepts because the subsequent plan walk has
// more information available and so can be more conservative.
if d.Operation == walkValidate {
return cty.UnknownVal(wantType), diags
}
moduleAddrStr := d.ModulePath.String()
vals := d.Evaluator.VariableValues[moduleAddrStr]
if vals == nil {

2
vendor/modules.txt vendored
View File

@ -132,7 +132,7 @@ github.com/hashicorp/hil/parser
github.com/hashicorp/hil/scanner
# github.com/hashicorp/logutils v1.0.0
github.com/hashicorp/logutils
# github.com/hashicorp/terraform v0.12.0-alpha4.0.20190416181449-bd1a215580c8
# github.com/hashicorp/terraform v0.12.0-alpha4.0.20190417210818-177a7afb781f
github.com/hashicorp/terraform/plugin
github.com/hashicorp/terraform/helper/customdiff
github.com/hashicorp/terraform/helper/encryption