hash

package
v1.23.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package hash allows the user to get a hash number for a given Kubernetes object. This is useful to detect when a derived resource need to be changed too.

The code in this package is adapted from:

https://github.com/kubernetes/kubernetes/blob/master/pkg/util/hash/hash.go // wokeignore:rule=master https://github.com/kubernetes/kubernetes/blob/ea07644/pkg/controller/controller_utils.go#L1189

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeHash

func ComputeHash(object interface{}) (string, error)

ComputeHash returns a hash value calculated from pod template and a collisionCount to avoid hash collision. The hash will be safe encoded to avoid bad words.

func ComputeVersionedHash added in v1.19.6

func ComputeVersionedHash(object interface{}, epoc int) (string, error)

ComputeVersionedHash follows the same rules of ComputeHash with the exception that accepts also a epoc value. The epoc value is used to generate a new hash from a same object. This is useful to force a new hash even if the original object is not changed. A practical use is to force a reconciliation loop of the object.

func DeepHashObject

func DeepHashObject(hasher hash.Hash, objectToWrite interface{}) error

DeepHashObject writes specified object to hash using the spew library which follows pointers and prints actual values of the nested objects ensuring the hash does not change when a pointer changes.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL