Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update jsondiffprinter #10

Merged
merged 4 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions format.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ func (a *App) diff(change *tfjson.Change) string {
}

buf := &strings.Builder{}
formatter := jsondiffprinter.NewTerraformFormatter(buf,
options := []jsondiffprinter.Option{
jsondiffprinter.WithTerraformDefaults(),
jsondiffprinter.WithWriter(buf),
jsondiffprinter.WithIndentation(" "),
jsondiffprinter.WithHideUnchanged(true),
jsondiffprinter.WithJSONinJSONCompare(compare),
Expand All @@ -125,8 +127,8 @@ func (a *App) diff(change *tfjson.Change) string {
}
return diff
}),
)
err = formatter.Format(change.Before, patch)
}
err = jsondiffprinter.Format(change.Before, patch, options...)
if err != nil {
panic(err)
}
Expand Down
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.8
github.com/breml/jsondiffprinter v0.0.10
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
4 changes: 2 additions & 2 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.8 h1:+FE3r92haHtqDSfjq1l8JRAKmEARVEeajD4Ud0YqVGQ=
github.com/breml/jsondiffprinter v0.0.8/go.mod h1:XuyU5sGP+XDNFHnhuyOT67mRBUUHtJ8OmjztxNuXgL8=
github.com/breml/jsondiffprinter v0.0.10 h1:pJBsUc8EUSragXq8ivkeeW/SSOkGpywg6usATc2qSiw=
github.com/breml/jsondiffprinter v0.0.10/go.mod h1:XuyU5sGP+XDNFHnhuyOT67mRBUUHtJ8OmjztxNuXgL8=
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
9 changes: 9 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import (
"github.com/urfave/cli/v2"
)

var (
version = "dev"
commit = "none"
date = "unknown"
)

func main() {
if err := main0(os.Args); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
Expand Down Expand Up @@ -42,6 +48,9 @@ Resource actions are indicated with the following symbols:
},
},
CustomAppHelpTemplate: cli.AppHelpTemplate + executionPlanLegend,

Copyright: "© 2024, Lucas Bremgartner",
Version: fmt.Sprintf("%s (%s, %s)", version, commit, date),
}
return cliapp.Run(osArgs)
}
Expand Down
2 changes: 1 addition & 1 deletion testdata/sensitive/output.golden
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Changes to Outputs:
}
+ other_value = jsonencode(
{
"key": "value"
+ key = "value"
}
)
~ sensitive = "some secret value" -> "new secret value"
Expand Down