Commit Graph

8 Commits

Author SHA1 Message Date
James Nugent 85ec09111b helper/schema: Add diff suppression callback
This commit adds a new callback, DiffSuppressFunc, to  the schema.Schema
structure. If set for a given schema, a callback to the user-supplied
function will be made for each attribute for which the default
type-based diff mechanism produces an attribute diff. Returning `true`
from the callback will suppress the diff (i.e. pretend there was no
diff), and returning false will retain it as part of the plan.

There are a number of motivating examples for this - one of which is
included as an example:

1. On SSH public keys, trailing whitespace does not matter in many
   cases - and in some cases it is added by provider APIs. For
   digitalocean_ssh_key resources we previously had a StateFunc that
   trimmed the whitespace - we now have a DiffSuppressFunc which
   verifies whether the trimmed strings are equivalent.

2. IAM policy equivalence for AWS. A good proportion of AWS issues
   relate to IAM policies which have been "normalized" (used loosely)
   by the IAM API endpoints. This can make the JSON strings differ
   from those generated by iam_policy_document resources or template
   files, even though the semantics are the same (for example,
   reordering of `bucket-prefix/` and `bucket-prefix/*` in an S3
   bucket policy. DiffSupressFunc can be used to test for semantic
   equivalence rather than pure text equivalence, but without having to
   deal with the complexity associated with a full "provider-land" diff
   implementation without helper/schema.
2016-08-31 19:13:53 -05:00
Tommy Murphy f71646a0f4 provider/digitalocean: trim whitespace from ssh key (#8173) 2016-08-14 21:38:37 +01:00
Paul Stack ae2bd7a0ff provider/digitalocean: Support Import `digitalocean_ssh_key` (#7345)
```
make testacc TEST=./builtin/providers/digitalocean
TESTARGS='-run=TestAccDigitalOceanSSHKey_'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /vendor/)
TF_ACC=1 go test ./builtin/providers/digitalocean -v -run=TestAccDigitalOceanSSHKey_ -timeout 120m
=== RUN   TestAccDigitalOceanSSHKey_importBasic
--- PASS: TestAccDigitalOceanSSHKey_importBasic (2.13s)
=== RUN   TestAccDigitalOceanSSHKey_Basic
--- PASS: TestAccDigitalOceanSSHKey_Basic (1.52s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/digitalocean
3.665s
```
2016-06-29 16:09:34 +01:00
James Nugent fed666a5b6 provider/digitalocean: Check for nil response
This applies the same fix to `digitalocean_ssh_key` as #5588 applies to
droplets. Fixes #5402. The report there gives weight to my theory that
this occurs when there are transport issues.
2016-03-21 14:25:11 +00:00
Alex Berghage 53f02fc4a2 Analogous to #3768 -- just for DNS and keys.
The error string for 404s on DNS domains has (apparently)
changed, causing things to be a little sad when you modify
DNS domains from the DO console instead of terraform. This
is just the same fix as was applied to droplets around this
time last month.

While I was at it I just fixed this everywhere I saw it in the
DO provider source tree.
2015-12-06 07:13:14 -05:00
Antoine Grondin 0bcf557198 use official Go client for DigitalOcean provider 2015-09-27 01:09:51 -04:00
Anthony Scalisi 198e1a5186 remove various typos 2015-09-11 11:56:20 -07:00
Pablo Lalloni ac58a450ba Add DigitalOcean SSH Key resource 2015-02-27 08:40:11 -03:00