config

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingName ..
	ErrMissingName = fmt.Errorf(`name field is required for an injection config`)
)

Functions

This section is empty.

Types

type Config

type Config struct {
	sync.RWMutex
	AnnotationNamespace string                      `yaml:"annotationNamespace"`
	Injections          map[string]*InjectionConfig `yaml:"injections"`
}

Config is a struct indicating how a given injection should be configured

func LoadConfigDirectory

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

LoadConfigDirectory loads all configs in a directory and returns the Config

func (*Config) GetRequestedConfig

func (c *Config) GetRequestedConfig(key string) (*InjectionConfig, error)

GetRequestedConfig returns the InjectionConfig given a requested key

func (*Config) ReplaceInjectionConfigs

func (c *Config) ReplaceInjectionConfigs(replacementConfigs []*InjectionConfig)

ReplaceInjectionConfigs will take a list of new InjectionConfigs, and replace the current configuration with them. this blocks waiting on being able to update the configs in place.

func (*Config) RequestAnnotationKey

func (c *Config) RequestAnnotationKey() string

func (*Config) RequestInitAnnotationKey

func (c *Config) RequestInitAnnotationKey() string

func (*Config) StatusAnnotationKey

func (c *Config) StatusAnnotationKey() string

type ExecAction

type ExecAction struct {
	// Command is the command line to execute inside the container, the working directory for the
	// command  is root ('/') in the container's filesystem. The command is simply exec'd, it is
	// not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use
	// a shell, you need to explicitly call out to that shell.
	// Exit status of 0 is treated as live/healthy and non-zero is unhealthy.
	// +optional
	Command []string `json:"command,omitempty"`
}

ExecAction describes a "run in container" action.

type InjectionConfig

type InjectionConfig struct {
	Name                  string               `json:"name"`
	Containers            []corev1.Container   `json:"containers"`
	Volumes               []corev1.Volume      `json:"volumes"`
	Environment           []corev1.EnvVar      `json:"env"`
	VolumeMounts          []corev1.VolumeMount `json:"volumeMounts"`
	HostAliases           []corev1.HostAlias   `json:"hostAliases"`
	InitContainers        []corev1.Container   `json:"initContainers"`
	ShareProcessNamespace bool                 `json:"shareProcessNamespace"`

	// PostStart is called after a container is created first.
	// If the handler fails, the containers will failed.
	// Key defines for the name of deployment container.
	// Value defines for the Commands for stating container.
	// +optional
	PostStart map[string]ExecAction `json:"postStart,omitempty"`

	// Selector is used to select pods that are used to inject sidecar.
	Selector *v1alpha1.SelectorSpec `json:"selector,omitempty"`
	// contains filtered or unexported fields
}

InjectionConfig is a specific instance of a injected config, for a given annotation

func LoadInjectionConfig

func LoadInjectionConfig(reader io.Reader) (*InjectionConfig, error)

LoadInjectionConfig takes an io.Reader and parses out an injectionconfig

func LoadInjectionConfigFromFilePath

func LoadInjectionConfigFromFilePath(configFile string) (*InjectionConfig, error)

LoadInjectionConfigFromFilePath returns a InjectionConfig given a yaml file on disk

func (*InjectionConfig) FullName

func (c *InjectionConfig) FullName() string

FullName returns the full identifier of this sidecar - both the Name, and the Version(), formatted like "${.Name}:${.Version}"

func (*InjectionConfig) Version

func (c *InjectionConfig) Version() string

Version returns the parsed version of this injection config. If no version is specified, "latest" is returned. The version is extracted from the request annotation, i.e. admission-webhook.pingcap.com/request: my-sidecar:1.2, where "1.2" is the version.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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