Skip to content

Commit

Permalink
Transfer the 'pkg/diff' module to 'github.com/nikhilsbhat/common/diff…
Browse files Browse the repository at this point in the history
…' to enhance its accessibility for others.

Then, incorporate this package into the current context.
  • Loading branch information
nikhilsbhat committed Mar 31, 2024
1 parent 77c287a commit 1cc5235
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 117 deletions.
8 changes: 4 additions & 4 deletions cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"strings"

"github.com/ghodss/yaml"
"github.com/nikhilsbhat/common/diff"
"github.com/nikhilsbhat/common/renderer"
"github.com/nikhilsbhat/gocd-cli/pkg/diff"
"github.com/nikhilsbhat/gocd-cli/pkg/errors"
"github.com/nikhilsbhat/gocd-cli/pkg/utils"
"github.com/nikhilsbhat/gocd-sdk-go"
Expand All @@ -20,7 +20,7 @@ var (
client gocd.GoCd
cliRenderer renderer.Config
cliShellReadConfig *utils.ReadConfig
diffCfg diff.Config
diffCfg *diff.Config
supportedOutputFormats = []string{"yaml", "json", "csv", "table"}
)

Expand Down Expand Up @@ -74,8 +74,8 @@ func setCLIClient(_ *cobra.Command, _ []string) error {
return &errors.CLIError{Message: errMsg}
}

diffCfg = diff.Config{Format: cliCfg.OutputFormat, NoColor: cliCfg.NoColor}
diffCfg.SetLogger(cliLogger)
diffCfg = diff.NewDiff(cliCfg.OutputFormat, cliCfg.NoColor, cliLogger)

cliCfg.setOutputFormats()
cliRenderer = renderer.GetRenderer(writer, cliLogger, cliCfg.NoColor, cliCfg.yaml, cliCfg.json, cliCfg.csv, cliCfg.table)

Expand Down
4 changes: 2 additions & 2 deletions cmd/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

func (cfg *Config) CheckDiffAndAllow(oldData, newData string) error {
hasDiff, diff, err := diffCfg.Diff(oldData, newData)
hasDiff, diffIdentified, err := diffCfg.Diff(oldData, newData)
if err != nil {
return err
}
Expand All @@ -16,7 +16,7 @@ func (cfg *Config) CheckDiffAndAllow(oldData, newData string) error {
os.Exit(0)
}

fmt.Printf("%s\n", diff)
fmt.Printf("%s\n", diffIdentified)
fmt.Printf("%s\n\n", "Above changes would be deployed")

if !cfg.Yes {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/fatih/color v1.16.0
github.com/ghodss/yaml v1.0.0
github.com/goccy/go-yaml v1.11.3
github.com/nikhilsbhat/common v0.0.5-0.20240330150338-6dad4cae0c57
github.com/nikhilsbhat/common v0.0.5-0.20240331064442-d5f43095b010
github.com/nikhilsbhat/gocd-sdk-go v0.1.9
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2
github.com/sirupsen/logrus v1.9.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/Qd
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/neilotoole/jsoncolor v0.7.1 h1:/MoU7KPLcto+ykcy592Y8eX9WFQhoi3IBEbwrP89dgs=
github.com/neilotoole/jsoncolor v0.7.1/go.mod h1:KZ9hUYN5xMrvyhqlFQ3QTmu11OcoqFgSnWAcYkN6abg=
github.com/nikhilsbhat/common v0.0.5-0.20240330150338-6dad4cae0c57 h1:6BYXfUsKO7xwzfA5a2xtY14i90xqiHLCJDV0epRHJU8=
github.com/nikhilsbhat/common v0.0.5-0.20240330150338-6dad4cae0c57/go.mod h1:ldoLjRsIaskDbouPaQ0ujVKbW8su3mI1MPQIaD24twQ=
github.com/nikhilsbhat/common v0.0.5-0.20240331064442-d5f43095b010 h1:TuR/lpOOwNt/uqJp/uhxT+K4MNZkHrbo0NMZSSKyX5c=
github.com/nikhilsbhat/common v0.0.5-0.20240331064442-d5f43095b010/go.mod h1:ldoLjRsIaskDbouPaQ0ujVKbW8su3mI1MPQIaD24twQ=
github.com/nikhilsbhat/gocd-sdk-go v0.1.9 h1:QG16EwKhxocn0Imza6S+/lE8S0MOw54UDebfJotQx2s=
github.com/nikhilsbhat/gocd-sdk-go v0.1.9/go.mod h1:FFVOLXPhn55evuuyfiRJ23R8I5Ks2n31/DXLBQmaNsw=
github.com/nwidger/jsoncolor v0.3.2 h1:rVJJlwAWDJShnbTYOQ5RM7yTA20INyKXlJ/fg4JMhHQ=
Expand Down
108 changes: 0 additions & 108 deletions pkg/diff/diff.go

This file was deleted.

0 comments on commit 1cc5235

Please sign in to comment.