config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

package config

Index

Constants

View Source
const SwoopWorkflowIdLabelName = "swoop.element84.com/workflowId"

Variables

View Source
var CallbackTypes = map[CallbackType]struct{}{
	SingleCallback:     {},
	PerFeatureCallback: {},
}
View Source
var HandlerTypes = map[HandlerType]struct{}{
	Noop:          {},
	SyncHttp:      {},
	ArgoWorkflows: {},
	Cirrus:        {},
}

Functions

This section is empty.

Types

type ArgoConf

type ArgoConf struct {
	InstanceId string      `yaml:"instanceId"`
	K8sOptions *K8sOptions `yaml:"k8sOptions"`
}

func (*ArgoConf) GetConfig

func (ac *ArgoConf) GetConfig() clientcmd.ClientConfig

func (*ArgoConf) GetNamespace

func (ac *ArgoConf) GetNamespace() (string, error)

type ArgoSubmitOptsGenerator

type ArgoSubmitOptsGenerator func(wfUuid uuid.UUID, priority int) *wfv1.SubmitOpts

type ArgoTemplate

type ArgoTemplate struct {
	Kind string
	Name string
}

func (*ArgoTemplate) UnmarshalYAML

func (at *ArgoTemplate) UnmarshalYAML(unmarshal func(interface{}) error) error

type ArgoWorkflowOpts

type ArgoWorkflowOpts struct {
	Template       *ArgoTemplate          `yaml:"template"`
	Parameters     ArgoWorkflowParameters `yaml:"parameters"`
	ServiceAccount string                 `yaml:"serviceAccount"`
	Labels         Labels                 `yaml:"labels"`
	Annotations    Labels                 `yaml:"annotations"`
}

func (*ArgoWorkflowOpts) SetWorkflowIdLabel

func (awo *ArgoWorkflowOpts) SetWorkflowIdLabel(id string) error

func (*ArgoWorkflowOpts) SubmitOptsGenerator

func (awo *ArgoWorkflowOpts) SubmitOptsGenerator() (ArgoSubmitOptsGenerator, error)

func (*ArgoWorkflowOpts) UnmarshalYAML

func (awo *ArgoWorkflowOpts) UnmarshalYAML(unmarshal func(interface{}) error) error

type ArgoWorkflowParameters

type ArgoWorkflowParameters map[string]string

func (ArgoWorkflowParameters) StringArray

func (p ArgoWorkflowParameters) StringArray() (params []string)

func (*ArgoWorkflowParameters) UnmarshalYAML

func (p *ArgoWorkflowParameters) UnmarshalYAML(unmarshal func(interface{}) error) error

func (ArgoWorkflowParameters) Validate

func (p ArgoWorkflowParameters) Validate() error

type Callback

type Callback struct {
	Name        string       `yaml:"-"`
	HandlerName string       `yaml:"handler"`
	Type        CallbackType `yaml:"type"`
	// TODO: need to parse filter into a type
	FeatureFilter string              `yaml:"featureFilter,omitempty"`
	When          *CallbackWhen       `yaml:"when"`
	Parameters    *CallbackParameters `yaml:"parameters,omitempty"`
	Handler       *Handler            `yaml:"-"`
}

func (*Callback) ValidateParams

func (cb *Callback) ValidateParams(params any) error

type CallbackParameter

type CallbackParameter struct {
	Value interface{}        `yaml:"value"`
	Path  *jsonpath.JsonPath `yaml:"path"`
}

type CallbackParameters

type CallbackParameters map[string]*CallbackParameter

type CallbackType

type CallbackType string
const (
	SingleCallback     CallbackType = "single"
	PerFeatureCallback CallbackType = "perfeature"
)

func ParseCallbackType

func ParseCallbackType(s string) (CallbackType, error)

func (CallbackType) String

func (cbt CallbackType) String() string

func (*CallbackType) UnmarshalYAML

func (cbt *CallbackType) UnmarshalYAML(unmarshal func(interface{}) error) error

type CallbackWhen

type CallbackWhen []states.FinalState

func (*CallbackWhen) UnmarshalYAML

func (cw *CallbackWhen) UnmarshalYAML(unmarshal func(interface{}) error) error

type Callbacks

type Callbacks map[string]*Callback

func (*Callbacks) UnmarshalYAML

func (cbs *Callbacks) UnmarshalYAML(unmarshal func(interface{}) error) error

type CirrusWorkflowOpts

type CirrusWorkflowOpts struct {
	SfnArn string `yaml:"sfnArn"`
}

type Conductor

