mirror of
https://github.com/getsops/sops.git
synced 2026-02-05 12:45:21 +01:00
Skip publish to Vault if secret is up-to-date
in order to avoid version increment
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
vault "github.com/hashicorp/vault/api"
|
||||
)
|
||||
|
||||
@@ -65,6 +66,17 @@ func (vaultd *VaultDestination) UploadUnencrypted(data map[string]interface{}, f
|
||||
}
|
||||
}
|
||||
|
||||
existingSecret, err := client.Logical().Read(vaultd.secretsPath(fileName))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if existingSecret != nil {
|
||||
if cmp.Equal(data, existingSecret.Data["data"]) {
|
||||
fmt.Printf("Secret in %s is already up-to-date.\n", vaultd.secretsPath(fileName))
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
secretsData := make(map[string]interface{})
|
||||
|
||||
if vaultd.kvVersion == 1 {
|
||||
|
||||
Reference in New Issue
Block a user