Commit Graph

17 Commits

Author SHA1 Message Date
Martin Atkins 19d0b42911 provider/consul: consul_keys data source (#7678)
Previously the consul_keys resource did double-duty as both a reader and
writer of values from the Consul key/value store, but that made its
interface rather confusing and complex, as well as having all of the other
general problems associated with read-only resources.

Here we split the functionality such that reading is done with the
consul_keys data source while writing is done with the consul_keys
resource.

The old read behavior of the resource is still supported, but it's no
longer documented (except as a deprecation note) and will generate
deprecation warnings when used.

In future it should be possible to simplify the consul_keys resource by
removing all of the read support, but that is deferred for now to give
users a chance to gracefully migrate to the new data source.
2016-07-26 18:23:38 +01: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
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
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 3fcc016e48 provider/consul: Change keyword to key from keys 2014-10-20 12:02:48 -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 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 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