annotation

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Prefix    = "spoditor.io/"
	Separator = "_"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CollectorFunc

type CollectorFunc func(metav1.ObjectMetaAccessor) map[QualifiedName]string

func (CollectorFunc) Collect

type Handler

type Handler interface {
	Mutate(spec *corev1.PodSpec, ordinal int, cfg interface{}) error
	GetParser() Parser
}

type Parser

type Parser interface {
	Parse(annotations map[QualifiedName]string) (interface{}, error)
}

type ParserFunc

type ParserFunc func(map[QualifiedName]string) (interface{}, error)

func (ParserFunc) Parse

func (p ParserFunc) Parse(annotations map[QualifiedName]string) (interface{}, error)

type PodQualifier

type PodQualifier func(int, string) bool
var CommonPodQualifier PodQualifier = func(ordinal int, q string) bool {
	ll := log.WithValues("ordinal", ordinal, "qualifier", q)
	if q == "" {
		ll.Info("pod is always included for dynamic argumentation")
		return true
	}
	bounds := strings.Split(q, "-")
	if b, err := regexp.MatchString("^\\d+-\\d+$", q); err == nil && b {
		min, _ := strconv.Atoi(bounds[0])
		max, _ := strconv.Atoi(bounds[1])
		ll.Info("check ordinal against range", "min", min, "max", max)
		return ordinal >= min && ordinal <= max
	}
	if b, err := regexp.MatchString("^\\d+$", q); err == nil && b {
		i, _ := strconv.Atoi(bounds[0])
		ll.Info("check ordinal against single exact number", "number", i)
		return ordinal == i
	}
	if b, err := regexp.MatchString("^\\d+-$", q); err == nil && b {
		min, _ := strconv.Atoi(bounds[0])
		ll.Info("check ordinal against lower bound", "min", min)
		return ordinal >= min
	}
	if b, err := regexp.MatchString("^-\\d+$", q); err == nil && b {
		max, _ := strconv.Atoi(bounds[1])
		ll.Info("check ordinal against upper bound", "max", max)
		return ordinal <= max
	}
	return false
}

type QualifiedAnnotationCollector

type QualifiedAnnotationCollector interface {
	Collect(accessor metav1.ObjectMetaAccessor) map[QualifiedName]string
}
var Collector QualifiedAnnotationCollector = defaultCollector

type QualifiedName

type QualifiedName struct {
	Qualifier string
	Name      string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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