Commit Graph

1066 Commits

Author SHA1 Message Date
Mitchell Hashimoto
33bbf09ff6
terraform: error if import with collision 2016-05-11 13:02:33 -07:00
Mitchell Hashimoto
c814d36333
terraform: handle multiple same named states 2016-05-11 13:02:33 -07:00
Mitchell Hashimoto
cfa58a25a6
terraform: test multiple return values 2016-05-11 13:02:33 -07:00
Mitchell Hashimoto
2ed23778b4
terraform: test importing into a new module with other modules 2016-05-11 13:02:33 -07:00
Mitchell Hashimoto
2738fa7df5
terraform: test importing into an existing module 2016-05-11 13:02:33 -07:00
Mitchell Hashimoto
7fe8b21969
terraform: verify import with missing type doesn't add to state 2016-05-11 13:02:32 -07:00
Mitchell Hashimoto
58fe557a9f
terraform: test that missing type results in error on import 2016-05-11 13:02:32 -07:00
Mitchell Hashimoto
0701c70eae
terraform: test import with module depth of two 2016-05-11 13:02:32 -07:00
Mitchell Hashimoto
492bda5186
terraform: more provider transform tests 2016-05-11 13:02:32 -07:00
Mitchell Hashimoto
0a7f48ab8e
terraform: import module works! 2016-05-11 13:02:32 -07:00
Mitchell Hashimoto
3b85544016
terraform: getting providers to connect the way we want for modules 2016-05-11 13:02:32 -07:00
Mitchell Hashimoto
6f607d0c59
terraform: MissingProviderTransformer now injects missing modules 2016-05-11 13:02:32 -07:00
Mitchell Hashimoto
1d3f11f0ba
terraform: working on fixes for imports in modules 2016-05-11 13:02:32 -07:00
Mitchell Hashimoto
0ab0ccf5b3
terraform: verify refresh is called on import 2016-05-11 13:02:31 -07:00
Mitchell Hashimoto
59e498dba8
terraform: basic test passing 2016-05-11 13:02:31 -07:00
Mitchell Hashimoto
8bb8637f24
terraform: some initial graphs (not tested, failing tests) 2016-05-11 13:02:31 -07:00
Mitchell Hashimoto
aca26fd784
terraform: ImportTransformer, EvalImportState 2016-05-11 13:02:31 -07:00
Mitchell Hashimoto
45c3fd58d8
terraform: InstanceState.DeepCopy is exported 2016-05-11 13:02:31 -07:00
Mitchell Hashimoto
1040cb7cdb
terraform: add type to Ephemeral 2016-05-11 13:02:31 -07:00
Mitchell Hashimoto
531f609564
terraform: add ImportState to the provider interface 2016-05-11 13:02:30 -07:00
Mitchell Hashimoto
9142ec400e
terraform: flowerbox the ResourceProvider interface because it is huge 2016-05-11 13:02:30 -07:00
Mitchell Hashimoto
57b6e5cee9
terraform: generate 2016-05-11 13:02:30 -07:00
Mitchell Hashimoto
2a86b85646
terraform: start Import function, totally untested 2016-05-11 13:02:30 -07:00
Mitchell Hashimoto
84531a3fd5
helper/schema: sets Importable to true for resources that have importer 2016-05-11 13:02:30 -07:00
Mitchell Hashimoto
5e127a62c1 Merge pull request #6597 from hashicorp/f-state-mv
command/state mv
2016-05-11 12:58:23 -07:00
Paul Hinze
559f017ebb
terraform: Correct fix for destroy interp errors
The fix that landed in #6557 was unfortunately the wrong subset of the
work I had been doing locally, and users of the attached bugs are still
reporting problems with Terraform v0.6.16.

At the very last step, I attempted to scope down both the failing test
and the implementation to their bare essentials, but ended up with a
test that did not exercise the root of the problem and a subset of the
implementation that was insufficient for a full bugfix.

The key thing I removed from the test was a _referencing output_ for the
module, which is what breaks down the #6557 solution.

I've re-tested the examples in #5440 and #3268 to verify this solution
does indeed solve the problem.
2016-05-10 15:58:51 -05:00
Paul Hinze
8223e606df
terraform: add debug logging to Noop impls
This sort of output is needed to debug these codepaths anyways, so I
figured might as well leave it in.
2016-05-10 15:58:46 -05:00
Mitchell Hashimoto
eaf3d608ed
terraform: test moving a module to be nested 2016-05-10 13:25:43 -07:00
Mitchell Hashimoto
163f19fd00
terraform: instance => module 2016-05-10 13:25:03 -07:00
Mitchell Hashimoto
4d268b6eca
terraform: instance => resource 2016-05-10 13:25:03 -07:00
Mitchell Hashimoto
e497c26517
terraform: resource => module 2016-05-10 13:25:03 -07:00
Mitchell Hashimoto
d3fcfcc027
terraform: moving resource to resource 2016-05-10 13:25:03 -07:00
Mitchell Hashimoto
e65a726936
terraform: copy deps and provider for resource state 2016-05-10 13:25:03 -07:00
Mitchell Hashimoto
cb060f9063
terraform: unify on init addr 2016-05-10 13:25:03 -07:00
Mitchell Hashimoto
c324062645
terraform: state add resource existing fails 2016-05-10 13:25:03 -07:00
Mitchell Hashimoto
21d7ffc3f3
terraform: add resource 2016-05-10 13:25:03 -07:00
Mitchell Hashimoto
2de4324607
terraform: add stateadd to its own test file 2016-05-10 13:25:02 -07:00
Mitchell Hashimoto
af3c3e4c60
terraform: Module copy copies outputs and dependencies 2016-05-10 13:25:02 -07:00
Mitchell Hashimoto
30cf550fc5
terraform: can't move module to module that exists 2016-05-10 13:25:02 -07:00
Mitchell Hashimoto
bbc812d035
terraform: fix failing tests 2016-05-10 13:25:02 -07:00
Mitchell Hashimoto
25098f20c9
terraform: State.Add works for module to module (new) 2016-05-10 13:25:02 -07:00
Mitchell Hashimoto
407be65cc8
terraform: ResourceAddress should output instance type if set 2016-05-10 13:25:02 -07:00
James Nugent
f1d0fc46aa core: Fix go vet issues shown by Travis 2016-05-10 16:00:28 -04:00
James Nugent
6a20e8927d core: Fix issues from rebasing dev-0.7 onto master
- Fix sensitive outputs for lists and maps
- Fix test prelude which was missed during conflict resolution
- Fix `terraform output` to match old behaviour and not have outputs
  header and colouring
