mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 12:27:28 +00:00
Function for locally generating ETag
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
@@ -298,3 +299,16 @@ func GenerateRandomString(length int) string {
|
|||||||
}
|
}
|
||||||
return string(b)
|
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[:]))
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user