hook

package
v1.0.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2019 License: Apache-2.0 Imports: 15 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	WorkingDir string
	TempDir    string
	EventCh    chan Event
)
View Source
var ContextBindingType = map[BindingType]string{
	Schedule:   "schedule",
	OnStartup:  "onStartup",
	KubeEvents: "onKubernetesEvent",
}

Functions

This section is empty.

Types

type BindingContext

type BindingContext struct {
	Binding           string `json:"binding"`
	ResourceEvent     string `json:"resourceEvent,omitempty"`
	ResourceNamespace string `json:"resourceNamespace,omitempty"`
	ResourceKind      string `json:"resourceKind,omitempty"`
	ResourceName      string `json:"resourceName,omitempty"`
}

Additional info from schedule and kube events

type BindingType

type BindingType string
const (
	Schedule   BindingType = "SCHEDULE"
	OnStartup  BindingType = "ON_STARTUP"
	KubeEvents BindingType = "KUBE_EVENTS"
)

type Event

type Event struct {
	Type EventType
}

type EventType

type EventType string
const (
	HooksLoaded EventType = "HOOKS_LOADED"
)

type Hook

type Hook struct {
	Name           string // The unique name like '002-prometheus-hooks/startup_hook'.
	Path           string // The absolute path to the executable file.
	Bindings       []BindingType
	OrderByBinding map[BindingType]float64
	Config         *HookConfig
	// contains filtered or unexported fields
}

func NewHook

func NewHook(name, path string) *Hook

func (*Hook) Run

func (h *Hook) Run(bindingType BindingType, context []BindingContext) error

func (*Hook) SafeName

func (h *Hook) SafeName() string

func (*Hook) WithConfig

func (h *Hook) WithConfig(configOutput []byte) (hook *Hook, err error)

type HookConfig

type HookConfig struct {
	OnStartup         interface{}                                   `json:"onStartup"`
	Schedule          []schedule_manager.ScheduleConfig             `json:"schedule"`
	OnKubernetesEvent []kube_events_manager.OnKubernetesEventConfig `json:"onKubernetesEvent"`
}

type HookManager

type HookManager interface {
	Run()
	GetHook(name string) (*Hook, error)
	GetHooksInOrder(bindingType BindingType) []string
	RunHook(hookName string, binding BindingType, bindingContext []BindingContext) error
}

func Init

func Init(workingDir string, tempDir string) (HookManager, error)

type MainHookManager

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

func NewMainHookManager

func NewMainHookManager() *MainHookManager

func (*MainHookManager) GetHook

func (hm *MainHookManager) GetHook(name string) (*Hook, error)

func (*MainHookManager) GetHooksInOrder

func (hm *MainHookManager) GetHooksInOrder(bindingType BindingType) []string

func (*MainHookManager) Run

func (hm *MainHookManager) Run()

HookManager has no events for now unlike antiopa

func (*MainHookManager) RunHook

func (hm *MainHookManager) RunHook(hookName string, binding BindingType, bindingContext []BindingContext) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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