Commit Graph

93 Commits

Author SHA1 Message Date
Paul Hinze ef70c8cae5 helper/schema: allow Schema attrs to be Removed
Removed fields show a customizable error message to the user when they
are used in a Terraform config. This is a tool that provider authors can
use for user feedback as they evolve their Schemas.

refs #957
2015-03-05 15:33:56 -06:00
Paul Hinze 888f16d2d3 helper/schema: allow Schema attrs to be Deprecated
Deprecated fields show a customizable warning message to the user when
they are used in a Terraform config. This is a tool that provider
authors can use for user feedback as they evolve their Schemas.

fixes #957
2015-03-05 15:16:50 -06:00
Mitchell Hashimoto 17680bb7ff helper/schema: some more test cases, revert some weird behavior from
dbfb95fcd5

I don't know why that behavior was in there, but it was breaking a lot
of existing Terraform states. Let's circle back on it.
2015-02-18 12:54:46 -08:00
Mitchell Hashimoto 659a77c6ae helper/schema: validate subresources more effectively 2015-02-18 09:41:55 -08:00
Mitchell Hashimoto fa7f496bef helper/schema: zero value of a set should be empty 2015-02-17 16:58:47 -08:00
Mitchell Hashimoto 5c06cc386a helper/schema: empty map values should show up in diff [GH-968] 2015-02-17 15:22:45 -08:00
Mitchell Hashimoto dbfb95fcd5 helper/schema: show in diff when no config is going to empty set 2015-02-17 14:45:18 -08:00
Mitchell Hashimoto bcdec738d4 helper/schema: default the new value to zero only for the decode 2015-02-17 13:16:59 -08:00
Mitchell Hashimoto b778a65a83 helper/schema: diff of zero value in state with lack of value should not
diff
2015-02-17 11:10:45 -08:00
Clint Shryock 4c7b732dad typo 2015-02-11 14:49:50 -08:00
INADA Naoki 33aa9d3ee8 Fix stringer error on helper/schema/schema.go 2015-02-03 19:33:01 +09:00
Dave Cunningham 18c26cb2eb Add some missing Float cases 2015-01-28 12:53:34 -05:00
Paul Hinze 5d4e69cc80 helper/schema: apply schema defaults at the field level when reading from config
We were waiting until the higher-level (m schemaMap) diffString method
to apply defaults, which was messing with set hashcode evaluation for
cases when a field with a default is included in the hash function.

fixes #824
2015-01-27 18:18:57 -06:00
Seth Vargo 072a1cf353 Read the "standard" AWS environment variables
This is 100% backwards-compatible
2015-01-22 16:09:25 -05:00
Jeff Mitchell f2bd1f45ab Move duplicated envDefaultFunc out of each provider and into Schema. 2015-01-16 17:25:39 +00:00
Mitchell Hashimoto 241fc5bb39 helper/schema: diff floats properly
/cc @phinze - This is pretty straightforward, almost magically so. The
reason this works is because in `diffString` we use mapstructure[1] with
"weak decode mode" to just be responisble for turning anything into a
string.

[1]: https://github.com/mitchellh/mapstructure
2015-01-14 09:32:03 -08:00
Mitchell Hashimoto 5e8b300ca1 update CHANGELOG 2015-01-14 09:29:37 -08:00
Emil Hessman 2bc612e6f8 helper/schema: fix panic when validating composite type
Don't check if the root key is being computed for composite types.
Instead, continue recursing the composite type in order to check if
the sub-key, key.N, for each individual element is being computed.

