diff --git a/go.mod b/go.mod index dcc0ab65..025e1fbe 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/mattn/go-colorable v0.1.6 // indirect github.com/mitchellh/gox v1.0.1 // indirect github.com/mitchellh/mapstructure v1.3.3 + github.com/pmezard/go-difflib v1.0.0 github.com/rivo/tview v0.0.0-20200818120338-53d50e499bf9 github.com/stretchr/testify v1.5.1 // indirect golang.org/x/crypto v0.0.0-20200422194213-44a606286825 diff --git a/pkg/grafana/dashboard-handler.go b/pkg/grafana/dashboard-handler.go index 0c8109bd..81f6b9c5 100644 --- a/pkg/grafana/dashboard-handler.go +++ b/pkg/grafana/dashboard-handler.go @@ -6,8 +6,8 @@ import ( "strings" "github.com/grafana/grizzly/pkg/grizzly" - "github.com/kylelemons/godebug/diff" "github.com/mitchellh/mapstructure" + "github.com/pmezard/go-difflib/difflib" ) /* @@ -152,7 +152,14 @@ func (h *DashboardHandler) Diff(notifier grizzly.Notifier, resources grizzly.Res if local == remoteRepresentation { notifier.NoChanges(resource) } else { - difference := diff.Diff(remoteRepresentation, local) + diff := difflib.UnifiedDiff{ + A: difflib.SplitLines(remoteRepresentation), + B: difflib.SplitLines(local), + FromFile: "Remote", + ToFile: "Local", + Context: 3, + } + difference, _ := difflib.GetUnifiedDiffString(diff) notifier.HasChanges(resource, difference) } } diff --git a/pkg/grizzly/workflow.go b/pkg/grizzly/workflow.go index 36b99856..9d291832 100644 --- a/pkg/grizzly/workflow.go +++ b/pkg/grizzly/workflow.go @@ -11,7 +11,7 @@ import ( "github.com/google/go-jsonnet" "github.com/grafana/grizzly/pkg/term" - "github.com/kylelemons/godebug/diff" + "github.com/pmezard/go-difflib/difflib" "golang.org/x/crypto/ssh/terminal" "gopkg.in/fsnotify.v1" ) @@ -196,7 +196,14 @@ func Diff(config Config, resources Resources) error { if local == remoteRepresentation { config.Notifier.NoChanges(resource) } else { - difference := diff.Diff(remoteRepresentation, local) + diff := difflib.UnifiedDiff{ + A: difflib.SplitLines(remoteRepresentation), + B: difflib.SplitLines(local), + FromFile: "Remote", + ToFile: "Local", + Context: 3, + } + difference, _ := difflib.GetUnifiedDiffString(diff) config.Notifier.HasChanges(resource, difference) } }