Commit Graph

673 Commits

Author SHA1 Message Date
Paul Hinze 028664a015 provider/digitalocean: acctest improvements
* Add SSH Keys to all droplets in tests, this prevents acctests from
   spamming account owner email with root password details
 * Add a new helper/acctest package to be a home for random string / int
   implementations used in tests.
 * Insert some random details into record tests to prevent collisions
 * Normalize config style in tests to hclfmt conventions
2016-01-04 15:30:35 -06:00
Radek Simko 4c6ceef9b8 helper/schema: Allow identification of a new resource in update func 2015-12-27 14:01:03 +01:00
James Nugent e976d6e787 testing: Use a copy of pre-destroy state in destroy check
In the acceptance testing framework, it is neccessary to provide a copy
of the state _before_ the destroy is applied to the check in order that
it can loop over resources to verify their destruction. This patch makes
a deep copy of the state prior to applying test steps which have the
Destroy option set and then passes that to the destroy check.
2015-12-10 13:14:17 -05:00
Paul Hinze edaf5795a5 Merge pull request #3257 from fatih/fix-nil-setting-schema
schema: delete non existing values
2015-12-08 20:15:00 -06:00
Paul Hinze 4bd4e18def core: use same logging setup for acctests
We weren't doing any log setup for acceptance tests, which made it
difficult to wrangle log output in CI.

This moves the log setup functions we use in `main` over into a helper
package so we can use them for acceptance tests as well.

This means that acceptance tests will by default be a _lot_ quieter,
only printing out actual test output. Setting `TF_LOG=trace` will
restore the full prior noise level.

Only minor behavior change is to make `ioutil.Discard` the default
return value rather than a `nil` that needs to be checked for.
2015-12-08 17:50:36 -06:00
Paul Hinze 99244c5597 helper/schema: skip provider input for deprecated fields
There's no reason that a field that's been deprecated should ever
prompt.

fixes #4033
2015-12-07 11:28:45 -06:00
Paul Hinze f1e7cec566 Merge pull request #3992 from svanharmelen/f-change-sets
core: change set internals and make (extreme) performance improvements
2015-12-04 09:03:43 -06:00
Sander van Harmelen ef4726bd50 Change Set internals and make (extreme) performance improvements
Changing the Set internals makes a lot of sense as it saves doing
conversions in multiple places and gives a central place to alter
the key when a item is computed.

This will have no side effects other then that the ordering is now
based on strings instead on integers, so the order will be different.
This will however have no effect on existing configs as these will
use the individual codes/keys and not the ordering to determine if
there is a diff or not.

Lastly (but I think also most importantly) there is a fix in this PR
that makes diffing sets extremely more performand. Before a full diff
required reading the complete Set for every single parameter/attribute
you wanted to diff, while now it only gets that specific parameter.