Fixes a panic which occurs when validating a composite type where
the value is an unknown kind for the schema.
2015-01-13 06:59:05 +01:00
Mitchell Hashimoto cf94a79955 helper/schema: add TypeFloat and Zero value 2015-01-10 15:57:06 -08:00
Mitchell Hashimoto 689cbc8b5b helper/schema: generate strings for ValueType 2015-01-10 15:52:11 -08:00
Mitchell Hashimoto 3cbcafe989 helper/schema: remove unused field 2015-01-10 12:50:53 -08:00
Mitchell Hashimoto 3c1b55a75f helper/schema: use the field reader/writer for state 2015-01-10 12:18:32 -08:00
Mitchell Hashimoto b4bf813151 helper/schema: too big to fail 2015-01-08 18:02:19 -08:00
Mitchell Hashimoto f416e0edf0 helper/schema: FieldReader and MapFieldReader 2014-12-19 05:56:46 -05:00
Mitchell Hashimoto df05483cf6 helper/schema: test pass from SvH 2014-12-16 09:05:16 -08:00
Mitchell Hashimoto 913f9a923e helper/schema: remove unnecessary code 2014-12-15 17:39:07 -08:00
Mitchell Hashimoto e5877543b2 helper/schema: track map element counts
This adds "field.#" values to the state/diff with the element count of a
map. This fixes a major issue around not knowing when child elements are
computed when doing variable access of a computed map.

Example, if you have a schema like this:

    "foo": &Schema{
        Type:     TypeMap,
        Computed: true,
    }

And you access it like this in a resource:

    ${type.name.foo.computed-field}

Then Terraform will error that "field foo could not be found on resource
type.name". By adding that "foo.#" is computed, Terraform core will pick
up that it WILL exist, so its okay.
2014-12-15 17:35:16 -08:00
Sander van Harmelen 40fa6c3aaa Fixed a type and reordered the case statements
Making in more inline with the existing code…
2014-12-15 23:02:16 +01:00
Sander van Harmelen 83c760fcb3 core: refactoring the way sets work internally v2
This is a refactored solution for PR #616. Functionally this is still
the same change, but it’s implemented a lot cleaner with less code and
less changes to existing parts of TF.
2014-12-12 23:21:20 +01:00
Sander van Harmelen 54db46ef1b Fixing a small logic bug in diffList
It’s not enough to only check if no new value is set. It can also be
that a new value is set, but contains a variable that cannot be
interpolated until a depending resource is created during the apply
fase.

I actually found this one as one of the acceptance tests for the AWS
ELB resource was failing. It failed with the following error:

```
--- FAIL: TestAccAWSELB_InstanceAttaching (177.83 seconds)
  testing.go:121: Step 1 error: Error applying: aws_elb.bar: diffs
didn't match during apply. This is a bug with the resource provider,
please report a bug.
FAIL
exit status 1
FAIL  github.com/hashicorp/terraform/builtin/providers/aws  177.882s
```

After a quick look I noticed it was actually a bug in core TF so added
the test and made sure all unit tests and AWS acceptance tests are now
running successfully.
2014-12-12 15:24:29 +01:00
Mitchell Hashimoto c3ec9f7965 Revert "helper/schema: TypeMap computed should mark diff as cmputed"
This reverts commit b73078c670.
2014-12-09 09:27:19 -08:00
Mitchell Hashimoto b73078c670 helper/schema: TypeMap computed should mark diff as cmputed 2014-12-09 00:39:02 -08:00
Emil Hessman 4bfe18b40d argument and verb formatting fixes reported by go vet
builtin/providers/aws/tags_test.go:56: unrecognized printf verb 'i'
builtin/providers/aws/tags_test.go:59: unrecognized printf verb 'i'

config/config_test.go:101: possible formatting directive in Fatal call
config/config_test.go:157: possible formatting directive in Fatal call

config/module/get_file_test.go:91: missing argument for Fatalf(%s): format reads arg 1, have only 0 args

helper/schema/schema.go:341: arg v.Type for printf verb %s of wrong type: schema.ValueType
helper/schema/schema.go:656: missing argument for Errorf(%s): format reads arg 2, have only 1 args
helper/schema/schema.go:912: arg schema.Type for printf verb %s of wrong type: schema.ValueType

terraform/context.go:178: arg v.Type() for printf verb %s of wrong type: github.com/hashicorp/terraform/config.VariableType
terraform/context.go:486: arg c.Operation for printf verb %s of wrong type: terraform.walkOperation

