MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / ComputeHash

Function ComputeHash

pkg/utils/hash/hash.go:49–56  ·  view source on GitHub ↗

ComputeHash returns a hash value calculated from the provided object. The hash will be safe encoded to avoid bad words.

(object interface{})

Source from the content-addressed store, hash-verified

47// ComputeHash returns a hash value calculated from the provided object.
48// The hash will be safe encoded to avoid bad words.
49func ComputeHash(object interface{}) (string, error) {
50 hasher := fnv.New32a()
51 if err := DeepHashObject(hasher, object); err != nil {
52 return "", err
53 }
54
55 return rand.SafeEncodeString(fmt.Sprint(hasher.Sum32())), nil
56}
57
58// ComputeVersionedHash follows the same rules of ComputeHash with the exception that accepts also a epoc value.
59// The epoc value is used to generate a new hash from a same object.

Callers 5

CreatePodEnvConfigFunction · 0.92
computeTemplateHashFunction · 0.92
hash_test.goFile · 0.85
ComputeVersionedHashFunction · 0.85

Calls 1

DeepHashObjectFunction · 0.85

Tested by

no test coverage detected