Commit Graph

429 Commits

Author SHA1 Message Date
Mitchell Hashimoto 29eadb8194 terraform: missing provider should add missing aliases [GH-2023] 2015-06-24 20:58:52 -07:00
Mitchell Hashimoto 461f6557c7 config: fix test error 2015-06-23 22:30:41 -07:00
Mitchell Hashimoto fafc32b183 Merge branch 'b-prevent-destroy-type' 2015-06-23 22:29:54 -07:00
Paul Hinze c154ef9558 Merge pull request #1790 from TimeIncOSS/combine-func
config: Add support for lists to concat
2015-06-23 15:41:59 -05:00
Sander van Harmelen c62370f9e9 Add a function to load JSON directly
Without this 12 line function it’s impossible to use any of the
Terraform code without the need for having the files on disk. As more
and more people are using (parts of) Terraform in other software, this
seems to be a very welcome addition. It has no negative impact on
Terraform itself whatsoever (the function is never called), but it
opens up a lot of other use cases.

Next to the single new function, I renamed the existing function (and
related tests) to better reflect what the function does. So now there
is a `LoadDir` function which calls `LoadFile` for each file, which
kind of made sense to me, especially when now adding a `LoadJSON`
function as well.

But of course if the rename is a problem, I can revert that part as
it’s not related to the added `LoadJSON` function.

Thanks!
2015-06-23 16:15:26 +02:00
Radek Simko 6a60fa4bfe config: concat function supports lists (combines more lists into one) 2015-06-13 08:54:01 +01:00
Radek Simko e9e41dfd05 Improve test error messages 2015-06-13 08:54:01 +01:00
Radek Simko 841a1f08da Sort functions by name alphabetically 2015-06-13 08:54:01 +01:00
Mitchell Hashimoto aa1e66c16c config: parse lifecycle block with mapstructure for weak decode 2015-06-07 22:04:23 -07:00
Paul Hinze b781c6c446 core: keys() and values() funcs for map variables
they work on maps with both keys and values that are string types, which
AFAICT are the only types of maps we have right now.

closes #1915
2015-06-02 16:49:51 -05:00
Sam Boyer b82bd0c280 Condense switch fallthroughs into expr lists 2015-05-26 21:52:36 -04:00
Josh Bleecher Snyder 02e751e356 config: add formatlist
formatlist distributes formatting over lists.
See the docs for details.

As a colleague commented:

"It happens all the time that we want a set of
outputs, but in a slightly different way than
just simple joining or concatting."

formatlist (combined with join)
makes it easy to satisfy those needs.
2015-05-12 16:11:42 -07:00
Josh Bleecher Snyder a3f79cd790 config: fix minor comment errors 2015-05-12 16:11:19 -07:00
Mitchell Hashimoto 1099e3f59f config: add module raw configs to InterpolatedConfigs [GH-1448] 2015-04-29 17:12:28 -07:00
Mitchell Hashimoto cca4964552 config: error in validation if module has self variable 2015-04-22 10:39:07 +02:00
Mitchell Hashimoto d0a6d78b97 config: test that resources reference good providers 2015-04-20 14:47:31 -07:00
Mitchell Hashimoto 8ee18e2e14 config: happy case test for multiple providers 2015-04-20 14:27:44 -07:00
Mitchell Hashimoto a599d5f224 config: validate that a multi provider is only configured once each 2015-04-20 14:25:33 -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
Paul Hinze afe4abb637 core: add prevent_destroy lifecycle flag
When the `prevent_destroy` flag is set on a resource, any plan that
would destroy that resource instead returns an error. This has the
effect of preventing the resource from being unexpectedly destroyed by
Terraform until the flag is removed from the config.
2015-04-17 10:40:04 -05:00
Paul Hinze 5874fa06ff Merge pull request #1495 from TimeIncOSS/length-func
config: Add length to built-in functions
2015-04-15 11:54:46 -05:00
Paul Hinze 975a96f271 core: protect against count.index in modules
Modules should get a validation error just like outputs do.

refs #1528
2015-04-15 10:41:56 -05:00
Paul Hinze 347690a73e core: don't crash when count.index is used in the wrong context
It's bad manners! :)

Also adds a validation error up at the configuration layer so the user
sees the case from #1528 as an error message.

