Skip to content

Commit

Permalink
Update dependencies, add support for from/to jsonInJson
Browse files Browse the repository at this point in the history
  • Loading branch information
breml committed Aug 9, 2024
1 parent cbe275c commit e99686a
Show file tree
Hide file tree
Showing 6 changed files with 353 additions and 53 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/breml/tfreveal
go 1.22.3

require (
github.com/breml/jsondiffprinter v0.0.10
github.com/breml/jsondiffprinter v0.0.11
github.com/ghetzel/go-stockutil v1.11.4
github.com/hashicorp/terraform-json v0.22.1
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkY
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
github.com/breml/jsondiffprinter v0.0.10 h1:pJBsUc8EUSragXq8ivkeeW/SSOkGpywg6usATc2qSiw=
github.com/breml/jsondiffprinter v0.0.10/go.mod h1:XuyU5sGP+XDNFHnhuyOT67mRBUUHtJ8OmjztxNuXgL8=
github.com/breml/jsondiffprinter v0.0.11 h1:9h2sbLyzrZv6uqRDVte/AqKQMS5uT/gKmoBKe73qtkg=
github.com/breml/jsondiffprinter v0.0.11/go.mod h1:jx47IKdOP/wnWtT0gahwvLp1sdImmhxMDuIZyiN95/Y=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
Expand Down Expand Up @@ -521,8 +521,8 @@ golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4f
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw=
golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
12 changes: 12 additions & 0 deletions testdata/advanced/after/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ resource "local_file" "foo" {
file_permission = "0660"
}

resource "local_file" "string2json" {
content = jsonencode({
"key": "some random json"
})
filename = "${path.module}/string2json"
}

resource "local_file" "json2string" {
content = "some random string"
filename = "${path.module}/json2string"
}

output "string" {
value = "some text 1"
}
12 changes: 12 additions & 0 deletions testdata/advanced/before/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ resource "local_file" "foo" {
filename = "${path.module}/foo.bar"
}

resource "local_file" "string2json" {
content = "some random string"
filename = "${path.module}/string2json"
}

resource "local_file" "json2string" {
content = jsonencode({
"key": "some random json"
})
filename = "${path.module}/json2string"
}

output "string" {
value = "some text"
}
44 changes: 39 additions & 5 deletions testdata/advanced/output.golden
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,43 @@ Changes to Resources:
# (5 unchanged attribute hidden)
}

# local_file.json2string must be replaced
-/+ local_file.json2string = {
~ content = jsonencode(
{
- key = "some random json"
}
) -> "some random string" # forces replacement
~ content_base64sha256 = "HYsNaOjaBgmFTRuYj4T4J4Ve7InaRVmfw2wgDbwr8Cs=" -> "(known after apply)"
~ content_base64sha512 = "COm1PXnJevPHVeZququDXk5+U5hDeA4dLmTnUpdeMhoF/3+isI46Hgkg5Dln9HCVN7Ythqjq4mrIP4t67bq3Ow==" -> "(known after apply)"
~ content_md5 = "31dd41a76bb193c928caf767ac8e8340" -> "(known after apply)"
~ content_sha1 = "72e1eb91ff698efdaa1a82b5977634a04cf2985d" -> "(known after apply)"
~ content_sha256 = "1d8b0d68e8da0609854d1b988f84f827855eec89da45599fc36c200dbc2bf02b" -> "(known after apply)"
~ content_sha512 = "08e9b53d79c97af3c755e66abaab835e4e7e539843780e1d2e64e752975e321a05ff7fa2b08e3a1e0920e43967f4709537b62d86a8eae26ac83f8b7aedbab73b" -> "(known after apply)"
~ id = "72e1eb91ff698efdaa1a82b5977634a04cf2985d" -> "(known after apply)"
# (6 unchanged attribute hidden)
}

# local_file.string2json must be replaced
-/+ local_file.string2json = {
~ content = "some random string" -> jsonencode(
{
+ key = "some random json"
}
) # forces replacement
~ content_base64sha256 = "Q0LgjQHySsRRvDu/9oZAhWO1wm04bQwYh5JE9eeXTX0=" -> "(known after apply)"
~ content_base64sha512 = "eaxV3784RhIgGecPVkfZ+wZlola4sUqDaG/V8Hr+Y5LKG7a3UJ5UkF9VRA4UYOGmtnlGI0hcm7nVJeq2u1AGFw==" -> "(known after apply)"
~ content_md5 = "76712b27e483bc0ba2ce8d2109210c22" -> "(known after apply)"
~ content_sha1 = "8d7219cf3e6259b90b70d5b5e2d39b27f946e4b8" -> "(known after apply)"
~ content_sha256 = "4342e08d01f24ac451bc3bbff686408563b5c26d386d0c18879244f5e7974d7d" -> "(known after apply)"
~ content_sha512 = "79ac55dfbf3846122019e70f5647d9fb0665a256b8b14a83686fd5f07afe6392ca1bb6b7509e54905f55440e1460e1a6b6794623485c9bb9d525eab6bb500617" -> "(known after apply)"
~ id = "8d7219cf3e6259b90b70d5b5e2d39b27f946e4b8" -> "(known after apply)"
# (6 unchanged attribute hidden)
}

# null_resource.cluster must be replaced
-/+ null_resource.cluster = {
~ id = "7713440656663291188" -> "(known after apply)"
~ id = "2582010537129087805" -> "(known after apply)"
triggers = { # forces replacement
~ secret = "secure" -> "still secure"
}
Expand All @@ -86,17 +120,17 @@ Changes to Resources:
}

- null_resource.cluster_old = {
- id = "342286906083046084"
- id = "6045924575212971352"
- triggers = {
- secret = "very very secure"
}
}

~ time_offset.example = {
~ day = 2 -> 3
~ day = 16 -> 17
~ offset_days = 7 -> 8
~ rfc3339 = "2024-06-02T15:18:04Z" -> "2024-06-03T15:18:04Z"
~ unix = 1717341484 -> 1717427884
~ rfc3339 = "2024-08-16T06:48:48Z" -> "2024-08-17T06:48:48Z"
~ unix = 1723790928 -> 1723877328
# (13 unchanged attribute hidden)
}

Expand Down
Loading

0 comments on commit e99686a

Please sign in to comment.