actions

package
v0.0.0-...-f8f77fb Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ObjectKeyFromTemplate

func ObjectKeyFromTemplate(namespaceTemplate, nameTemplate string, event events.Event) client.ObjectKey

ObjectKeyFromTemplate create a client.ObjectKey from a namespace and name template.

Types

type Action

type Action interface {
	Perform(context.Context, events.Event) error
	GetName() string
	GetType() string
	GetTargetObjectName(events.Event) string
	SupportsRetry() bool
}

type ActionBuilder

type ActionBuilder func(v1alpha1.Action, ActionContext, bool) Action

type ActionContext

type ActionContext struct {
	Client         client.Client
	RestConfig     *rest.Config
	Recorder       record.EventRecorder
	CounterMeasure v1alpha1.CounterMeasure
}

type ActionRunner

type ActionRunner interface {
	Run(ActionContext, events.Event)
}

type BaseAction

type BaseAction struct {
	DryRun       bool
	RetryEnabled bool
	Name         string
	// contains filtered or unexported fields
}

func NewBase

func NewBase(c client.Client, spec v1alpha1.Action, dryRun bool) BaseAction

func (*BaseAction) GetName

func (b *BaseAction) GetName() string

func (*BaseAction) SupportsRetry

func (b *BaseAction) SupportsRetry() bool

type Debug

type Debug struct {
	BaseAction
	// contains filtered or unexported fields
}

func NewDebugAction

func NewDebugAction(coreV1Client clientCoreV1.CoreV1Interface,
	client client.Client,
	spec v1alpha1.DebugSpec) *Debug

func NewDebugFromBase

func NewDebugFromBase(base BaseAction,
	coreV1Client clientCoreV1.CoreV1Interface,
	spec v1alpha1.DebugSpec) *Debug

func (*Debug) GetTargetObjectName

func (d *Debug) GetTargetObjectName(event events.Event) string

func (*Debug) GetType

func (d *Debug) GetType() string

func (*Debug) Perform

func (d *Debug) Perform(ctx context.Context, event events.Event) error

type Delete

type Delete struct {
	BaseAction
	// contains filtered or unexported fields
}

func NewDeleteAction

func NewDeleteAction(client client.Client, spec v1alpha1.DeleteSpec) *Delete

func NewDeleteFromBase

func NewDeleteFromBase(base BaseAction, spec v1alpha1.DeleteSpec) *Delete

func (*Delete) GetTargetObjectName

func (d *Delete) GetTargetObjectName(event events.Event) string

func (*Delete) GetType

func (d *Delete) GetType() string

func (*Delete) Perform

func (d *Delete) Perform(ctx context.Context, event events.Event) error

type InMemoryRunner

type InMemoryRunner []Action

func (InMemoryRunner) Run

func (seq InMemoryRunner) Run(eventCtx ActionContext, event events.Event)

Run called with an event when the counter measure actions need to be exeucted.

type Manager

type Manager struct {
	ActionRegistry Registry
	// contains filtered or unexported fields
}

func NewFromManager

func NewFromManager(mgr controller.Manager, bus *eventbus.EventBus) *Manager

NewFromManager construct a new action manager

func (*Manager) Add

func (m *Manager) Add(cm *v1alpha1.CounterMeasure) error

Add install a countermeasure to route events to

func (*Manager) Exists

func (m *Manager) Exists(objectName metav1.ObjectMeta) bool

Exists check if a countermeasure is installed

func (*Manager) Remove

func (m *Manager) Remove(name types.NamespacedName) error

Remove uninstall a countermeasure from the event subscription

type Patch

type Patch struct {
	BaseAction
	// contains filtered or unexported fields
}

func NewPatchAction

func NewPatchAction(client client.Client, spec v1alpha1.PatchSpec) *Patch

func NewPatchFromBase

func NewPatchFromBase(base BaseAction, spec v1alpha1.PatchSpec) *Patch

func (*Patch) GetTargetObjectName

func (p *Patch) GetTargetObjectName(event events.Event) string

func (*Patch) GetType

func (d *Patch) GetType() string

func (*Patch) Perform

func (p *Patch) Perform(ctx context.Context, event events.Event) error

Perform will apply the patch to the object

type PatchData

type PatchData struct {
	events.EventData
	*unstructured.Unstructured
}

type Registry

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

func (*Registry) Initialize

func (r *Registry) Initialize()

Initialize registers all the known actions with the registry

func (*Registry) NewRunner

func (r *Registry) NewRunner(ctx ActionContext) (ActionRunner, error)

ConvertToHandler converts a countermeasure and all actions within into a handler for source events.

func (*Registry) RegisterAction

func (r *Registry) RegisterAction(prototype interface{}, builder ActionBuilder)

RegisterAction register a new action with the registry

type Restart

type Restart struct {
	BaseAction
	// contains filtered or unexported fields
}

func NewRestartAction

func NewRestartAction(client client.Client, spec v1alpha1.RestartSpec) *Restart

func NewRestartFromBase

func NewRestartFromBase(base BaseAction, spec v1alpha1.RestartSpec) *Restart

func (*Restart) GetTargetObjectName

func (r *Restart) GetTargetObjectName(event events.Event) string

func (*Restart) GetType

func (d *Restart) GetType() string

func (*Restart) Perform

func (r *Restart) Perform(ctx context.Context, event events.Event) error

Perform will apply the restart patch to the deployment

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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