hook

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PreApply   = "pre-apply"
	PostApply  = "post-apply"
	PreDelete  = "pre-delete"
	PostDelete = "post-delete"
)

Supported types of hooks.

Variables

SupportedTypes contains a list of supported hook types.

Functions

func IsSupportedType

func IsSupportedType(typ string) bool

IsSupportedType returns true if typ is a supported hook type.

func LabelSelector

func LabelSelector(chartName, hookType string) string

LabelSelector returns a selector which can be used to find hooks of given type for given chart in a cluster.

func Validate

func Validate(h *Hook) error

Validate returns an error if a hook has an unsupported type or resource kind or if other resource fields have unsupported values.

Types

type Hook

type Hook struct {
	*unstructured.Unstructured
}

Hook gets executed before or after apply/delete depending on its type. It wraps an unstructured object to enhance it with some extra logic for validation and working with hook options.

func New

func New(obj runtime.Object) (*Hook, error)

New creates a new hook from a runtime object.

func (*Hook) AllowFailure

func (h *Hook) AllowFailure() bool

AllowFailure indicates whether the hook is allowed to fail or not. If true, hook errors are only printed and execution continues. If this is true, NoWait() must not return true as well.

func (*Hook) NoWait

func (h *Hook) NoWait() bool

NoWait indicates whether it should be waited for the hook to complete or not. If true, AllowFailure() must not return true and it is also not possible to detect possible hook failures.

func (*Hook) Type

func (h *Hook) Type() string

Type returns the hook type, e.g. post-apply.

func (*Hook) WaitTimeout

func (h *Hook) WaitTimeout() (time.Duration, error)

WaitTimeout returns the timeout for waiting for hook completion and an error if the annotation cannot be parsed.

type List

type List []*Hook

List is a slice of *Hook.

func (List) EachItem

func (l List) EachItem(fn func(*Hook) error) error

EachItem walks the list and calls fn for each item. If fn returns an error for any hook, walking the list is stopped and the error is returned.

func (List) ToObjectList

func (l List) ToObjectList() []runtime.Object

ToObjectList converts l to a slice of runtime.Object.

type Map

type Map map[string]List

Map is a map of hook type to lists of hooks.

func (Map) Add

func (m Map) Add(hooks ...*Hook) Map

Add adds hooks to the map and puts them into the buckets determined by their type.

func (Map) All

func (m Map) All() List

All returns all hooks contained in the m as a List.

type UnsupportedKindError

type UnsupportedKindError struct {
	Kind string
}

UnsupportedKindError denotes that the hook object has a resource kind that is not supported to be used as a hook.

func (UnsupportedKindError) Error

func (e UnsupportedKindError) Error() string

Error implements the error interface.

type UnsupportedTypeError

type UnsupportedTypeError struct {
	Type string
}

UnsupportedTypeError denotes that a hook has a type that is not supported.

func (UnsupportedTypeError) Error

func (e UnsupportedTypeError) Error() string

Error implements the error interface.

Jump to

Keyboard shortcuts

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