diff with --redacted
This commit is contained in:
parent
b3e189fa8d
commit
3d84f46112
@ -34,9 +34,15 @@ var Diff = &command.Command{
|
||||
},
|
||||
},
|
||||
},
|
||||
"redacted": {
|
||||
Description: "Compare redacted versions",
|
||||
Type: "bool",
|
||||
Default: false,
|
||||
},
|
||||
},
|
||||
Action: func(cmd *command.Command) error {
|
||||
paths := cmd.Arguments[0].ToValue().([]string)
|
||||
redacted := cmd.Options["redacted"].ToValue().(bool)
|
||||
for _, path := range paths {
|
||||
|
||||
local, err := config.Load(path, false)
|
||||
@ -44,7 +50,7 @@ var Diff = &command.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
if err := local.DiffRemote(path, cmd.Cobra.OutOrStdout(), cmd.Cobra.OutOrStderr()); err != nil {
|
||||
if err := local.DiffRemote(path, redacted, cmd.Cobra.OutOrStdout(), cmd.Cobra.OutOrStderr()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ func Update(vault, name string, item *op.Item) error {
|
||||
}
|
||||
|
||||
if remote.GetValue("password") == item.GetValue("password") {
|
||||
logrus.Debugf("remote %s\nlocal %s", remote.GetValue("password"), item.GetValue("password"))
|
||||
logrus.Warnf("item %s/%s is already up to date", item.Vault.ID, item.Title)
|
||||
return nil
|
||||
}
|
||||
|
@ -156,13 +156,19 @@ func (cfg *Config) Merge(other *Config) error {
|
||||
return cfg.Tree.Merge(other.Tree)
|
||||
}
|
||||
|
||||
func (cfg *Config) DiffRemote(path string, stdout io.Writer, stderr io.Writer) error {
|
||||
func (cfg *Config) DiffRemote(path string, redacted bool, stdout, stderr io.Writer) error {
|
||||
logrus.Debugf("loading remote for %s", path)
|
||||
remote, err := Load(path, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
localBytes, err := cfg.AsYAML(OutputModeNoComments, OutputModeSorted, OutputModeNoConfig, OutputModeStandardYAML)
|
||||
modes := []OutputMode{OutputModeNoComments, OutputModeSorted, OutputModeNoConfig, OutputModeStandardYAML}
|
||||
if redacted {
|
||||
modes = append(modes, OutputModeRedacted)
|
||||
}
|
||||
|
||||
localBytes, err := cfg.AsYAML(modes...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -173,7 +179,7 @@ func (cfg *Config) DiffRemote(path string, stdout io.Writer, stderr io.Writer) e
|
||||
}
|
||||
defer cleanupLocalDiff()
|
||||
|
||||
remoteBytes, err := remote.AsYAML(OutputModeNoComments, OutputModeSorted, OutputModeStandardYAML)
|
||||
remoteBytes, err := remote.AsYAML(modes...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -97,7 +97,6 @@ func checksum(fields []*op.ItemField) string {
|
||||
sort.Strings(df)
|
||||
newHash.Write([]byte(strings.Join(df, "")))
|
||||
checksum := newHash.Sum(nil)
|
||||
|
||||
return fmt.Sprintf("%x", checksum)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user