Commit Graph

20 Commits

Author SHA1 Message Date
Paul Hinze b7e854fa8b
provider/template: validate vars are primitives
Closes #7160 by returning a proper error.
2016-07-11 16:01:05 -05:00
Martin Atkins 861ac536dd provider/template: convert resources to data sources
The template resources don't actually need to retain any state, so they
are good candidates to be data sources.

This includes a few tweaks to the acceptance tests -- now configured to
run as unit tests -- since it seems that they have been slightly broken
for a while now. In particular, the "update" cases are no longer tested
because updating is not a meaningful operation for a data source.
2016-07-08 17:11:17 +01:00
James Nugent 3ea3c657b5 core: Use OutputState in JSON instead of map
This commit forward ports the changes made for 0.6.17, in order to store
the type and sensitive flag against outputs.

It also refactors the logic of the import for V0 to V1 state, and
fixes up the call sites of the new format for outputs in V2 state.

Finally we fix up tests which did not previously set a state version
where one is required.
2016-05-18 13:25:20 -05:00
James Nugent a0cc7115b3 deps: Update call sites of hil.Eval from update
hil.Eval() now returns (hil.EvaluationResult, error) instead of (value,
type, error). This commit updates the call sites, but retains all
previous behaviour. Tests are also updated.
2016-04-18 16:37:12 -07:00
Paul Hinze 0036db8f82 provider/template: warn when template specified as path
Turns out the BC code allowed users to move from `filename` to
`template` to squash the warning without having to switch from template
paths to template contents.

Here we warn when `template` is specified as a path so we can remove the
functionality in the future and remove this source of confusion.

refs #3732
2016-03-10 12:34:56 -06:00
Mitchell Hashimoto aaf1302ce8 providers/template: don't use config/lang 2016-02-03 13:24:04 -05:00
Simon Thulbourn 548136c050 Remove mime type validation
Remove the mime type validation since the part handler type allows for
custom types.

http://cloudinit.readthedocs.org/en/latest/topics/format.html#part-handler

The docs specify that if a part handler type is specified, one could use
custom mime types

Signed-off-by: Simon Thulbourn <simon+github@thulbourn.com>
2016-01-28 11:36:18 +00:00
James Nugent b0f9eb5c13 provider/template: Allow update in `template_cloudinit_config` 2016-01-20 09:58:20 -05:00
Paul Hinze 0739cf2348 provider/template: fix race causing panic in template_file
The render code path in `template_file` was doing unsynchronized access
to a shared mapping of functions in `config.Func`.

This caused a race condition that was most often triggered when a
`template_file` had a `count` of more than one, and expressed itself as
a panic in the plugin followed by a cascade of "unexpected EOF" errors
through the plugin system.

Here, we simply turn the FuncMap from shared state into a generated
value, which avoids the race. We do more re-initialization of the data
structure, but the performance implications are minimal, and we can
always revisit with a perf pass later now that the race is fixed.
2016-01-15 16:34:46 -05:00
Simon Thulbourn 3701342716 Alters template provider to use a fork of multipart.
Signed-off-by: Simon Thulbourn <simon+github@thulbourn.com>
2015-12-21 13:32:26 -05:00
Simon Thulbourn 33d2afc26d Add headers to output
The original implmentation was missing headers to denote mime version &
content transfer encoding, this caused issues with EC2.

Signed-off-by: Simon Thulbourn <simon+github@thulbourn.com>
2015-12-21 13:32:26 -05:00
James Nugent ba9c7323a9 Remove unnecessary commented imports 2015-12-21 13:32:26 -05:00
James Nugent abffa67a49 Rename resource.go -> resource_template_file.go
This is necessitated by new resources being added to the template
provider.
2015-12-21 13:32:26 -05:00
James Nugent a926fa6fdd Adds template_cloudinit_config resource to template
This adds a new resource to template to generate multipart cloudinit
configurations to be used with other providers/resources.

The resource has the ability gzip and base64 encode the parts.
2015-12-21 13:32:26 -05:00
Paul Hinze 928f534cfc template_file: source contents instead of path
Building on the work of #3846, deprecate `filename` in favor of a
`template` attribute that accepts file contents instead of a path.

Required a bit of work in the interpolation code to prevent Terraform
from assuming that template interpolations were resource variables that
needed to be resolved. Leaving them as "Unknown Variables" prevents
interpolation from happening early and lets the `template_file` resource
do its thing.
2015-11-13 11:24:20 -06: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 06eb388c3f provider/template: store relative path in state
This makes template_file usage in modules portable.
2015-05-21 15:03:03 -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
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
Josh Bleecher Snyder 745d83a995 providers: add template provider
Fixes #215.
2015-05-01 16:59:49 -07:00