Commit Graph

28 Commits

Author SHA1 Message Date
Martin Atkins d706130a51 consul_key_prefix resource
This new resource is an alternative to consul_keys that manages all keys
under a given prefix, rather than arbitrary single keys across the entire
store.

The key advantage of this resource over consul_keys is that it is able to
detect and delete keys that are added outside of Terraform, whereas
consul_keys is only able to detect changes to keys it is explicitly
managing.
2016-04-02 20:37:11 -07:00
Martin Atkins 2e33f5311c Treat each consul key as having its own lifecycle
Previously this resource managed the set of keys as a whole rather than
the individual keys, and so it was unable to recognize when a particular
managed key is removed and delete just that one key from Consul.

Here this is addressed by recognizing that each key actually has its own
lifecycle, and detecting when individual keys are added and removed
without replacing the entire consul_keys instance.

Additionally this restores the behavior of updating the "value" attribute
on read, but restricts it only to blocks that already had a value so as
to avoid the quirkiness seen previously when we updated blocks that were
intended to be read-only. Updating the value is important now, because we
rely on this to detect and repair discrepancies between values stored in
Consul and values given in the configuration.

This change produces a change in the handling of the "delete" attribute.
Before it was considered only when the entire consul_keys resource was
deleted, but now it is considered also when a particular key block is
removed from within a resource.
2016-03-10 07:52:43 -08:00
Martin Atkins df2ce588bc Specialized client for interacting with Consul keys
This deals with some of the quirks of interacting with the Consul API,
with the goal of making the consul_keys resource implementation, and
later the consul_keys data source, less noisy to read.
2016-03-10 07:51:27 -08:00
Paul Hinze 069425a700 consul: Fix several problems w/ consul_keys update
Implementation notes:

 * The hash implementation was not considering key value, causing "diffs
   did not match" errors when a value was updated. Switching to default
   HashResource implementation fixes this
 * Using HashResource as a default exposed a bug in helper/schema that
   needed to be fixed so the Set function is picked up properly during
   Read
 * Stop writing back values into the `key` attribute; it triggers extra
   diffs when `default` is used. Computed values all just go into `var`.
 * Includes a state migration to prevent unnecessary diffs based on
   "key" attribute hashcodes changing.

In the tests:

 * Switch from leaning on the public demo Consul instance to requiring a
   CONSUL_HTTP_ADDR variable be set pointing to a `consul agent -dev`
   instance to be used only for testing.
 * Add a test that exposes the updating issues and covers the fixes

Fixes #774
Fixes #1866
Fixes #3023
2016-01-26 14:46:26 -06:00
Paul Hinze 84afeb73b1 acc tests: ensure each resource has a _basic test
Helpful for breadth first acc test sweeps `-run '_basic$'`
2015-06-07 18:18:14 -05:00
Josh Bleecher Snyder 30d34908b7 providers/consul: add scheme argument
This enables connecting to consul over https
without having to set the envvar CONSUL_HTTP_SSL.
2015-05-06 16:12:32 -07:00
Evan Krall 090a30e988 Fix comment in consul provider to not mention digitalocean 2015-01-22 12:45:55 -08:00
Ryan Uber 94c3acbca6 Switch to github.com/hashicorp/consul/api 2015-01-06 17:11:29 -08:00
Sander van Harmelen 4ace4865d7 Making all function names consistent
Before all providers were using the helper.Schema approach the helper
function had these names. Now they all use names consistent with the Go
naming conventions except for these last few…
2014-12-15 15:26:17 +01:00
Mitchell Hashimoto 903aa0250c providers/consul: fix delete diff 2014-10-20 14:09:57 -07:00
Armon Dadgar f4d5d648c9 provider/consul: Disambiguate between set/get 2014-10-20 12:06:27 -07:00
Armon Dadgar 00eaabf5b8 provider/consul: Fixing test DC 2014-10-20 12:06:16 -07:00
Armon Dadgar 3fcc016e48 provider/consul: Change keyword to key from keys 2014-10-20 12:02:48 -07:00
Armon Dadgar 3e43eb5497 provider/consul: Fixing test harness 2014-10-20 12:02:37 -07:00
Armon Dadgar 1cc95b7a72 provider/consul: Change to GetOk with schema.Helper 2014-10-14 12:16:42 -07:00
Armon Dadgar 269c5be738 provider/Consul: Support Token. Fixes #378 2014-10-13 11:42:40 -07:00
Armon Dadgar 3e249a4e4e provider/consul: Port to helper.Schema framework 2014-10-13 11:35:45 -07:00
Mitchell Hashimoto 459ffe9d2a providers/*: fix compilation for input 2014-09-29 10:28:08 -07:00
Mitchell Hashimoto 9b2b3a963f ResourceDiff => InstanceDiff 2014-09-17 16:33:24 -07:00
Mitchell Hashimoto e4066595c9 providers/consul: tests passing, compiling 2014-09-16 17:29:38 -07:00
Armon Dadgar da539caf0a provider/consul: Acceptance test uses demo.consul.io 2014-07-26 21:25:28 -04:00
Armon Dadgar 2263616c2e provider/consul: Fixing resource updates 2014-07-26 21:24:20 -04:00
Armon Dadgar dc0de63a72 provider/consul: cleanup 2014-07-26 20:21:48 -04:00
Armon Dadgar 719217d64d provider/consul: Simplify 2014-07-26 15:32:34 -04:00
Armon Dadgar e4450fcd51 provider/consul: Vast simplification 2014-07-26 15:14:41 -04:00
Armon Dadgar 9ff8856fe8 provider/consul: first pass at update 2014-07-25 22:35:50 -04:00
Armon Dadgar dd58896d07 provider/consul: first pass 2014-07-25 22:14:51 -04:00
Armon Dadgar 61841467c4 provider/consul: Skeleton 2014-07-25 17:03:17 -04:00