Documentation ¶
Overview ¶
Package hashbasedstate provides types and functions to compare objects by a hash and a position in a yaml sequence.
The hashbasedstate package should only be used objects unmarshalled from a yaml sequences as they have a defined order. The comparison is based on labels for a hash and an index put on a kubernetes object. The hash label holds the hash that represents the object and the index value holds the position of the object in the sequence. Both of this information is then used to identify if an object was changed, removed or newly added.
Since this comparison is based on the order of objects, it means that adding a new object before an existing object in the sequence triggers an update for all the following objects, since their position in the sequence has changed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddLabelsToAuthorizationPolicy ¶
func AddLabelsToAuthorizationPolicy(ap *securityv1beta1.AuthorizationPolicy, indexInYaml int) error
AddLabelsToAuthorizationPolicy adds hashing labels.
func GetAuthorizationPolicyHash ¶
func GetAuthorizationPolicyHash(ap *securityv1beta1.AuthorizationPolicy) (string, error)
Types ¶
type AuthorizationPolicyHashable ¶
type AuthorizationPolicyHashable struct {
// contains filtered or unexported fields
}
func NewAuthorizationPolicy ¶
func NewAuthorizationPolicy(ap *securityv1beta1.AuthorizationPolicy) AuthorizationPolicyHashable
func (*AuthorizationPolicyHashable) ToObject ¶
func (a *AuthorizationPolicyHashable) ToObject() client.Object
type Changes ¶
Changes that need to be applied to reach the desired state
func GetChanges ¶
GetChanges returns the changes that need to be applied to reach the desired state by comparing the hash keys of the objects in the desired and actual state.
type Desired ¶
type Desired struct {
// contains filtered or unexported fields
}
func NewDesired ¶
func NewDesired() Desired
func (*Desired) Add ¶
Add the value to the desired state. Since setting the hashing labels is decoupled from adding objects to the state we need to protect against the creation of objects in that do not have the required hash and index labels, this function returns an error if one of these labels is missing.