Commit Graph

370 Commits

Author SHA1 Message Date
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