Commit Graph

72 Commits

Author SHA1 Message Date
Laurent Commarieu d54a8da7d4 feat(consul): add basic auth to consul provider (#12679) 2017-03-20 13:00:44 +00:00
James Bardin 7f9a57db1d Revert "Have the consul provider use a local test server"
This reverts commit 9529bd3bf0.
2017-03-15 14:42:26 -04:00
James Bardin 9529bd3bf0 Have the consul provider use a local test server
We're providing a local test server for the consul backends, so we might
as well use it to make the provider acceptance tests more relible as
well.

TODO: the TLS test doesn't actualy test anything other than the Config.
The tests have been modified to make it apparent that they aren't
connecting to the server at all.
2017-03-14 10:43:09 -04:00
Sean Chittenden 3127998ecd Remove the AWS Access Key and Secret Access keys from the (#12061)
`consul_agent_self` data source.

Pro tip: update consul!  I was using an old branch of Consul, not
`origin/master`.
2017-02-17 13:36:38 -08:00
Sean Chittenden 5f3b6ffdb2
Add `consul_agent_self` docs and synchronize a few missing attributes. 2017-02-16 15:10:50 -08:00
Sean Chittenden dfb86a8983
Fix a `go vet` issue re: missing arg to `fmt.Sprintf`. 2017-02-16 14:08:15 -08:00
Sean Chittenden 99d91d1f28
Chase the update to the out parameter: `s/services/service/g` 2017-02-16 13:58:08 -08:00
Sean Chittenden e7a8f25388
Push out the last of the docs and fixes for the `consul_catalog_nodes` data source. 2017-02-16 13:50:06 -08:00
Sean Chittenden 1c7a924258
Update and provide docs to the `consul_catalog_service` data source. 2017-02-16 13:50:06 -08:00
Sean Chittenden 9d06a47069
Add docs for the `consul_catalog_services` data source. 2017-02-16 13:50:06 -08:00
Sean Chittenden b7c9dedf4e
Add a `consul_catalog_services` resource that enumerates the list of services in a given Consul datacenter. 2017-02-16 13:50:06 -08:00
Sean Chittenden 4003c47c71
Remove some accidentally leaked `q.Q()` calls from earlier debugging.x 2017-02-16 13:50:06 -08:00
Sean Chittenden 59925478c3
Add a `consul_catalog_service` resource to obtain detailed information about a specific Consul service. 2017-02-16 13:50:06 -08:00
Sean Chittenden 41e4208777
Commit miss: `s/query_opts/query_options/` 2017-02-16 13:50:05 -08:00
Sean Chittenden 974415d5cf
Move the query options schema into its own set and nested collection of attributes.
This is being done in advance of supporting the services data source.
2017-02-16 13:50:05 -08:00
Sean Chittenden 0d049026be
Remove unused helper functions. 2017-02-16 13:50:05 -08:00
Sean Chittenden efb76b3374
Update the style of the `consul_catalog_nodes` data source. 2017-02-16 13:50:05 -08:00
Sean Chittenden 1476445593
Update `consul_catalog_nodes` to conform to normal resource guidelines. 2017-02-16 13:50:05 -08:00
Sean Chittenden 5567732814
Remove underscores from private identifiers that were not to be exported and strictly use lowercase letters instead. 2017-02-16 13:50:05 -08:00
Sean Chittenden 0d5ee1e953
Catch API drift with Consul. 2017-02-16 13:50:04 -08:00
Sean Chittenden ac1294633a
Add a datasource for catalog nodes. 2017-02-16 13:50:04 -08:00
Sean Chittenden db2f217f25
Change the signature of map writer to take a map that isn't a pointer. Force the use of `ToMap()` to retrieve the created `map[string]interface{}`. 2017-02-16 13:50:04 -08:00
Sean Chittenden 15fb969f3e
Add an attribute reader interface and a config reader implementation. 2017-02-16 13:50:04 -08:00
Sean Chittenden 77d7e25018
Remove stale code that would never be called at present. 2017-02-16 13:50:04 -08:00
Sean Chittenden 4b73ac7abe
Add the `circonus_agent_self` data source. 2017-02-16 13:50:04 -08:00
Manuwela Kanade 0942aed7a3 provider/consul: catalog entry service id should default to service name 2017-02-08 09:43:00 +00:00
Daniel Portella c2370c574e Fixes for consul_service resource (#9366)
Added `service_id` in place of `id` for resource.
modified created, read, update to use `service_id`
modified tests to include `service_id`.
modified documentation for consul_service to include new value.

Tests results

CONSUL_HTTP_ADDR=localhost:8500 make testacc TEST=./builtin/providers/consul/

==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2016/10/14 14:43:05 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/consul/ -v  -timeout 120m
=== RUN   TestAccDataConsulKeys_basic
--- PASS: TestAccDataConsulKeys_basic (0.05s)
=== RUN   TestAccConsulAgentService_basic
--- PASS: TestAccConsulAgentService_basic (0.05s)
=== RUN   TestAccConsulCatalogEntry_basic
--- PASS: TestAccConsulCatalogEntry_basic (0.06s)
=== RUN   TestAccConsulKeyPrefix_basic
--- PASS: TestAccConsulKeyPrefix_basic (0.19s)
=== RUN   TestConsulKeysMigrateState
--- PASS: TestConsulKeysMigrateState (0.00s)
=== RUN   TestConsulKeysMigrateState_empty
--- PASS: TestConsulKeysMigrateState_empty (0.00s)
=== RUN   TestAccConsulKeys_basic
--- PASS: TestAccConsulKeys_basic (0.13s)
=== RUN   TestAccConsulNode_basic
--- PASS: TestAccConsulNode_basic (0.05s)
=== RUN   TestAccConsulPreparedQuery_basic
--- PASS: TestAccConsulPreparedQuery_basic (0.12s)
=== RUN   TestAccConsulService_basic
--- PASS: TestAccConsulService_basic (0.05s)
=== RUN   TestResourceProvider
--- PASS: TestResourceProvider (0.00s)
=== RUN   TestResourceProvider_impl
--- PASS: TestResourceProvider_impl (0.00s)
=== RUN   TestResourceProvider_Configure
--- PASS: TestResourceProvider_Configure (0.00s)
=== RUN   TestResourceProvider_ConfigureTLS
--- PASS: TestResourceProvider_ConfigureTLS (0.00s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/consul	0.708s

Refs: #9352
2016-10-26 13:07:00 +01:00
David Adams 32d08ad45a Make consul provider settings truly optional
Set default values of truly optional settings to empty strings rather
than nil, since a nil value triggers prompts for the missing values.

Also:
* Set default Consul address to `localhost:8500`
* Set default scheme to `http`
* Accept `CONSUL_HTTP_SCHEME` for consistency with other env var names
* Actively read ACL token from env vars (vs leaving it to client lib)

Should fix issue #8499
2016-08-30 08:28:03 -05:00
Ryan Uber ec7fc60d5f Adds consul_prepared_query resource (#7474)
* provider/consul: first stab at adding prepared query support

* provider/consul: flatten pq resource

* provider/consul: implement updates for PQ's

* provider/consul: implement PQ delete

* provider/consul: add acceptance tests for prepared queries

* provider/consul: add template support to PQ's

* provider/consul: use substructures to express optional related components for PQs

* website: first pass at consul prepared query docs

* provider/consul: PQ's support datacenter option and store_token option

* provider/consul: remove store_token on PQ's for now

* provider/consul: allow specifying a separate stored_token

* website: update consul PQ docs

* website: add link to consul_prepared_query resource

* vendor: update github.com/hashicorp/consul/api

* provider/consul: handle 404's when reading prepared queries

* provider/consul: prepared query failover dcs is a list

* website: update consul PQ example usage

* website: re-order arguments for consul prepared queries
2016-08-18 08:46:30 +01:00
Max Englander c072c0dfbb #7013 add tls config support to consul provider (#7015)
* #7013 add tls config support to consul provider

* #7013 add acceptance tests

* #7013 use GFM tables

* #7013 require one of {CONSUL_ADDRESS,CONSUL_HTTP_ADDR} when running consul acc tests
2016-08-12 12:22:41 +10:00
stack72 47c274f699
provider/consul: Fixing the ConsulNode_basic tests to have the correct references 2016-07-26 18:31:38 +01:00
stack72 c1d7ae867f
Merge branch 'gh-2087-consul-service-resource' of https://github.com/maxenglander/terraform into maxenglander-gh-2087-consul-service-resource 2016-07-26 18:26:52 +01:00
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
Max Englander 6e40210227 #2087 gracefully handle non-presence of service on remote consul agent 2016-07-06 08:29:47 -04:00
Max Englander df4c0c82f2 #2087 merge upstream/master 2016-07-06 08:27:15 -04:00
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
Max Englander 296f8be10a #2087 add consul_node and consul_service resources 2016-03-27 03:58:12 +00:00
Max Englander bdf2bbff2e merge master 2016-03-27 02:14:07 +00: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
Max Englander adda285cae finish tests and add docs for consul_{agent_service,catalog_entry} 2016-01-25 00:15:09 +00:00
Max Englander 5f5fd7c6e6 make good use of ForceNew in consul_agent_service 2015-10-29 11:39:27 -04:00
Max Englander 8d6b71e2ae use ForceNew on just about all catalog entry attributes; struggle in the hell of 'diffs mismatch' 2015-10-29 05:04:25 -04:00
Max Englander 7b9ec59258 #2087: consul_catalog_entry can set a service 2015-10-15 04:06:52 -04:00
Max Englander 929e3cdbe2 #2087: add consul_agent_service acceptance test 2015-09-28 01:16:11 -04:00
Max Englander 65ebbda776 #2087 agent_service resource supports address, port, and tag keys, can be read (refreshed) and deleted 2015-09-24 01:30:06 -04:00
Max Englander 63a045f4ff #2087: add consul agent_service and catalog_entry resources; create resource works; TODO support more fields and add tests 2015-09-23 03:52:18 -04: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