Skip to content

Commit

Permalink
Function for locally generating ETag
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielHougaard committed Aug 27, 2024
1 parent 03cc71c commit fe11b8e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cli/packages/util/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"crypto/sha256"
"encoding/base64"
"encoding/hex"
"fmt"
"math/rand"
"os"
Expand Down Expand Up @@ -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[:]))
}

0 comments on commit fe11b8e

Please sign in to comment.