We have a use case where we have a Set that has 18 parameters and the
set consist of about 600 items (don't ask 😉). So when doing a diff
it would take 100% CPU of all cores and stay that way for almost an
hour before being able to complete the diff.

Debugging this we learned that for retrieving every single parameter
it made over 52.000 calls to `func (c *ResourceConfig) get(..)`. In
this function a slice is created and used only for the duration of the
call, so the time needed to create all needed slices and on the other
hand the time the garbage collector needed to clean them up again caused
the system to cripple itself. Next to that there are also some expensive
reflect calls in this function which also claimed a fair amount of CPU
time.

After this fix the number of calls needed to get a single parameter
dropped from 52.000+ to only 2! 😃
2015-11-22 14:21:28 +01:00
Paul Hinze c7dc1c10a3 helper/schema: skip StateFunc when value is nil
This takes the nil checking burden off of StateFunc.

fixes #3586, see that issue for further discussion
2015-11-20 14:07:18 -06:00
Paul Hinze 938281024f helper/schema: name test cases w/ strings
I promised myself that next time I jumped in this file I'd fix this up.
Now we don't have to manually index the file with comments, we can just
add descriptive names to the test cases!
2015-11-20 13:51:34 -06:00
Paul Hinze 6b6b5a43c3 provider/aws: serialize SG rule access to fix race condition
Because `aws_security_group_rule` resources are an abstraction on top of
Security Groups, they must interact with the AWS Security Group APIs in
a pattern that often results in lots of parallel requests interacting
with the same security group.

We've found that this pattern can trigger race conditions resulting in
inconsistent behavior, including:

 * Rules that report as created but don't actually exist on AWS's side
 * Rules that show up in AWS but don't register as being created
   locally, resulting in follow up attempts to authorize the rule
   failing w/ Duplicate errors

Here, we introduce a per-SG mutex that must be held by any security
group before it is allowed to interact with AWS APIs. This protects the
space between `DescribeSecurityGroup` and `Authorize*` / `Revoke*`
calls, ensuring that no other rules interact with the SG during that
span.

The included test exposes the race by applying a security group with
lots of rules, which based on the dependency graph can all be handled in
parallel. This fails most of the time without the new locking behavior.

I've omitted the mutex from `Read`, since it is only called during the
Refresh walk when no changes are being made, meaning a bunch of parallel
`DescribeSecurityGroup` API calls should be consistent in that case.
2015-11-18 12:39:59 -06:00
Radek Simko 1e3cc7b33f helper: Remove url helper (moved to go-getter) 2015-11-14 08:21:18 +00:00
Paul Hinze 7ffa66d1a5 ssh: accept private key contents instead of path
We've been moving away from config fields expecting file paths that
Terraform will load, instead prefering fields that expect file contents,
leaning on `file()` to do loading from a path.

This helps with consistency and also flexibility - since this makes it
easier to shift sensitive files into environment variables.

Here we add a little helper package to manage the transitional period
for these fields where we support both behaviors.

Also included is the first of several fields being shifted over - SSH
private keys in provisioner connection config.

We're moving to new field names so the behavior is more intuitive, so
instead of `key_file` it's `private_key` now.

Additional field shifts will be included in follow up PRs so they can be
reviewed and discussed individually.
2015-11-12 14:59:14 -06:00
James Nugent f4c03ec2a6 Reflect new comment format in stringer.go
As of November 8th 2015, (4b07c5ce8a), the word "Code" is prepended to
the comments in Go source files generated by the stringer utility.
2015-11-09 11:38:51 -05:00
Martin Atkins a67182543c Nicer error when list/map assigned to string argument.
Previous this would return the following sort of error:
expected type 'string', got unconvertible type '[]interface {}'

This is the raw error returned by the underlying mapstructure library.
This is not a helpful error message for anyone who doesn't know Go's
type system, and it exposes Terraform's internals to the UI.

Instead we'll catch these cases before we try to use mapstructure and
return a more straightforward message.

By checking the type before the IsComputed exception this also avoids
a crash caused when the assigned value is a computed list. Otherwise
the list of interpolations is allowed through here and then crashes later
during Diff when the value is not a primitive as expected.
2015-10-22 21:16:02 -07:00
Mitchell Hashimoto 344e7c26b5 fix a bunch of tests from go-getter import 2015-10-15 13:48:58 -07:00
Paul Hinze 2a179d1065 helper/schema: ValidateFunc support for maps 2015-10-14 15:10:22 -05:00
Panagiotis Moustafellos e4845f75cc removed extra parentheses 2015-10-08 15:48:04 +03:00
Martin Atkins cc8e8a55de helper/schema: Default hashing function for sets
A common issue with new resource implementations is not considering parts
of a complex structure that's used inside a set, which causes quirky
behavior.

The schema helper has enough information to provide a default reasonable
implementation of a set function that includes all non-computed attributes
in a deterministic way. Here we implement such a function and use it
when no explicit hashing function is provided.

In order to achieve this we encapsulate the construction of the zero
value for a schema in a new method schema.ZeroValue, which allows us to
put the fallback logic to the new default function in a single spot.
It is no longer valid to use &Set{F: schema.Set} and all uses of that
construct should be replaced with schema.ZeroValue().(*Set) .
2015-10-03 18:10:47 -07:00
Martin Atkins 3fde993978 Merge #3336: Remove local multierror package.
Instead, use ``github.com/hashicorp/go-multierror``.
2015-10-03 17:53:36 -07:00
Radek Simko 641b701830 schema: Make validation more strict 2015-10-03 14:29:19 -07:00
Sander van Harmelen 2ba8dc38fa Switch to go-multierror
It seems there are 4 locations left that use the `helper/multierror`
package, where the rest is TF settled on the `hashicorp/go-multierror`
package.

Functionally this doesn’t change anything, so I suggest to delete the
builtin version as it can only cause confusion (both packages have the
same name, but are still different types according to Go’s type system.
2015-09-27 18:58:48 -07:00
Fatih Arslan f269d4fc8c schema: add test for nil string case 2015-09-16 23:35:10 +03:00
Fatih Arslan 8e7fc240f9 schema: delete non existing values
We need to set the value to an empty value so the state file does
indeed change the value. Otherwise the obsolote value is still
intact and doesn't get changed at all. This means `terraform show`
still shows the obsolote value when the particular value is not
existing anymore. This is due the AWS API which is returning a null
instead of an empty string.
2015-09-16 23:26:27 +03:00
Anthony Scalisi 198e1a5186 remove various typos 2015-09-11 11:56:20 -07:00
Paul Hinze 7eb72e7a12 helper/schema: record schema version when destroy fails
This was just a missed exit from the resource.Apply function -
subsequent refreshes would add the SchemaVersion back into the state,
but having the state recorded once without the meta information can
cause problems with Atlas's remote state checksumming.
2015-08-03 15:53:15 -05:00
Clint f979fd7dee Merge pull request #2571 from TimeIncOSS/f-aws-autogenerated-elb-name
provider/aws: Allow ELB name to be generated
2015-07-21 15:52:36 -05:00
Radek Simko 9882cc59d8 aws: Add regression test for renaming ecs_cluster 2015-07-12 14:37:39 +01:00
Sander van Harmelen 4a8ef78d33 Fixes #2676 by prefixing all Windows commands
By prefixing them with `cmd /c` it will work with both `winner` and
`ssh` connection types.

This PR also reverts some bad stringer changes made in PR #2673
2015-07-10 12:56:27 +02:00
Sander van Harmelen 97fd4f5b7d Tweaking the tests 2015-07-09 21:29:27 +02:00
Paul Hinze 5c38456b05 core: don't prompt for variables with defaults
In `helper/schema` we already makes a distinction between `Default`
which is always applied and `InputDefault` which is displayed to the
user for an empty field.

But for variables we just have `Default` which is treated like
`InputDefault`. This changes it to _not_ prompt the user for a value
when the variable declaration includes a default.

Treating this as a UX bugfix and the "don't prompt for variables w/
defaults set" behavior as the originally expected behavior we were
failing to honor.

Added an already-passing test to verify and cover the `helper/schema`
behavior.

Perhaps down the road we can add a `input_default` attribute to
variables to allow similar behavior to `helper/schema` in variables, but
for now just sticking with the fix.

Fixes #2592
2015-07-02 10:40:30 -05:00
Radek Simko 70b7243dd6 helper: Add resource.PrefixedUniqueId 2015-06-30 12:54:54 +01:00
Mitchell Hashimoto 2f08a2bb15 Merge pull request #2507 from hashicorp/b-set-remove
helper/schema: diff should include removed set items [GH-1823]
2015-06-26 08:18:28 -07:00
Mitchell Hashimoto 0100d4139b helper/schema: clean up style 2015-06-25 22:01:54 -07:00
Mitchell Hashimoto 6e509aedcb helper/schema: diff should include removed set items [GH-1823] 2015-06-25 21:52:49 -07:00
Paul Hinze 7238b3b4af core: encapsulate representation of StringList
Now the only code that cares about how StringLists are represented lives
inside string_list.go

...which gives us the ability to change it! :)
2015-06-25 17:55:57 -05:00
Paul Hinze 10b3abf405 config: introduce StringList to abstract over list hack
This is the initial pure "all tests passing without a diff" stage. The
plan is to change the internal representation of StringList to include a
suffix delimiter, which will allow us to recognize empty and
single-element lists.
2015-06-25 17:55:56 -05:00
Radek Simko 6fdbca8e58 Merge pull request #2466 from TimeIncOSS/f-schema-field-name-validate
schema: Add field name to ValidateFunc
2015-06-24 18:52:53 +01:00
Mitchell Hashimoto 6b7c2bcb35 Merge pull request #2450 from hashicorp/b-schema-validate-type
helper/schema: validate objects are objects [GH-2166]
2015-06-24 10:35:26 -07:00
Mitchell Hashimoto 630646335f Merge pull request #2451 from hashicorp/b-provider-validate
helper/schema: internal validate as part of provider validation
2015-06-24 10:28:49 -07:00
Radek Simko 92db4802b6 schema: Add field name to ValidateFunc 2015-06-24 18:22:12 +01:00
Mitchell Hashimoto 4e7fcd4f42 helper/schema: test that validatefunc is not called with computed vals 2015-06-23 22:10:46 -07:00
Mitchell Hashimoto e36597cad7 helper/schema: internal validate as part of provider validation
[GH-1291]
2015-06-23 16:52:04 -07:00
Mitchell Hashimoto 4f391902a0 helper/schema: validate objects are objects [GH-2166] 2015-06-23 16:39:02 -07:00
Paul Hinze aa8cf572a8 Merge pull request #2265 from hashicorp/f-schema-validate-field
Support arbitrary per-field schema validation
2015-06-22 18:01:54 -05:00
Paul Hinze 385b17d679 provider/template: don't error when rendering fails in Exists
The Exists function can run in a context where the contents of the
template have changed, but it uses the old set of variables from the
state. This means that when the set of variables changes, rendering will
fail in Exists. This was returning an error, but really it just needs to
be treated as a scenario where the template needs re-rendering.

fixes #2344 and possibly a few other template issues floating around
2015-06-17 15:33:07 -05:00
Paul Hinze a4912cc51f helper/schema: limit ValidateFunc to primitives for now
I couldn't see a simple path get this working for Maps, Sets,
and Lists, so lets land it as a primitive-only schema feature.

I think validation on primitives comprises 80% of the use cases anyways.
2015-06-11 07:06:30 -05:00
Paul Hinze 49352db26f helper/schema: skip ValidateFunc on other errors
Guarantees that the `interface{}` arg to ValidateFunc is the proper
type, allowing implementations to be simpler.

Finish the docstring on `ValidateFunc` to call this out.

/cc @mitchellh
2015-06-08 08:55:45 -05:00
Paul Hinze 61fee6735d helper/schema: ValidateFunc
Allows provider authors to implement arbitrary per-field validation
warnings or errors.
2015-06-08 08:47:41 -05:00
Svend Sorensen 943bf3c00a Use name of function in comment string
Name of function is Difference, not Differences.
2015-06-04 13:03:01 -07:00
Clint Shryock 78e7519efa Updates from go generate 2015-06-03 08:37:57 -05:00
Sam Boyer b82bd0c280 Condense switch fallthroughs into expr lists 2015-05-26 21:52:36 -04:00
Mitchell Hashimoto dd24ed4b76 helper/schema: blank ID refresh doesn't exist [GH-1905] 2015-05-13 20:15:13 -07:00
Justin Campbell bb14bfa657 helper/schema: call InternalValidate w/ schemaMap{} 2015-05-12 11:01:08 -04:00
Paul Hinze 1e3d1b07e6 helper/schema: validate ConflictsWith against top-level
The runtime impl of ConfictsWith uses Resource.Get(), which makes it
work with any other attribute of the resource - the InternalValidate was
only checking against the local schemaMap though, preventing subResource
from using ConflictsWith properly.

It's a lot of wiring and it's a bit ugly, but it's not runtime code, so
I'm a bit less concerned about that aspect.

This should take care of the problem mentioned in #1909
2015-05-12 09:45:15 -05:00
Paul Hinze a96a3372c6 provider/template: don't diff when there's no diff
This reworks the template lifecycle a bit such that we get nicer diff
behavior.

First, we tick ForceNew on for both filename and vars, so that the diff
indicates that the template will be "replaced" on change. This is mostly
cosmetic, but it also tracks conceptually with the fact that the
identifier we use is a hash of the contents, so any change essentially
makes a "new resource".

Second, we change the Exists implementation to only return `false` when
there has been a change in the rendered template. This lets descendent
resources see the computed value changing so that they'll properly
trigger in the plan.

Fixes #1898
Refs #1866 (but does not fix, there's another deeper issue there)
2015-05-11 10:38:19 -05:00
Paul Hinze bc9792f4c5 helper/schema: tweak test anotation 2015-05-07 10:39:17 -05:00
Paul Hinze 051ba78554 Merge pull request #1824 from hashicorp/b-write-count-for-empty-maps
helper/schema: write "attr.#": "0" for empty maps
2015-05-07 10:38:32 -05:00
Andrew Langhorn bb4f7415ca Rename "The The" so that they can play songs again
Other than the fact that "The the" doesn't really make any sense anywhere
that it's used in Terraform, they're a post-punk band from the UK.

Fixes "The The" so that they can get back to playing songs.
2015-05-06 22:53:11 +01:00
Paul Hinze fbce3a3caa helper/resource: don't fail test on config warnings
AccTests like TestAccComputeInstance_basic_deprecated_network were
failing early on "invalid config" when we are explictly testing behavior
that we know generates warnings.
2015-05-06 13:17:56 -05:00
Paul Hinze f2368428d3 helper/schema: write "attr.#": "0" for empty maps
This fixes some perpetual diffs I saw in Atlas AccTests where an empty
map (`map[string]interface{}{}`) was being `d.Set` for "metadata_full".

Because the MapFieldWriter was not distinguishing between empty and nil,
this trigger the "map delete" logic and no count was written to the
state. This caused subsequent plans to improperly report a diff.

Here we redefine the map delete functionality to explicitly trigger only
on `nil`, so we catch the `.#` field for empty maps.
2015-05-06 10:21:22 -05:00
Paul Hinze cebcee5c63 Merge pull request #1778 from josharian/template-provider
providers: add template provider
2015-05-05 20:09:27 -05:00
Phil Frost b082117e92 Implement AWS IAM resources
- Users
- Groups
- Roles
- Inline policies for the above three
- Instance profiles
- Managed policies
- Access keys

This is most of the data types provided by IAM. There are a few things
missing, but the functionality here is probably sufficient for 95% of
the cases. Makes a dent in #28.
2015-05-05 12:47:20 -04:00
Phil Frost 33183c078b Implement a hash function for string sets
Sets of strings are pretty common. Let's not duplicate the function
necessary to create a set of strings in so many places.
2015-05-05 12:47:18 -04:00
Paul Hinze a3101568c5 helper/schema: add clarifying GetOk test
Wrote this test to verify behavior, committing and commenting to help me
get the answer faster in the future.
2015-05-04 14:58:12 -05:00
Josh Bleecher Snyder 76bcac3031 providers/template: add tests, address review comments
Do directory expansion on filenames.

Add basic acceptance tests. Code coverage is 72.5%.
Uncovered code is uninteresting and/or impossible error cases.

Note that this required adding a knob to
helper/resource.TestStep to allow transient
resources.
2015-05-04 10:26:17 -07:00
Paul Hinze 1671f1e50c Merge pull request #1762 from hashicorp/f-add-test-for-nested-set-statefunc
helper/schema: add test for statefunc with nested sets
2015-05-01 20:07:44 -05:00
Paul Hinze 15c75c501f Merge pull request #1483 from svanharmelen/f-winrm-support
core: add WinRM support
2015-05-01 15:56:53 -05:00
Sander van Harmelen c9e9e374bb Adding some abstractions for the communicators
This is needed as preperation for adding WinRM support. There is still
one error in the tests which needs another look, but other than that it
seems like were now ready to start working on the WinRM part…
2015-05-01 18:48:54 +02:00
Paul Hinze 88744d569f helper/resource/testing: unit tests to cover #1770
Also clarified that final return value of testStep is now only for the
happy path.
2015-05-01 11:22:06 -05:00
Paul Hinze dbf6d1bd00 helper/resource: fix accidentaly swallowing of acctest step errors
With #1757 I unwittingly reused an err variable, causing all test check
errors to be swallowed. -_-
2015-05-01 11:11:16 -05:00
Paul Hinze cb3cbffb19 helper/schema: add test for statefunc with nested sets
refs #1759
2015-04-30 15:20:33 -05:00
Paul Hinze 149e52ad1f helper/resource: verify refresh+plan after each step
I forgot to add `Computed: true` when I made the "key_name" field
optional in #1751.

This made the behavior:

 * Name generated in Create and set as ID
 * Follow up plan (without refresh) was nice and empty
 * During refresh, name gets cleared out on Read, causing a bad diff on
   subsequent plans

We can automatically catch bugs like this if we add yet another
verification step to our resource acceptance tests -> a post
Refresh+Plan that we verify is empty.

I left the non-refresh Plan verification in, because it's important that
_both_ of these are empty after an Apply.
2015-04-30 12:52:25 -05:00
Mitchell Hashimoto b96027ac87 Merge pull request #1656 from tpounds/bug-fix-prevent-neg-hash-all-operations
helper/schema: Prevent negative hashcodes for all set operations.
2015-04-28 20:49:53 -07:00
Phil Frost bd8ac4fe5e Better document StateChangeConf.WaitForState 2015-04-28 12:33:23 -04:00
Trevor Pounds 17b31925fe Prevent negative hashcodes for all set operations. 2015-04-23 09:32:07 -07:00
Mitchell Hashimoto 10fa50ce35 Merge pull request #1654 from hashicorp/b-neg-code
helper/schema: allow set items with hyphens
2015-04-23 17:36:30 +02:00
Mitchell Hashimoto 707aa36aec helper/schema: only use ~ on first char of code 2015-04-23 17:20:54 +02:00
Mitchell Hashimoto 77314a01d2 helper/schema: disallow negative hash codes 2015-04-23 16:57:26 +02:00
Paul Hinze 92ebb60293 helper/resource: ok let's actually use RFC4122 2015-04-22 13:16:44 -05:00
Paul Hinze d1106e9e22 helper/resource: add UniqueId() helper
A generic function for provider resources to use to get a unique
identifier.
2015-04-22 12:53:05 -05:00
Mitchell Hashimoto 1f46bc1926 helper/schema: validate unknown fields with computed values [GH-1507] 2015-04-22 12:52:26 +02:00
Mitchell Hashimoto 3176e5b44a Merge pull request #1595 from TimeIncOSS/aws-account-protection
aws: Allow defining blacklist/whitelist of account IDs
2015-04-22 08:08:01 +02:00
Mitchell Hashimoto 54e3e6104e Merge pull request #1594 from TimeIncOSS/schema-conflicts-with
helper/schema: add schema.ConflictsWith[]
2015-04-22 08:04:49 +02:00
Mitchell Hashimoto 51951d68f4 helper/schema: change diff logic around maps to fix case #57 and #44 2015-04-21 22:13:03 +02:00
Mitchell Hashimoto 9c10a89cf8 helper/schema: FieldReaderMap should mark map as exists if anything set 2015-04-21 22:11:00 +02:00
Mitchell Hashimoto fa934d96d0 helper/schema: FieldReaderConfig detects computed maps 2015-04-21 22:07:52 +02:00
Mitchell Hashimoto dc69603cd4 helper/resource: docs 2015-04-20 14:14:34 -07:00
Matt Good 21b0a03d70 Support for multiple providers of the same type
Adds an "alias" field to the provider which allows creating multiple instances
of a provider under different names. This provides support for configurations
such as multiple AWS providers for different regions. In each resource, the
provider can be set with the "provider" field.

(thanks to Cisco Cloud for their support)
2015-04-20 14:14:34 -07:00
Radek Simko 150fd00932 AWS account ID protection added 2015-04-20 12:07:39 +01:00
Radek Simko 34f48b3e06 Add schema.ConflictsWith[]
- this will allow defining logically conflicting attributes
2015-04-20 12:07:34 +01:00
Radek Simko e0df74c863 Add schema.ConflictsWith[]
- this will allow defining logically conflicting attributes
2015-04-20 12:07:00 +01:00
Mitchell Hashimoto de8666a5fa helper/ssh: add random number to script [GH-1545] 2015-04-18 16:09:08 -07:00
Mitchell Hashimoto 968a152df4 Merge pull request #1443 from hashicorp/f-acc-tests-check-empty-plan
providers: check for empty plan after each test step
2015-04-14 08:30:11 -07:00
Sander van Harmelen d90b3aa332 Merge pull request #1469 from svanharmelen/b-communicator-tests
Fixing up the communicator tests
2015-04-09 23:46:59 +02:00
Sander van Harmelen 02a41a8802 Fixing up the communicator tests
It turned out the tests didn’t work as expected due to some missing
config in the `newMockLineServer` and a defer located in the wrong
location. All is good again now…
2015-04-09 23:40:40 +02:00
Mitchell Hashimoto db58c7dd33 providers/docker: default cert_path to non-nil so input isn't asked 2015-04-09 09:49:03 -07:00
Paul Hinze 7fe34d4547 providers: check for empty plan after each test step
Each acceptance test step plays a Refresh, Plan, Apply for a given
config. This adds a follow up Plan and fails the test if it does not
come back empty. This will catch issues with perpetual, unresolvable
diffs that crop up here and there.

This is going to cause a lot of our existing acceptance tests to fail -
too many to roll into a single PR. I think the best plan is to land this
in master and then fix the failures (each of which should be catching a
legitimate provider bug) one by one until we get the provider suites
back to green.
2015-04-09 10:19:01 -05:00
Paul Hinze 66dbf91ffd helper/schema: ensure ForceNew set when Update is not
If a given resource does not define an `Update` function, then all of
its attributes must be specified as `ForceNew`, lest Applys fail with
"doesn't support update" like #1367.

This is something we can detect automatically, so this adds a check for
it when we validate provider implementations.
2015-04-03 09:57:30 -05:00
Tarrant f68c9eee63 Merge branch 'master' of https://github.com/hashicorp/terraform 2015-04-01 18:24:57 -07:00
Tarrant 6ad812e3d8 Merge branch 'ssh_agent' 2015-03-31 17:49:55 -07:00
Paul Hinze 97acccd3ed core: targeted operations
Add `-target=resource` flag to core operations, allowing users to
target specific resources in their infrastructure. When `-target` is
used, the operation will only apply to that resource and its
dependencies.

The calculated dependencies are different depending on whether we're
running a normal operation or a `terraform destroy`.

Generally, "dependencies" refers to ancestors: resources falling
_before_ the target in the graph, because their changes are required to
accurately act on the target.

For destroys, "dependencies" are descendents: those resources which fall
_after_ the target. These resources depend on our target, which is going
to be destroyed, so they should also be destroyed.
2015-03-31 14:49:38 -05:00
Tarrant 05407296c6 Add cleanup function to close SSHAgent 2015-03-20 18:18:35 -07:00
Paul Hinze 3ba8ed536b helper/schema: record schema version on apply
We were previously only recording the schema version on refresh. This
caused the state to be incorrectly written after a `terraform apply`
causing subsequent commands to run the state through an unnecessary
migration.
2015-03-18 19:08:48 -05:00
Tarrant 164f303da4 Add SSH Agent support 2015-03-15 16:12:59 -07:00
Paul Hinze 558775d115 Merge pull request #1184 from hashicorp/f-update-ssh-import
helper/ssh: update import location
2015-03-11 16:57:12 -05:00
Paul Hinze a24c21bd2c Merge pull request #1152 from hashicorp/f-helper-schema-versioning
helper/schema: schema versioning & migration
2015-03-11 15:54:22 -05:00
Paul Hinze 85caf9d8d7 helper/ssh: update import location
go's ssh package now lives canonically at `golang.org/x/crypto/ssh`

see https://godoc.org/golang.org/x/crypto/ssh

closes #1179
2015-03-11 15:48:47 -05:00
Paul Hinze 3d4b55e557 helper/schema: schema versioning & migration
Providers get a per-resource SchemaVersion integer that they can bump
when a resource's schema changes format. Each InstanceState with an
older recorded SchemaVersion than the cureent one is yielded to a
`MigrateSchema` function to be transformed such that it can be addressed
by the current version of the resource's Schema.
2015-03-06 16:26:11 -06:00
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
Paul Hinze 000238835c helper/schema: [tests] add names to Validate tests
a process also known as 'paulification' :)
2015-03-05 12:28:53 -06:00
Mitchell Hashimoto 58a8776c41 helper/schema: test real nil pointer to ResourceData.Set 2015-03-02 23:37:43 -08:00
Mitchell Hashimoto c030148259 helper/schema: allow pointer values to ResourceData.Set 2015-03-02 21:06:14 -08:00
Mitchell Hashimoto 2feaebdca5 config: substring containing computed value replaces element 2015-02-27 21:51:14 -08:00
Jack Pearkes c180487af6 helper/resource: allow configuration of not found checks in state change 2015-02-26 09:59:42 -08:00
Mitchell Hashimoto 0bc0c03fec helper/schema: zero value set should set function [GH-1009] 2015-02-19 11:26:02 -08:00
Mitchell Hashimoto 9b8b38cbb1 helper/schema: test that set can be nil 2015-02-18 14:59:55 -08:00
Mitchell Hashimoto e4f0f6b15d helper/schema: more tests 2015-02-18 14:44:46 -08:00
Mitchell Hashimoto dd00001c9a helper/schema: tests that all pass as I was trying to track down a bug 2015-02-18 14:10:12 -08: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 7d32c8946a helper/schema: GetOk now only returns true if set to non-zero value 2015-02-17 16:55:39 -08:00
Mitchell Hashimoto e04def93e6 Merge pull request #991 from hashicorp/b-autoscale-lc-update
providers/aws: allow in-place update of launch configuration
2015-02-17 16:29:56 -08:00
Mitchell Hashimoto faec39b8c1 Merge pull request #990 from hashicorp/b-set-change
helper/schema: GetChange shouldn't return true when no change
2015-02-17 16:17:44 -08:00
Mitchell Hashimoto 5a64d0900b providers/aws: test for allowing in-place lC update 2015-02-17 16:12:02 -08:00
Mitchell Hashimoto 66f7731995 helper/schema: GetChange shouldn't return true when no change 2015-02-17 15:43:19 -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 e9778c85a5 helper/schema: clarify test 2015-02-17 14:46:24 -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 fd274d7328 helper/schema: update test desc 2015-02-17 13:17:23 -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 ad6be99f5b helper/schema: failing test 2015-02-17 13:15:30 -08:00
Mitchell Hashimoto 2ee2b9e26f Merge pull request #986 from hashicorp/b-remove-set
helper/schema: Diff with set going to 0 elements removes it from state
2015-02-17 11:50:50 -08:00
Mitchell Hashimoto 2212d6895d helper/schema: diff with set going to 0 elements removes it from state 2015-02-17 11:38:56 -08:00
Mitchell Hashimoto c22ba7d3a8 helper/schema: fix test index 2015-02-17 11:14:04 -08:00
Mitchell Hashimoto cbcfb26ec6 helper/schema: add test for sets 2015-02-17 11:12:45 -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
Mitchell Hashimoto 61215d8826 Merge pull request #919 from ceh/url-helper
helper/url: add "Windows-safe" URL Parse wrapper
2015-02-17 09:26:55 -08:00
Clint Shryock 4c7b732dad typo 2015-02-11 14:49:50 -08:00
Clint Shryock 5602348695 formatting, cleanups 2015-02-11 11:40:49 -08:00
Clint Shryock a5040ecc03 Update hashcode to always generate a positive 2015-02-11 10:59:21 -08:00
Emil Hessman e7bbbfb098 helper/url: add Windows 'safe' URL Parse wrapper
Pull out the urlParse function, which was introduced in config/module,
into a helper package.
2015-02-05 11:16:54 +01:00
Paul Hinze 26156981d7 Merge pull request #917 from methane/fix-stringer
Fix stringer error on helper/schema/schema.go
2015-02-04 10:09:53 -06:00
Paul Hinze 4e8e3dad86 DiffFieldReader: filter all '#' fields from sets
Now that readMap filters out '#' fields, when maps are nested in sets,
we exposed a related bug where a set was iterating over nested maps and
expected the '#' key to be present in those nested maps.

