hashbasedstate

package
v0.0.0-...-b7a9461 Latest Latest
Warning

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

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

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 Actual

type Actual struct {
	// contains filtered or unexported fields
}

func NewActual

func NewActual() Actual

func (*Actual) Add

func (a *Actual) Add(hashable Hashable)

Add the value to the desired state. If the value does not have the hash and index labels, an error is returned.

type AuthorizationPolicyHashable

type AuthorizationPolicyHashable struct {
	// contains filtered or unexported fields
}

func (*AuthorizationPolicyHashable) ToObject

type Changes

type Changes struct {
	Create []client.Object
	Delete []client.Object
	Update []client.Object
}

Changes that need to be applied to reach the desired state

func GetChanges

func GetChanges(desiredState Desired, actualState Actual) Changes

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.

func (Changes) String

func (c Changes) String() string

type Desired

type Desired struct {
	// contains filtered or unexported fields
}

func NewDesired

func NewDesired() Desired

func (*Desired) Add

func (d *Desired) Add(h Hashable) error

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.

type Hashable

type Hashable interface {
	ToObject() client.Object
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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