terraform/diff_test.go💯 arg actual for printf verb %s of wrong type: terraform.DiffChangeType
terraform/diff_test.go:235: arg actual for printf verb %s of wrong type: terraform.DiffChangeType
2014-11-02 13:56:44 +01:00
Mitchell Hashimoto f63a5d24e9 helper/schema: diffs for sets should include the full set [GH-457]
Prior to this, the diff only contained changed set elements. The issue
with this is that `getSet`, the internal function that reads a set from
the ResourceData, expects that each level (state, config, diff, etc.)
has the _full set_ information. This change was done to fix merging
issues.

Because of this, we need to make sure the full set is visible in the
diff.
2014-10-21 10:49:53 -07:00
Mitchell Hashimoto 8f166458d2 Merge pull request #480 from hashicorp/f-fix-consul
Consul param should be "key"
2014-10-20 15:35:31 -07:00
Mitchell Hashimoto 39edc5dc04 helper/schema: diffing maps that are computed should not result in
change
2014-10-20 14:23:06 -07:00
Mitchell Hashimoto deec7194a3 helper/schema: validate maps properly [GH-461] 2014-10-19 20:33:00 -07:00
Mitchell Hashimoto 3e1169db61 helper/schema: validate string/bool types [GH-460] 2014-10-19 19:56:46 -07:00
Mitchell Hashimoto 686871310d terraform: input properly sends on only set input 2014-10-18 14:54:42 -07:00
Mitchell Hashimoto 2b50d44aa4 helper/schema: validate Set is a set type [GH-413] 2014-10-17 23:23:50 -07:00
Mitchell Hashimoto 2e703afdad helper/schema: valiate should ignore computed fields 2014-10-16 14:04:45 -07:00
Mitchell Hashimoto 12c178bc63 helper/schema: don't ask for input if provider default would not be nil 2014-10-12 17:37:52 -07:00
Mitchell Hashimoto 59349cca11 helper/schema: sets must be treated atomically within ResourceData
This fixes a seemingly minor issue (GH-255) around plans showing changes
when in fact there are none. But in reality this turned out to uncover a
really terrible bug.

The effect of what was happening was that multiple items in a set were
being merged. Now, they were being merged in the right order, so if you
didn't have rich types (lists in a set) then you never saw the effect
since the later value would overwrite the earlier. But with lists (such
as in security groups), you would end up with the lists merging. So, if
you had one ingress rule with CIDR blocks and one with SGs, then after
the merge both ingress rules would have BOTH CIDR and SGs, resulting in
an incorrect plan (GH-255).

This fixes the issue by introducing a `getSourceExact` bitflag to the
ResourceData source. When this is set, ALL data must come from this
level, instead of merging lower levels. In the case of sets and diffs,
this is exactly what you want: "Get me the set 'foo' from the config and
the config ONLY (not the state or diff or w/e)".

Andddddd its fixed.

GH-255
2014-10-11 10:40:54 -07:00
Mitchell Hashimoto dcaf653d6f helper/schema: properly detect that a list is computed 2014-10-09 19:09:06 -07:00
Mitchell Hashimoto 753f6c6f8e helper/schema: fix failing tests 2014-10-08 18:25:31 -07:00
Mitchell Hashimoto 00bdef3093 providers/aws: test tag removal 2014-10-08 18:21:21 -07:00
Mitchell Hashimoto a7c321a028 helper/scheam: support UI defaults 2014-09-29 14:00:35 -07:00
Mitchell Hashimoto 99044a1f14 Add descriptions for AWS inputs 2014-09-29 13:30:28 -07:00
Mitchell Hashimoto 901c1448b4 command: make the UI a look nicer 2014-09-29 13:12:06 -07:00
Mitchell Hashimoto d9596fa4d0 helper/schema: don't ask for input on fields that have a value 2014-09-29 11:16:19 -07:00