fixes #1528
2015-04-15 10:23:53 -05:00
Radek Simko 6a720d087c length added to built-in functions 2015-04-15 16:20:11 +01:00
Mitchell Hashimoto 0ff39a3773 config/lang: support math on variables through implicits 2015-04-14 09:09:18 -07:00
Radek Simko 8eb6984a89 Test helpers to print expected output 2015-04-13 14:12:43 +01:00
Mitchell Hashimoto 6514bf5f25 config: clarify unknown variable error [GH-1480] 2015-04-10 16:45:15 -07:00
Mitchell Hashimoto 06beab6fd8 config: copy the key on Copy 2015-04-09 09:31:04 -07:00
Mitchell Hashimoto b201983304 terraform: copy RawConfigs 2015-04-09 09:21:38 -07:00
Mitchell Hashimoto aab7bc0da5 config/module: rename parameters 2015-04-07 17:07:50 -07:00
Mitchell Hashimoto 2378160803 config/module: determine storage folder by path 2015-04-07 16:44:24 -07:00
Mitchell Hashimoto f084d8d932 config/module: store the path with the module 2015-04-07 16:37:46 -07:00
Paul Hinze 766b4902d4 remove extraneous var declaration
just a go nitpick :)
2015-03-30 19:03:01 -05:00
7heo a6411626bf config: interprets '~' as the current user home dir in file() 2015-03-31 01:52:39 +02:00
Mitchell Hashimoto 44fce5ce60 config/module: remove debug 2015-03-26 09:31:58 -07:00
Mitchell Hashimoto 2e11ca68df config/module: go back to the original folder when doing parent
references
2015-03-26 09:30:32 -07:00
Mitchell Hashimoto bd4aaac71a config/module: failing unit test for GH-1232 2015-03-26 09:11:32 -07:00
Mitchell Hashimoto fdded8ca14 config: allow atlas block 2015-03-24 13:30:22 -07:00
Mitchell Hashimoto f84ae29cf8 config: isTemporaryFile -> isIgnoredFile 2015-03-19 09:51:14 +01:00
Radek Simko f794f30b7d Ignore hidden files per Unix conventions 2015-03-18 07:50:33 +00:00
Mitchell Hashimoto 23609a7af5 Merge pull request #1096 from hashicorp/f-sprintf
config: add "format' function [GH-758]
2015-03-04 16:05:25 -08:00
Mitchell Hashimoto 9e50bf76c7 config/lang: test case for multiline lang 2015-03-02 23:31:49 -08:00
Mitchell Hashimoto b39ddc7d47 config: add format function 2015-03-02 10:26:06 -08:00
Mitchell Hashimoto 63ee4c83ab config: only regexp if at least two characters in replace search 2015-03-02 09:46:46 -08:00
Mitchell Hashimoto 5895494897 config: test bad regexp for replace 2015-03-02 09:44:45 -08:00
Mitchell Hashimoto 2f33a24385 config: add replace function 2015-03-02 09:37:40 -08:00
Mitchell Hashimoto 5e25dc54a7 config: if any var is computed, the entire interpolation is computed 2015-02-27 22:47:43 -08:00
Mitchell Hashimoto 2feaebdca5 config: substring containing computed value replaces element 2015-02-27 21:51:14 -08:00
Mitchell Hashimoto 5848cba6ad config/lang: add modulo 2015-02-26 15:17:37 -08:00
Mitchell Hashimoto 3c4a036fb5 config/lang: add (expr) for order of ops 2015-02-26 14:39:04 -08:00
Mitchell Hashimoto 6750318bb5 config/lang: add test with expressions 2015-02-26 14:34:45 -08:00
Mitchell Hashimoto 9ddcaf15eb config/lang: fix shift/reduce conflict 2015-02-26 14:33:56 -08:00
Mitchell Hashimoto 07b78fdf84 config/lang: math operations 2015-02-26 14:26:14 -08:00
Mitchell Hashimoto 684228e371 config/lang: add math operations for ints 2015-02-26 11:32:39 -08:00
Mitchell Hashimoto cab2e408d2 config/module: retry bitbucket test a few times [GH-1027] 2015-02-23 15:24:24 -08:00
Mitchell Hashimoto 965fe45b9e config: self var validation 2015-02-23 14:43:14 -08:00
Mitchell Hashimoto 9c612964d8 config: self variables 2015-02-23 14:34:25 -08:00
Mitchell Hashimoto a31f2a276b Merge pull request #1015 from hashicorp/b-depends-on-var
config: depends on cannot contain interpolations [GH-985]
2015-02-23 13:49:34 -08:00
Mitchell Hashimoto 87ecf4f40d Merge pull request #1016 from hashicorp/b-splat-validate
config: provisioner splat vars can only reference other resources
2015-02-23 13:48:40 -08:00
Mitchell Hashimoto 45a267111b Merge pull request #885 from brycekahle/split-func
config: add split function
2015-02-20 13:45:01 -08:00
Mitchell Hashimoto c14e84a657 config: validate provisioner splats can only reference others 2015-02-20 09:21:29 -08:00
Mitchell Hashimoto f156d0d1bd config: test we can ref splat of other resources 2015-02-20 09:19:13 -08:00
Mitchell Hashimoto 90a6a627ed config: validate configuration doens't contain splats to ourselves 2015-02-20 09:18:08 -08:00
Mitchell Hashimoto 0e7b150c5b config: depends on cannot contain interpolations [GH-985] 2015-02-20 09:07:41 -08:00
Mitchell Hashimoto 0a68576746 config: add RawConfig.Merge 2015-02-19 12:07:59 -08:00
Mitchell Hashimoto 4bcf6cf6b2 config: bare splat variables should not be allowed in provisioners
[GH-636]
2015-02-17 13:32:45 -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
Emil Hessman a8db835a44 config/module: fix HgGetter test failures on Windows
HgGetter tests failed on windows/amd64 using Mercurial version 3.2.4:

