v1alpha1

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder returns a new instance of builder

func BuilderForObject

func BuilderForObject(t types.PatchType, obj []byte) *Builder

BuilderForObject returns a new instance of builder when a patch obj and patch type is given

func BuilderForRuntask

func BuilderForRuntask(context, templateYaml string,
	templateValues map[string]interface{}) *Builder

BuilderForRuntask returns a new instance of builder for runtask when a runtask patch yaml is given

func NewBuilder

func NewBuilder() *Builder

NewBuilder returns a new instance of builder

func (*Builder) AddCheck

func (b *Builder) AddCheck(p Predicate) *Builder

AddCheck adds the predicate as a condition to be validated against the patch instance

func (*Builder) AddCheckf

func (b *Builder) AddCheckf(p Predicate, predicateMsg string, args ...interface{}) *Builder

AddCheckf adds the predicate as a condition to be validated against the patch instance and format the message string according to format specifier. If only predicate and message string is provided, it will treat it as the value for the corresponding predicate.

func (*Builder) AddChecks

func (b *Builder) AddChecks(predicates ...Predicate) *Builder

AddChecks adds the provided predicates as conditions to be validated against the patch instance

func (*Builder) Build

func (b *Builder) Build() (*Patch, error)

Build returns the final instance of patch

type Patch

type Patch struct {
	// Type determines the type of patch to be applied
	Type types.PatchType `json:"type"`
	// object determines the actual patch object
	// in json format
	Object []byte `json:"object"`
}

Patch will consist of patch that gets applied against a particular resource

func (*Patch) GoString

func (p *Patch) GoString() string

GoString provides the essential Patch struct details

func (*Patch) IsValidType

func (p *Patch) IsValidType() bool

IsValidType returns true if provided patch type is one of the valid patch types

func (*Patch) String

func (p *Patch) String() string

String provides the essential Patch details

type PatchType

type PatchType string

PatchType is a custom type that holds the patch type

const (
	// PatchTypeJSON refers to a generic json patch type that is understood
	// by Kubernetes API as well
	PatchTypeJSON PatchType = "json"
	// PatchTypeMerge refers to a generic json merge patch type that is
	// understood by Kubernetes API as well
	PatchTypeMerge PatchType = "merge"
	// PatchTypeStrategic refers to a patch type that is understood
	// by Kubernetes API only
	PatchTypeStrategic PatchType = "strategic"
)

type Predicate

type Predicate func(*Patch) bool

Predicate abstracts conditional logic w.r.t the patch instance

NOTE: Predicate is a functional approach versus traditional approach to mix conditions such as *if-else* within blocks of business logic

NOTE: Predicate approach enables clear separation of conditionals from imperatives i.e. actions that form the business logic

func IsValidType

func IsValidType() Predicate

IsValidType returns a predicate for checking valid patch type

Jump to

Keyboard shortcuts

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