By skipping _all_ count fields when iterating over set keys, all is
right with the world again.
2015-02-04 09:25:45 -06:00
Paul Hinze 219aa3e788 helper/schema: fix DiffFieldReader map handling
An `InstanceDiff` will include `ResourceAttrDiff` entries for the
"length" / `#` field of maps. This makes sense, since for something like
`terraform plan` it's useful to see when counts are changing.

The `DiffFieldReader` was not taking these entries into account when
reading maps out, and was therefore incorrectly returning maps that
included an extra `'#'` field, which was causing all sorts of havoc
for providers (extra tags on AWS instances, broken google compute
instance launch, possibly others).

 * fixes #914 - extra tags on AWS instances
 * fixes #883 - general core issue sprouted from #757
 * removes the hack+TODO from #757
2015-02-03 20:17:57 -06:00
INADA Naoki f6367a779a regenerate with new stringer. 2015-02-04 01:54:14 +09:00
INADA Naoki 33aa9d3ee8 Fix stringer error on helper/schema/schema.go 2015-02-03 19:33:01 +09:00
Dave Cunningham aa2015ccd0 Fix failing tests 2015-01-28 16:20:14 -05:00
Dave Cunningham 3cbf1a3230 Fix missing import of math 2015-01-28 15:39:32 -05:00
Dave Cunningham 319933f551 Add some tests for TypeFloat 2015-01-28 15:22:47 -05: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 0a7dea5532 Improve readability and purpose of multi-env default test 2015-01-22 16:09:25 -05:00
Seth Vargo 072a1cf353 Read the "standard" AWS environment variables
This is 100% backwards-compatible
2015-01-22 16:09:25 -05:00
Mitchell Hashimoto 466a54cfe4 Merge pull request #766 from hashicorp/f-exists-api
helper/schema: Exists API
2015-01-16 10:56:25 -08:00
Mitchell Hashimoto 41029f8daa helper/schema: tests for EnvDefaultFunc
/cc @jefferai - In case you care
2015-01-16 10:54:43 -08:00
Mitchell Hashimoto b3e77ef244 Merge pull request #825 from jefferai/envdefault
Move duplicated envDefaultFunc out of each provider and into Schema.
2015-01-16 10:50:43 -08:00
Mitchell Hashimoto 87948b68fc helper/schema: use interface for equality check
/cc @svanharmelen
2015-01-16 09:32:15 -08:00
Jeff Mitchell f2bd1f45ab Move duplicated envDefaultFunc out of each provider and into Schema. 2015-01-16 17:25:39 +00:00
Mitchell Hashimoto 8cba4a40f5 Merge pull request #821 from svanharmelen/b-core-haschange-getchange
core: fixing two related bugs in HasChange and GetChange
2015-01-16 09:10:06 -08:00
Mitchell Hashimoto e32cd396ad helper/schema: add test for GH-814 2015-01-16 08:37:25 -08:00
Sander van Harmelen c7550595a3 Fixing two related bugs in HasChange and GetChange
This was actually quite nasty as the first bug covered the second one…

