Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions mimirtool/common.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package mimirtool

import (
"crypto/sha256"
"encoding/hex"
"math/rand"
)

func hash(s string) string {
sha := sha256.Sum256([]byte(s))
return hex.EncodeToString(sha[:])
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

func randStringBytes(n int) string {
b := make([]byte, n)
for i := range b {
b[i] = letterBytes[rand.Intn(len(letterBytes))]
}
return string(b)
}

func stringValueMap(src map[string]interface{}) map[string]string {
Expand Down
2 changes: 1 addition & 1 deletion mimirtool/resource_ruler_namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func rulerNamespaceCreate(ctx context.Context, d *schema.ResourceData, meta any)
}
}

d.SetId(hash(namespace))
d.SetId(randStringBytes(64))
return rulerNamespaceRead(ctx, d, meta)
}

Expand Down