Documentation ¶
Index ¶
- Constants
- Variables
- func NewContainer(kinds ...Kind) *container
- type BasicClientSet
- func (c *BasicClientSet) Client() *kubernetes.Clientset
- func (c *BasicClientSet) ConfigMaps() typedv1core.ConfigMapInterface
- func (c *BasicClientSet) Deployments() typedv1apps.DeploymentInterface
- func (c *BasicClientSet) Ingresses() typedv1beta1net.IngressInterface
- func (c *BasicClientSet) Namespace() string
- func (c *BasicClientSet) Namespaces() typedv1core.NamespaceInterface
- func (c *BasicClientSet) PersistentVolumeClaims() typedv1core.PersistentVolumeClaimInterface
- func (c *BasicClientSet) Secrets() typedv1core.SecretInterface
- func (c *BasicClientSet) Services() typedv1core.ServiceInterface
- type BasicController
- func (c *BasicController) ClientSet() ClientSet
- func (c *BasicController) Configure(opt Option)
- func (c *BasicController) CreateContainer() []error
- func (c *BasicController) CreateKind(kind Kind) (res Resource, err error)
- func (c *BasicController) DeleteContainer() []error
- func (c *BasicController) DeleteKind(kind Kind) error
- func (c *BasicController) GetContainer() []error
- func (c *BasicController) GetKind(kind Kind) (res Resource, err error)
- func (c *BasicController) Hooks() Hooks
- type ClientSet
- type Container
- type Controller
- type Hook
- type HookErr
- type HookErrType
- type HookType
- type Hooks
- type HooksErr
- type HooksManager
- type Kind
- type Option
- type Resource
Constants ¶
const ( PreCreate HookType = "pre_create" PostCreate HookType = "post_create" PreGet HookType = "pre_get" PostGet HookType = "post_get" PreDelete HookType = "pre_delete" PostDelete HookType = "post_delete" ErrCreate HookErrType = "err_create" ErrGet HookErrType = "err_get" ErrDelete HookErrType = "err_delete" )
Variables ¶
var WithClientSet = func(clientset ClientSet) Option { return func(c *BasicController) { c.clientset = clientset } }
var WithContainerCopy = func() Option { return func(c *BasicController) { c.Container = c.Container.Copy() } }
OptionContainerCopy creates BasicController copying the Container
var WithCreateOpts = func(opts v1meta.CreateOptions) Option { return func(c *BasicController) { c.CreateOpts = opts } }
var WithHooks = func(hooks Hooks) Option { return func(c *BasicController) { for t, h := range hooks { if existing := c.hooks[t]; existing == nil { c.hooks[t] = h } else { c.hooks[t] = append(c.hooks[t], h...) } } } }
var WithHooksFirst = func(hooks Hooks) Option { return func(c *BasicController) { for t, h := range hooks { if existing := c.hooks[t]; existing == nil { c.hooks[t] = h } else { h = append(h, c.hooks[t]...) c.hooks[t] = h } } } }
register hooks as first to run
var WithKubernetesClient = func(namespace string, client *kubernetes.Clientset) Option { return func(c *BasicController) { c.clientset = NewClientSet(namespace, client) } }
var WithoutHooks = func() Option { return func(c *BasicController) { c.hooks = make(Hooks) } }
delete all hooks
Functions ¶
func NewContainer ¶
func NewContainer(kinds ...Kind) *container
NewContainer creates new container for Kind's
Types ¶
type BasicClientSet ¶
type BasicClientSet struct {
// contains filtered or unexported fields
}
KubeClientSet implements BasicClientSet
func (*BasicClientSet) Client ¶
func (c *BasicClientSet) Client() *kubernetes.Clientset
func (*BasicClientSet) ConfigMaps ¶
func (c *BasicClientSet) ConfigMaps() typedv1core.ConfigMapInterface
func (*BasicClientSet) Deployments ¶
func (c *BasicClientSet) Deployments() typedv1apps.DeploymentInterface
func (*BasicClientSet) Ingresses ¶
func (c *BasicClientSet) Ingresses() typedv1beta1net.IngressInterface
func (*BasicClientSet) Namespace ¶
func (c *BasicClientSet) Namespace() string
func (*BasicClientSet) Namespaces ¶
func (c *BasicClientSet) Namespaces() typedv1core.NamespaceInterface
func (*BasicClientSet) PersistentVolumeClaims ¶
func (c *BasicClientSet) PersistentVolumeClaims() typedv1core.PersistentVolumeClaimInterface
func (*BasicClientSet) Secrets ¶
func (c *BasicClientSet) Secrets() typedv1core.SecretInterface
func (*BasicClientSet) Services ¶
func (c *BasicClientSet) Services() typedv1core.ServiceInterface
type BasicController ¶
type BasicController struct { Container CreateOpts v1meta.CreateOptions DeleteOpts v1meta.DeleteOptions GetOpts v1meta.GetOptions // contains filtered or unexported fields }
BasicController implements Controller
func (*BasicController) ClientSet ¶
func (c *BasicController) ClientSet() ClientSet
func (*BasicController) Configure ¶
func (c *BasicController) Configure(opt Option)
func (*BasicController) CreateContainer ¶
func (c *BasicController) CreateContainer() []error
func (*BasicController) CreateKind ¶
func (c *BasicController) CreateKind(kind Kind) (res Resource, err error)
func (*BasicController) DeleteContainer ¶
func (c *BasicController) DeleteContainer() []error
func (*BasicController) DeleteKind ¶
func (c *BasicController) DeleteKind(kind Kind) error
func (*BasicController) GetContainer ¶
func (c *BasicController) GetContainer() []error
func (*BasicController) GetKind ¶
func (c *BasicController) GetKind(kind Kind) (res Resource, err error)
func (*BasicController) Hooks ¶
func (c *BasicController) Hooks() Hooks
type ClientSet ¶
type ClientSet interface { Namespace() string Client() *kubernetes.Clientset Namespaces() typedv1core.NamespaceInterface Deployments() typedv1apps.DeploymentInterface Ingresses() typedv1beta1net.IngressInterface Secrets() typedv1core.SecretInterface Services() typedv1core.ServiceInterface ConfigMaps() typedv1core.ConfigMapInterface PersistentVolumeClaims() typedv1core.PersistentVolumeClaimInterface }
ClientSet is meant to manipulate Resource state in kubernetes
func NewClientSet ¶
func NewClientSet(namespace string, client *kubernetes.Clientset) ClientSet
NewClientSet creates new KubeClientSet for a given namespace
type Container ¶
type Container interface { Kinds() []Kind // Kinds() should returns container Kind's Self() Container // Self() returns the Container instance itself Copy() Container // Copy() should return a copy of Container so it can be declared once per package Update(Kind, Resource) error // Update() overrides underlying Kind Resource GetResource(Kind) Resource // GetResource() returns underlying Resource for a Kind ForEachResource(func(Resource)) // ForEachResource() performs function on each Resource ForEachKind(func(Kind)) // ForEachKind() performs function on each Kind // caster methods to get underlying Resource instance for a Kind Namespace(Kind) *v1core.Namespace Deployment(Kind) *v1apps.Deployment Ingress(Kind) *v1beta1net.Ingress Secret(Kind) *v1core.Secret Service(Kind) *v1core.Service ConfigMap(Kind) *v1core.ConfigMap PersistentVolumeClaim(Kind) *v1core.PersistentVolumeClaim }
Container is meant to hold binding between Kind and it's Resource
type Controller ¶
type Controller interface { Container // Container of which Controller is in control Hooks() Hooks Configure(option Option) // Configure accepts Option to modify Controller ClientSet() ClientSet // todo should hooks run here? GetKind(Kind) (Resource, error) // GetKind(Kind) performs kubernetes get request updating underlying Resource CreateKind(Kind) (Resource, error) // CreateKind(Kind) performs kubernetes create request for underlying Resource DeleteKind(Kind) error // DeleteKind(Kind) performs kubernetes delete request for underlying Resource GetContainer() []error // GetContainer() performs kubernetes get request for all Kind's in Container CreateContainer() []error // CreateContainer() performs kubernetes create request for all Kind's in Container DeleteContainer() []error // DeleteContainer() performs kubernetes delete request for all Kind's in Container }
Controller is meant to perform actions on Container via ClientSet a Controller can use Container New() method to construct itself - that allows declaring Container once per package. Each method on Controller handles the underlying Container - updating Resource's that it holds.
func NewController ¶
func NewController(container Container, opts ...Option) Controller
NewController creates new Controller
type Hook ¶
Hook is a hook for a Container for ex. hooks.SetLabels sets labels for all Resource's in a Container
type HookErrType ¶
type HookErrType string
type HooksErr ¶
type HooksErr map[HookErrType][]HookErr
HooksErr is a map of HookErr executed when an error occurs
type HooksManager ¶
todo hooks per kind
type Kind ¶
type Kind interface { Name() string Cast() Resource // Cast() should return new instance of Resource Delete(contr ClientSet, ctx context.Context, name string, opts v1meta.DeleteOptions) error Get(contr ClientSet, ctx context.Context, name string, opts v1meta.GetOptions) (Resource, error) Create(contr ClientSet, ctx context.Context, res Resource, opts v1meta.CreateOptions) (Resource, error) }
Kind is meant to be declared as a constant, that is - a string that allows accessing the underlying kubernetes state of the Resource in a typed (constant) way via Container.
type Option ¶
type Option func(*BasicController)