The first bug is with HasChange. This function uses reflect.DeepEqual
to check if two instances are the same/have the same content. This
works fine for all types except for Set’s as they contain a function.
And reflect.DeepEqual will only say the functions are equal if they are
both nil (which they aren’t in a Set). So in effect it means that
currently HasChange will always say true for Set’s, even when they are
actually being equal.

As soon as you fix this problem, you will notice the second one (which
the added test is written for). Without saying you want the exact diff,
you will end up with a merged value which will (in most cases) be the
same.

Run all unit tests and a good part of the acc tests to verify this
works as expected and all look good.
2015-01-16 14:13:40 +01:00
Sander van Harmelen 2edfd0e89d Just my OCD playing up 😉 2015-01-16 13:30:11 +01:00
Greg Osuri 2769d7cf9c Fixes #813: Ensuring set count (.#) is written to the state 2015-01-16 03:43:57 -08:00
Greg Osuri f870eff5f9 core: fix for #813 - added a gaurd for interface conversion 2015-01-16 00:16:38 -08:00
Mitchell Hashimoto 448887f3c4 helper/schema: map counts in state 2015-01-15 14:12:24 -08:00
Mitchell Hashimoto 22436555a7 helper/schema: test setting computed value and retrieving it via state 2015-01-15 11:08:06 -08:00
Mitchell Hashimoto 4d067f4d6d helper/schema: don't put things into the state that don't exist or are
computed [GH-805]
2015-01-15 10:35:44 -08:00
Sander van Harmelen 133a40d77f Sets should init only once...
Currently the `sync.Once` call is only used to init a Set in the add()
func. So when you add a value to a Set that is the result of one of the
Set operations (i.e. union, difference, intersect) the Set will be
reinitialised and the exiting values will be lost.

