1
0
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:
MOREV Mikhail
2020-01-09 10:51:14 +06:00
parent ef68940d2f
commit 10ef21c8b8

View File

@@ -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 {