hook

package
v1.0.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2019 License: Apache-2.0 Imports: 15 Imported by: 4 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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