models

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompileTapFiltersObject

type CompileTapFiltersObject struct {
	Key     *template.Template
	Value   string
	Operand string
}

type CompiledConfig

type CompiledConfig struct {
	Flows []CompiledFlow `yaml:"taps"`
}

type CompiledFlow

type CompiledFlow struct {
	Tap   CompiledTap    `yaml:"tap"`
	Sinks []CompiledSink `yaml:"sinks"`
}

func (CompiledFlow) NewObjectInstance

func (c CompiledFlow) NewObjectInstance() client.Object

type CompiledSink

type CompiledSink struct {
	Name         string
	Method       string
	URLTemplate  *template.Template
	BodyTemplate *template.Template
	Header       map[string][]string
}

type CompiledTap

type CompiledTap struct {
	Name       string
	Filter     CompiledTapFilter
	Kind       string `yaml:"kind"`
	APIVersion string `yaml:"apiVersion"`
}

type CompiledTapFilter

type CompiledTapFilter struct {
	Name      *regexp.Regexp
	Namespace *regexp.Regexp
	Object    *CompileTapFiltersObject
}

type Config

type Config struct {
	// List of the Flows.
	Flows []Flow `yaml:"flows"`

	// List of the Taps.
	Taps []Tap `yaml:"taps"`

	// List of the Sinks.
	Sinks []Sink `yaml:"sinks"`
}

Config defines the configuration structure of the Watchtower.

func NewConfig

func NewConfig(path string) (*Config, error)

func (*Config) Compile

func (c *Config) Compile() (*CompiledConfig, error)

type Flow

type Flow struct {
	// Name of the Tap
	// +required
	Tap string `yaml:"tap"`

	// Name of the Sink
	// +required
	Sink string `yaml:"sink"`
}

Flow is a pairing of the tap and the sink. That defines the specific tap will be sink into specified sink.

type Sink

type Sink struct {
	// Name of the Sink
	// +required
	Name string `yaml:"name"`

	// Http Method that will be used in sink like POST, GET, PUT etc.
	// +required
	Method string `yaml:"method"`

	// Template of the Url that needs to be crafted and request will be sent.
	// Object fields can be used in the template.
	// +required
	URLTemplate string `yaml:"urlTemplate"`

	// Template of the Body that needs to be crafted and sent.
	// Object fields can be used in the template.
	// +required
	BodyTemplate string `yaml:"bodyTemplate"`

	// Key-Value pairs that will be sent as header in the request.
	// +required
	Header map[string]string `yaml:"header"`
}

Sink defines the endpoint the resources will be informed to.

func (*Sink) Compile

func (c *Sink) Compile() CompiledSink

type Tap

type Tap struct {
	// Name of the Tap
	// +required
	Name string `yaml:"name"`

	// Kind of the Kubernetes Resource
	// +required
	Kind string `yaml:"kind"`

	// APIVersion of the Kubernetes Resource
	// +required
	APIVersion string `yaml:"apiVersion"`

	// Filter that will be used while processing the Resource
	// +optional
	Filter *struct {
		// Filter for the resource names, regular expression can be used.
		// +optional
		Name string `yaml:"name"`

		// Filter for the resource namespaces, regular expression can be used.
		// +optional
		Namespace string `yaml:"namespace"`

		// Filter according to the comparison of the object fields.
		// +optional
		Object *struct {
			// Key of the object field. E.g. ".spec.a.b"
			// +optional
			Key string `yaml:"key"`

			// Value of the object.
			// +optional
			Value string `yaml:"value"`

			// Operator that will be used in while doing evaluation like = or !=.
			// +optional
			Operator string `yaml:"operator"`
		} `yaml:"object"`
	} `yaml:"filter"`
}

func (Tap) Compile

func (r Tap) Compile() CompiledTap

Jump to

Keyboard shortcuts

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