Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Function for locally generating ETag

Daniel Hougaardfe11b8e57edd
diff --git a/cli/packages/util/helper.go b/cli/packages/util/helper.go
index 69a310efae..b758ebd9d7 100644
--- a/cli/packages/util/helper.go
+++ b/cli/packages/util/helper.go
@@ -4,6 +4,7 @@ import (
"bytes"
"crypto/sha256"
"encoding/base64"
+ "encoding/hex"
"fmt"
"math/rand"
"os"
@@ -298,3 +299,16 @@ func GenerateRandomString(length int) string {
}
return string(b)
}
+
+func GenerateETagFromSecrets(secrets []models.SingleEnvironmentVariable) string {
+ sortedSecrets := SortSecretsByKeys(secrets)
+ content := []byte{}
+
+ for _, secret := range sortedSecrets {
+ content = append(content, []byte(secret.Key)...)
+ content = append(content, []byte(secret.Value)...)
+ }
+
+ hash := sha256.Sum256(content)
+ return fmt.Sprintf(`"%s"`, hex.EncodeToString(hash[:]))
+}