I don’t have a clue why this is showing up in my ACC tests just now, as
this code is in there for quite some time already. Somehow it seems to
have something to do with the refactoring of the helper/schema done
last week, as I cannot reproduce this with
47f02f80bc
2015-01-15 15:33:52 +01:00
Mitchell Hashimoto 2abeb2d9ac config: use new API 2015-01-14 22:03:15 -08:00
Mitchell Hashimoto db02541d31 helper/schema: fix failing tests
/cc @svanharmelen - I think some logic changed after my refactor. I now
return Exists: true when Computed: true but the value might be blank to
note that the FieldReader FOUND a value, its just unknown. I think
before it didn't do that so the logic for GetOk has to be "does it exist
and is it _not_ computed"

Seems weird because I just realized there is no way to get the OLD value
of something if it is being computed now, but I looked and there are
tests that verify this and they're like... test #5 of Get. So, they're
not new meaning that must've been expected behavior? Hm. Let me know if
you find any other issues from acceptance tests
2015-01-14 15:38:18 -08:00
Mitchell Hashimoto 05de36b4ea Merge pull request #796 from svanharmelen/f-test-issue-791
Adding a test for issue #791
2015-01-14 15:31:28 -08:00
Mitchell Hashimoto d3c0543bf3 Merge pull request #797 from hashicorp/f-stronger-types
Force variables to be typed (internally)
2015-01-14 15:30:38 -08:00
Mitchell Hashimoto e00ee1e5ee helper/diff: fix failing test 2015-01-14 15:29:56 -08:00
Mitchell Hashimoto dbe83af829 helper/schema: fix failing tests 2015-01-14 15:28:36 -08:00
Sander van Harmelen cb37e10c6f Adding a test for issue #791
Running this test on commit 47f02f80bc
from 6 days ago, is successful, but on master it now fails.
2015-01-14 20:50:58 +01: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 6fadebc5d8 Merge pull request #769 from phinze/type-float-failing-diff-test
failing schema diff test for TypeFloat
2015-01-14 09:30:08 -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
Paul Hinze bcac8c64bd failing schema diff test for TypeFloat
refs #768
2015-01-11 14:51:48 -06:00
Mitchell Hashimoto 1fcd24cf67 helper/schema: add float type 2015-01-10 16:04:01 -08:00
Mitchell Hashimoto cf94a79955 helper/schema: add TypeFloat and Zero value 2015-01-10 15:57:06 -08:00
Mitchell Hashimoto 34617b337f helper/schema: remove commit not for this branch 2015-01-10 15:53:29 -08:00
Mitchell Hashimoto 689cbc8b5b helper/schema: generate strings for ValueType 2015-01-10 15:52:11 -08:00
Mitchell Hashimoto 48b9614556 helper/schema: Exists API 2015-01-10 15:39:29 -08:00
Mitchell Hashimoto 3cbcafe989 helper/schema: remove unused field 2015-01-10 12:50:53 -08:00
Mitchell Hashimoto 361d00347a helper/schema: refactor tests for fieldreader to be common 2015-01-10 12:42:15 -08:00
Mitchell Hashimoto 9ab128899a helper/schema: make the getSource enum easier 2015-01-10 12:25:34 -08:00
Mitchell Hashimoto d89446391a helper/schema: make the get API cleaner 2015-01-10 12:22:05 -08:00
Mitchell Hashimoto 3c1b55a75f helper/schema: use the field reader/writer for state 2015-01-10 12:18:32 -08:00
Mitchell Hashimoto f64b09a045 helper/schema: more tests 2015-01-10 11:49:37 -08:00
Mitchell Hashimoto e77b2b17c4 helper/schema: remove unused method 2015-01-10 11:46:09 -08:00
Mitchell Hashimoto 03c6453a72 helper/schema: FieldWriter, replace Set 2015-01-10 11:44:26 -08:00
Mitchell Hashimoto e9a4aaaca7 helper/schema: full object test for addrToSchema 2015-01-09 17:43:44 -08:00
Mitchell Hashimoto e57f3f69b1 helper/schema: empty maps, support reading objects directly 2015-01-09 15:07:02 -08:00
Mitchell Hashimoto f0af1c36f5 helper/schema: nested resource fields should be zero-valued on get 2015-01-09 11:51:29 -08:00
Mitchell Hashimoto 942a988ac2 helper/schema: zero value of a set should be a set 2015-01-08 18:48:03 -08:00
Mitchell Hashimoto b4bf813151 helper/schema: too big to fail 2015-01-08 18:02:19 -08:00
Mitchell Hashimoto 864a8f24ec helper/schema: GoString for Set 2015-01-08 11:33:15 -08:00
Mitchell Hashimoto 7e379cb1a1 helper/schema: field readers no longer take a schema as arg 2015-01-03 12:13:46 -05:00
Mitchell Hashimoto 3ff859d734 helper/schema: MultiLevelFieldReader 2015-01-03 10:32:24 -05:00
Mitchell Hashimoto 0b1da37b20 helper/schema: diff field reader should merge result with source 2015-01-03 09:55:38 -05:00
Mitchell Hashimoto 91a57b42e8 helper/schema: reading a diff with computed should return zero value 2015-01-03 12:02:49 +05:30
Mitchell Hashimoto 73726e83b2 helper/schema: DiffFieldReader for reading data from a diff 2014-12-20 02:17:35 +05:30
Mitchell Hashimoto 9447973015 helper/schema: ConfigFieldReader and generic helpers 2014-12-19 22:52:53 +05:30
Mitchell Hashimoto 5f063d321f helper/schema: FieldReader needs to return computed status 2014-12-19 06:15:04 -05:00
Mitchell Hashimoto f416e0edf0 helper/schema: FieldReader and MapFieldReader 2014-12-19 05:56:46 -05:00
Mitchell Hashimoto e8ac16b2df helper/schema: test for empty state 2014-12-16 15:56:40 -08: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 4c23019ab7 core: fixing new test
Removed the ‘hashcode’ function so we didn’t need to import it here,
but also removed the needed type assertion.
2014-12-12 15:42:01 +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 1792334ec4 fmt 2014-10-21 11:00:12 -07:00
Mitchell Hashimoto 81913c58fb providers/aws: fixing faililng test 2014-10-21 10:57:55 -07:00
Mitchell Hashimoto 61811fce23 helper/schema: remove debug info 2014-10-21 10:54:44 -07: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 d0ce67a5b7 helper/schema: on destroy/create, reset state to be empty [GH-464] 2014-10-21 00:28:53 -07:00
Mitchell Hashimoto d1324678dd helper/schema: setting empty map works [GH-464] 2014-10-21 00:17:17 -07:00
Mitchell Hashimoto 9ecbbc6fa0 helper/schema: some more unit tests 2014-10-20 23:52:22 -07:00
Mitchell Hashimoto 17d1bb7dde Revert "Merge pull request #422 from svanharmelen/f-shaving-off-some-cpu-cycles"
This reverts commit 428cce2478, reversing
changes made to 517c5b2ea8.
2014-10-20 23:14:14 -07:00
Mitchell Hashimoto 428cce2478 Merge pull request #422 from svanharmelen/f-shaving-off-some-cpu-cycles
helper/schema: Shaving off some unneeded calls, saving CPU cycles
2014-10-20 23:13:18 -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 5390357e45 helper/schema: sets properly take into account the diff 2014-10-20 15:32:30 -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 37930f51a1 helper/schema: test case for boolean diffs 2014-10-20 14:08:56 -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 b4f8b7f43b helper/resource: RetryError for quitting quickly 2014-10-17 18:28:03 -07:00
Mitchell Hashimoto 2e703afdad helper/schema: valiate should ignore computed fields 2014-10-16 14:04:45 -07:00
Sander van Harmelen e003334429 Shaving off some unneeded calls, saving CPU cycles
I know it’s very unlikely that a user will notice the difference, but
why range through the list, generate the set and calculate the
hashcode, only to find out that indexMap == nil (e.g. don’t do anything
with the generated hashcode).