- Bump timeout on TestAtlasClient_UnresolvableConflict
2016-05-10 15:43:50 -04:00
James Nugent
7b6df27e4a helper/schema: Read native maps from configuration
This adds a test and the support necessary to read from native maps
passed as variables via interpolation - for example:

```
resource ...... {
     mapValue = "${var.map}"
}
```

We also add support for interpolating maps from the flat-mapped resource
config, which is necessary to support assignment of computed maps, which
is now valid.

Unfortunately there is no good way to distinguish between a list and a
map in the flatmap. In lieu of changing that representation (which is
risky), we assume that if all the keys are numeric, this is intended to
be a list, and if not it is intended to be a map. This does preclude
maps which have purely numeric keys, which should be noted as a
backwards compatibility concern.
2016-05-10 14:49:14 -04:00
James Nugent
f49583d25a core: support native list variables in config
This commit adds support for native list variables and outputs, building
up on the previous change to state. Interpolation functions now return
native lists in preference to StringList.

List variables are defined like this:

variable "test" {
    # This can also be inferred
    type = "list"
    default = ["Hello", "World"]
}

output "test_out" {
    value = "${var.a_list}"
}
This results in the following state:

```
...
            "outputs": {
                "test_out": [
                    "hello",
                    "world"
                ]
            },
...
```

And the result of terraform output is as follows:

```
$ terraform output
test_out = [
  hello
  world
]
```

Using the output name, an xargs-friendly representation is output:

```
$ terraform output test_out
hello
world
```

The output command also supports indexing into the list (with
appropriate range checking and no wrapping):

```
$ terraform output test_out 1
world
```

Along with maps, list outputs from one module may be passed as variables
into another, removing the need for the `join(",", var.list_as_string)`
and `split(",", var.list_as_string)` which was previously necessary in
Terraform configuration.

This commit also updates the tests and implementations of built-in
interpolation functions to take and return native lists where
appropriate.

A backwards compatibility note: previously the concat interpolation
function was capable of concatenating either strings or lists. The
strings use case was deprectated a long time ago but still remained.
Because we cannot return `ast.TypeAny` from an interpolation function,
this use case is no longer supported for strings - `concat` is only
capable of concatenating lists. This should not be a huge issue - the
type checker picks up incorrect parameters, and the native HIL string
concatenation - or the `join` function - can be used to replicate the
missing behaviour.
2016-05-10 14:49:14 -04:00
Mitchell Hashimoto
e81fb10e61 terraform: test file for last commit 2016-05-10 14:49:14 -04:00
Mitchell Hashimoto
3480b7ebee terraform: state filter wasn't comparing resource names 2016-05-10 14:49:14 -04:00
James Nugent
e57a399d71 core: Use native HIL maps instead of flatmaps
This changes the representation of maps in the interpolator from the
dotted flatmap form of a string variable named "var.variablename.key"
per map element to use native HIL maps instead.

This involves porting some of the interpolation functions in order to
keep the tests green, and adding support for map outputs.

There is one backwards incompatibility: as a result of an implementation
detail of maps, one could access an indexed map variable using the
syntax "${var.variablename.key}".

This is no longer possible - instead HIL native syntax -
"${var.variablename["key"]}" must be used. This was previously
documented, (though not heavily used) so it must be noted as a backward
compatibility issue for Terraform 0.7.
2016-05-10 14:49:13 -04:00
James Nugent
6aac79e194 state: Add support for outputs of multiple types
This commit adds the groundwork for supporting module outputs of types
other than string. In order to do so, the state version is increased
from 1 to 2 (though the "public-facing" state version is actually as the
first state file was binary).

Tests are added to ensure that V2 (1) state is upgraded to V3 (2) state,
though no separate read path is required since the V2 JSON will
unmarshal correctly into the V3 structure.

Outputs in a ModuleState are now of type map[string]interface{}, and a
test covers round-tripping string, []string and map[string]string, which
should cover all of the types in question.

Type switches have been added where necessary to deal with the
interface{} value, but they currently default to panicking when the input
is not a string.
2016-05-10 14:40:12 -04:00