type Conductor struct {
	HandlerNames []string   `yaml:"handlers,omitempty"`
	Handlers     []*Handler `yaml:"-"`
}

type Conductors

type Conductors map[string]*Conductor

type ConfigFile

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

func (*ConfigFile) AddFlags

func (cf *ConfigFile) AddFlags(fs *pflag.FlagSet)

func (*ConfigFile) Parse

func (cf *ConfigFile) Parse() (*SwoopConfig, error)

type Handler

type Handler struct {
	Name string      `yaml:"-"`
	Type HandlerType `yaml:"type"`
	// TODO: need a backoff type
	Backoff    map[string]int     `yaml:"backoff"`
	Parameters *HandlerParameters `yaml:"parameters"`
	Secrets    []*HandlerSecret   `yaml:"secrets"`
	Workflows  []*Workflow        `yaml:"-"`
	HttpClient *http.Client       `yaml:"request,omitempty"`
	ArgoConf   *ArgoConf          `yaml:"argoConf,omitempty"`
}

func (*Handler) UnmarshalYAML

func (h *Handler) UnmarshalYAML(unmarshal func(interface{}) error) error

type HandlerParameters

type HandlerParameters jsonschema.Schema

func (*HandlerParameters) UnmarshalYAML

func (p *HandlerParameters) UnmarshalYAML(unmarshal func(interface{}) error) error

func (*HandlerParameters) Validate

func (p *HandlerParameters) Validate(data any) error

type HandlerSecret

type HandlerSecret struct {
	Name string `yaml:"name"`
	Type string `yaml:"type"`
	Path string `yaml:"path"`
	TTL  int    `yaml:"ttl"`
}

TODO: how does this even work?

I think we need another type to actually fetch/retrive the value?
Or maybe it just checks the value at read time,
and if enough time has passed since last read it tries to read again?
If error on read after startup use last value and log error
-> next read should be scheduled, and we can use that to backoff reads on error

type HandlerType

type HandlerType string
const (
	Noop          HandlerType = "noop"
	SyncHttp      HandlerType = "synchttp"
	ArgoWorkflows HandlerType = "argoworkflows"
	Cirrus        HandlerType = "cirrus"
)

func ParseHandlerType

func ParseHandlerType(s string) (HandlerType, error)

func (HandlerType) String

func (cbt HandlerType) String() string

func (*HandlerType) UnmarshalYAML

func (ht *HandlerType) UnmarshalYAML(unmarshal func(interface{}) error) error

type Handlers

type Handlers map[string]*Handler

func (*Handlers) UnmarshalYAML

func (hs *Handlers) UnmarshalYAML(unmarshal func(interface{}) error) error

type K8sOptions

type K8sOptions struct {
	Kubeconfig      string                     `yaml:"kubeconfig"`
	ConfigOverrides *clientcmd.ConfigOverrides `yaml:"configOverrides"`
}

type Labels

type Labels labels.Set

func (Labels) Add

func (l Labels) Add(key, val string) (Labels, error)

func (Labels) Get

func (l Labels) Get(key string) (string, bool)

func (Labels) String

func (l Labels) String() string

func (*Labels) UnmarshalYAML

func (l *Labels) UnmarshalYAML(unmarshal func(interface{}) error) error

func (Labels) Validate

func (l Labels) Validate() error

type SwoopConfig

type SwoopConfig struct {
	Workflows  Workflows  `yaml:"workflows"`
	Handlers   Handlers   `yaml:"handlers"`
	Conductors Conductors `yaml:"conductors"`
}

func Parse

func Parse(configFile string) (*SwoopConfig, error)

func (*SwoopConfig) LinkAndValidate

func (sc *SwoopConfig) LinkAndValidate() error

func (*SwoopConfig) UnmarshalYAML

func (sc *SwoopConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

TODO: using this pattern in many places -> make a generic unmarshal function that takes an interface with a postUnmarshal

function or something that can be used to run validation and other such steps

type Workflow

type Workflow struct {
	Id string

	HandlerName string              `yaml:"handler"`
	Callbacks   Callbacks           `yaml:"callbacks"`
	ArgoOpts    *ArgoWorkflowOpts   `yaml:"argoOpts,omitempty"`
	CirrusOpts  *CirrusWorkflowOpts `yaml:"cirrusOpts,omitempty"`
	// contains filtered or unexported fields
}

func (*Workflow) GetHandler

func (wf *Workflow) GetHandler() *Handler

type Workflows

type Workflows map[string]*Workflow

func (*Workflows) UnmarshalYAML

func (wfs *Workflows) UnmarshalYAML(unmarshal func(interface{}) error) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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