resources

package
v1.17.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeYaml

func DecodeYaml(yaml string, tplValues interface{}, resource interface{}) error

DecodeYaml Initialise the resource object passes as argument with its yaml definition. If tplValues is provided (key/values or structs as documented by the html/template GO module), the yaml string is considered as a template that will be interpreted. The yaml string can also be used to pass a JSON data string, howver in this case, the tplValues are totaly useless and must be nil. Note that any data existing in the resource object not described in the yaml file, are preserved by this function. Thus the DecodeYaml function is more a merge function that preserve existing values in the resource and override only values provided by the YAML data.

func TplToByteBuffer

func TplToByteBuffer(doc string, tplValues interface{}) (bytes.Buffer, error)

TplToByteBuffer xx

func TplToBytes

func TplToBytes(doc string, tplValues interface{}) ([]byte, error)

TplToBytes xx

Types

type MutableResource

type MutableResource interface {

	// UpdateSyncStatus Apply an annotation fingerprint to the object which permits to follows object modifications.
	// Compute new object's fingerprint (Hash) and compare it with the existing fingerprint.
	// Update status telling if yes or no the expected value is Synched with the Cluster Resource
	// When it is an object creation, no existing hash value exists, thus the needResync property will be TRUE!
	UpdateSyncStatus(ref okthash.HashableRef) error

	// Is this object (before, after or without mutation) out of sync with its peer ?
	// The NeedResync status is updated as well thanks to a call to UpdateSyncStatus()
	// As soon it is triggered to True it remains at True
	NeedResync() bool
	// If NeedResync() is already true, LastSyncState() allow to know if last call to UpdateSyncStatus has detected NO modification.
	LastSyncState() bool

	PreMutate(scheme *runtime.Scheme) error
	PostMutate(cr client.Object, scheme *runtime.Scheme) error

	// Verify  that object keys (index) remains the same as expected, even after a modifications
	CheckExpectedKey() error

	UpdatePeer() error
}

MutableResource provides all the required tools to process a mutation on a resource having a Mutator (mandatory) All things driven with idempotency in mind.

type MutableResourceType

type MutableResourceType interface {
	Resource
	MutableResource
	Mutator
}

MutableResourceType is an OKT resource leading a resource type that can be mutated by an OKT Reconciler

type MutationHelper

type MutationHelper interface {
	GetObject() client.Object
	GetObjectSpec() interface{}
	PreMutate() error
	PostMutate() error
}

MutationHelper provides pre and post mutation help in order to deal with specific resources beahaviour like Secrets When a mutation helper has been defined for a MutableResourceType, it can then be added to the Pre and PostMutate() functions called by the OKT Reconciler.

type Mutator

type Mutator interface {
	// HashableRef is a reference (address) on a structure we want to use for
	// the Hash calculation performed to detect object's modification
	GetHashableRef() okthash.HashableRef

	MutateWithInitialData() error                          // Initial data are the one set at creation time
	MutateWithCR() (requeueAfterSeconds uint16, err error) // Custom Resource data can evolve during resource life cycle
}

Mutator is an interface providing mutation function based on hash computation to determines changes on the resource The HashableRef provides all the objects entering in the scope of the Hash computation

type Params

type Params interface {
	SetData(map[string]string)
	GetData() map[string]string
}

Params brings resources parameters to use for reconciliation

type Resource

type Resource interface {
	ResourceInfo

	IsCreation() bool
	CreatePeer() error
	SyncFromPeer() error
	Params
}

Resource a resource manageable by the OKT Reconciler. It is synchronized with its peer on cluster and offers utilities for its creation. A simple Resource can NOT be mutated (see MutableResource), but only created.

type ResourceInfo

type ResourceInfo interface {
	// A uniq key name
	Index() string
	// Commodity name composed with resource "Kind/Name"
	KindName() string
}

ResourceInfo interface provides resource ID and name

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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