--- FAIL: TestHgGetter (0.11s)
        get_hg_test.go:35: err: C:\Program Files\Mercurial\hg.exe exited with 255: abort: file:// URLs can only refer to localhost
--- FAIL: TestHgGetter_branch (0.11s)
        get_hg_test.go:62: err: C:\Program Files\Mercurial\hg.exe exited with 255: abort: file:// URLs can only refer to localhost
FAIL
FAIL    github.com/hashicorp/terraform/config/module    5.615s

This commit fixes the failures by adjusting the file:// URL to a form that
Mercurial expects.
2015-02-02 19:49:57 +01:00
Emil Hessman 5bbfc0d4e2 config/module: fix URL file path handling on Windows
Only adjust the URL Scheme when parsing drive letter file paths on
Windows, don't add a file scheme prefix.
FileDetector is responsible for adding the file scheme prefix.
2015-02-02 12:19:34 +01:00
Mitchell Hashimoto 2d9dd25493 config/module: fix regression of ignoring forced type if valid URL
/cc @ceh - Does this break Windows at all? This regressed with your
commit (we didn't have test coverage on it). I added a test now, though.
2015-02-01 20:17:56 +01:00
Bryce Kahle adccaad252 Add split function 2015-01-28 16:59:16 -05:00
Emil Hessman 97227a5c70 config/module: fix detection of file paths on Windows
Absolute file paths were not correctly detected by module.Detect
when using url.Parse to parse the source URL. Wrap the detection
with urlParse to properly handle file path detections on Windows.

Fixes command test failures on Windows.
2015-01-28 10:40:32 +01:00
Emil Hessman 65177edd1e config/module: fix test failures on Windows
When parsing URLs on Windows, assume it is a drive letter path
if the second element is a ':' character. Format the drive letter
path as a "file:///"-path prior to parsing the URL.

Fixes test failures of the following form in command on Windows:

=== RUN TestApply_plan
--- FAIL: TestApply_plan (0.00s)
        apply_test.go:379: bad: 1

		module download not supported for scheme 'c'
2015-01-28 08:19:04 +01:00
Emil Hessman d5a49363d7 config/module: handle absolute file paths on Windows
Using url.Parse to parse an absolute file path on Windows yields
a URL type where the Path element is prefixed by a slash.

For example, parsing "file:///C:/Users/user" gives a URL type
with Path:"/C:/Users/user".

According to golang.org/issue/6027, the parsing is correct as is.

The leading slash on the Path must be eliminated before any file
operations.

This commit introduces a urlParse function which wraps the url.Parse
functionality and removes the leading slash in Path for absolute file
paths on Windows.

Fixes config/module test failures on Windows.
2015-01-27 23:18:47 +01:00
Emil Hessman 78d1fc742f config/module: adjust HttpGetter test to fix Windows test failure
Specify laddr on the form host:port in the call to net.Listen as
documented for net.Dial, see godoc.org/net#Dial

Fixes the following test failures on Windows:

> go test -run=TestHttpGetter
--- FAIL: TestHttpGetter_header (0.00s)
        get_http_test.go:31: err: Get http://[::]:52101/header?terraform-get=1: dial tcp [::]:52101: ConnectEx tcp: The requested address is not valid in its context.
--- FAIL: TestHttpGetter_meta (0.00s)
        get_http_test.go:55: err: Get http://[::]:52103/meta?terraform-get=1: dial tcp [::]:52103: ConnectEx tcp: The requested address is not valid in its context.
--- FAIL: TestHttpGetter_metaSubdir (0.00s)
        get_http_test.go:79: err: Get http://[::]:52105/meta-subdir?terraform-get=1: dial tcp [::]:52105: ConnectEx tcp: The requested address is not valid in its context.
FAIL
exit status 1
FAIL github.com/hashicorp/terraform/config/module    0.054s
2015-01-27 23:18:46 +01:00
Emil Hessman 74cf8fcabd config/module: adjust FileDetector tests for Windows
"/foo" is not an absolute path on Windows. Adjust the FileDetector
tests to take that into account when verifying the results.

Fixes FileDetector test failures on Windows.
2015-01-27 23:18:46 +01:00
Emil Hessman 160e4f926e config/module: fix panic on Windows when running tests
On Windows, Go returns paths with the `\` path separator.
Make sure we are using `/` even on Windows since URLs are `/`-based.
2015-01-27 07:52:51 +01:00
Mitchell Hashimoto 63344a37c6 config/lang: verify single quotes syntax error [GH-613] 2015-01-16 10:28:00 -08:00
Mitchell Hashimoto 91a3405e88 config: understand provisioner blocks in JSON [GH-807] 2015-01-16 10:14:48 -08:00
Mitchell Hashimoto 7f9abbb99c config/lang; missed file 2015-01-15 09:40:36 -08:00
Mitchell Hashimoto a2e40ad731 config: multi-variable access in slice validation fixed [GH-798] 2015-01-15 09:40:13 -08:00
Mitchell Hashimoto 2abeb2d9ac config: use new API 2015-01-14 22:03:15 -08:00
Mitchell Hashimoto 61ee63d842 config/lang/ast: remove unused Eval 2015-01-14 21:49:39 -08:00
Mitchell Hashimoto 8d2c60a8af config/lang: eval 2015-01-14 21:48:20 -08:00
Mitchell Hashimoto 4302dbaf2a config/lang: make TypeCheck implementable by other nodes 2015-01-14 21:18:22 -08:00
Mitchell Hashimoto 57adfe53f6 config/lang: use the new AST stuff 2015-01-14 20:58:46 -08:00
Mitchell Hashimoto c96b3b9ddc config/lang/ast: Eval 2015-01-14 20:37:16 -08:00
Mitchell Hashimoto c4273974de config/lang/ast: introduce Type 2015-01-14 20:13:35 -08:00
Mitchell Hashimoto 342b4d2d9f config/lang: proper filename 2015-01-14 16:36:42 -08:00
Mitchell Hashimoto 1e79861b84 config/lang/ast: AST transforms are built-in 2015-01-14 16:36:01 -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
Emil Hessman 482460c4c8 config/lang: address vet reports
Fixes the following vet reports:

config/lang/check_types.go:98: arg n for printf verb %d of wrong type: *github.com/hashicorp/terraform/config/lang/ast.Concat
config/lang/lex.go:80: arg x.mode for printf verb %s of wrong type: lang.parserMode
2015-01-14 22:04:28 +01:00
Mitchell Hashimoto 6e29ea0366 config/lang: some hoops to get the types to work 2015-01-14 12:18:51 -08:00
Mitchell Hashimoto 591610deea config/lang: string to int 2015-01-14 12:02:26 -08:00
Mitchell Hashimoto d12bf66403 config/lang: implicit builtins are coming in 2015-01-14 11:59:06 -08:00
Mitchell Hashimoto 36b6601baf config/lang: implicit type conversions 2015-01-14 11:47:20 -08:00
Mitchell Hashimoto 8ae14f06b3 config: variables must be typed 2015-01-14 10:40:43 -08:00
Mitchell Hashimoto dd456871e9 config/lang: remove unused code 2015-01-14 10:11:29 -08:00
Mitchell Hashimoto 92af4801a1 config: reintroduce concat 2015-01-13 12:47:54 -08:00
Mitchell Hashimoto 8d51b6b1d4 config/lang: variadic functions 2015-01-13 12:40:47 -08:00