As indexMap is only needed when len(parts) > 0, why not only create and
fill it (in one go) when len(parts) > 0?
2014-10-16 11:54:36 +02:00
Armon Dadgar 5a3f80559c helper/ssh: Cleanups 2014-10-13 12:48:06 -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 30786ce442 fmt 2014-10-11 10:47:07 -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 3a107d2e50 helper/schema: set the field to empty if it is a list and computed 2014-10-10 15:58:38 -07:00
Mitchell Hashimoto e5d64318bf helper/schema: don't say that a set is computed if it exists 2014-10-10 15:46:24 -07:00
Mitchell Hashimoto 36f225dea0 fmt 2014-10-10 14:50:35 -07:00
Mitchell Hashimoto e0994c717d helper/schema: fix issues around computed sets 2014-10-10 09:13:04 -07:00
Mitchell Hashimoto 539eca5ee6 Fix failing tests 2014-10-09 21:29:21 -07:00
Mitchell Hashimoto dcaf653d6f helper/schema: properly detect that a list is computed 2014-10-09 19:09:06 -07:00
Mitchell Hashimoto 3aa655ad3b helper/schema: test schema diffs with the interpolation splits 2014-10-09 16:31:24 -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 6eafac8a34 providers/aws: aws_vpc supports tags 2014-10-08 17:54:00 -07:00
Mitchell Hashimoto f43528957e helper/schema: support top-level TypeMap 2014-10-08 17:35:14 -07:00
Mitchell Hashimoto 0db9d98fff helper/schema: can set Partial(true) multiple times 2014-10-08 16:35:14 -07:00
Mitchell Hashimoto ef62fa80db helper/resource: add Retry function 2014-10-07 21:44:51 -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
Mitchell Hashimoto 5aed997223 helper/schema: Input support 2014-09-29 10:25:43 -07:00
Mitchell Hashimoto 9ba39d93b7 helper/resource: compile 2014-09-24 14:23:29 -07:00
Mitchell Hashimoto 9b2b3a963f ResourceDiff => InstanceDiff 2014-09-17 16:33:24 -07:00
Mitchell Hashimoto 81d9d70296 helper/schema: conforms to new API, tests pass 2014-09-16 17:07:13 -07:00
Mitchell Hashimoto 0bcbccf046 helper/resource: compiles, fails because Context doesn't work, probably 2014-09-16 17:02:05 -07:00
Mitchell Hashimoto 90dd00ee3c helper/diff: InstanceState conversion 2014-09-16 16:56:31 -07:00
Mitchell Hashimoto f117e33c9d helper/ssh: convert to InstanceState 2014-09-16 16:55:02 -07:00
Mitchell Hashimoto 0250c17d6e helper/schema: DefaultFunc for dynamic defaults
/cc @c4milo - This might be useful to you as well.
2014-09-09 21:33:08 -07:00
Mitchell Hashimoto 5919637456 helper/schema: Defaults [GH-245] 2014-09-09 21:17:29 -07:00
Mitchell Hashimoto 3a6940d715 helper/schema: test cases around unknown variable values 2014-08-30 17:03:01 -07:00
Mitchell Hashimoto faa4e75960 helper/schema: Get on computed diff should be empty 2014-08-27 15:45:52 -07:00
Mitchell Hashimoto c9a541d95b helper/schema: generate a full diff in destroy/create cycle 2014-08-27 15:45:52 -07:00
Mitchell Hashimoto 9d239eea60 helper/schema: detect no change computed for sets/lists properly 2014-08-27 15:03:42 -07:00
Mitchell Hashimoto 0c9b65f3f4 helper/schema: documentation 2014-08-26 21:52:09 -07:00
Mitchell Hashimoto 87a488092c helper/schema: support partial states 2014-08-26 20:19:44 -07:00
Mitchell Hashimoto 40e5608fa9 helper/schema: return the prior state if Data is an error 2014-08-26 15:50:31 -07:00
Mitchell Hashimoto 56cf1e6faa Fix go vet complaints 2014-08-24 21:50:35 -07:00
Mitchell Hashimoto 95bd64132b helper/schema: update docs 2014-08-24 16:53:42 -07:00
Mitchell Hashimoto 31cc3ffca1 helper/schema: one of Optional, Required, Computed must be set 2014-08-24 16:53:41 -07:00
Mitchell Hashimoto eff8306a6c helper/schema: don't mark things computed if an ID is set 2014-08-22 12:18:08 -07:00
Mitchell Hashimoto 9ed601d541 helper/schema: store state with processed properly 2014-08-22 12:09:06 -07:00
Mitchell Hashimoto 50026a6d5c helper/schema: When having a StateFunc, make sure NewExtra contains
original
2014-08-22 08:57:44 -07:00
Mitchell Hashimoto d009ea800a helper/schema: add support for StateFunc 2014-08-22 08:45:54 -07:00
Mitchell Hashimoto 7be2f1b091 helper/schema: add GetOk 2014-08-21 23:03:04 -07:00
Mitchell Hashimoto 37cf52fa27 helper/schema: if no ID is set then return nil 2014-08-21 22:19:33 -07:00
Mitchell Hashimoto 3d3789920d helper/schema: can set conninfo 2014-08-21 22:15:47 -07:00
Mitchell Hashimoto efaedbabb0 fmt 2014-08-20 22:24:35 -07:00
Mitchell Hashimoto 4015d942ab providers/aws: security group ingress rules treated as set [GH-87]
/cc @pearkes - !!!
2014-08-20 22:24:13 -07:00
Mitchell Hashimoto 3db41fe9f6 helper/hashcode for generating hashcodes 2014-08-20 22:09:40 -07:00
Mitchell Hashimoto e9cc09a886 helper/schema: improve InternalValidate for sets 2014-08-20 21:13:18 -07:00
Mitchell Hashimoto 9ab5577beb helper/schema: set diff tests 2014-08-20 21:09:07 -07:00
Mitchell Hashimoto 475528adc3 helper/schema: Set operations 2014-08-20 21:09:06 -07:00
Mitchell Hashimoto ca18e971d1 helper/schema: can set sets 2014-08-20 21:09:06 -07:00
Mitchell Hashimoto 9fe21f0423 helper/schema: verify that sets remove duplicates 2014-08-20 21:09:06 -07:00
Mitchell Hashimoto 56dde5c0c1 helper/schema: can read and get the state of sets 2014-08-20 21:09:06 -07:00
Mitchell Hashimoto a7e1154a0f helper/schema: remove swap tracking 2014-08-20 18:11:40 -07:00
Mitchell Hashimoto 312acf3e40 helper/schema: track map of swaps 2014-08-20 18:11:40 -07:00
Mitchell Hashimoto 5e975e47cf helper/schema: diffing should use ResourceData for guidance 2014-08-20 18:11:40 -07:00