engine

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadImageReference = errors.New("bad image reference")
)
View Source
var (
	ErrWrongRuleType = errors.New("wrong rule type")
)

Functions

func NewImageInspector

func NewImageInspector() *imageInspector

func ParseImageReference

func ParseImageReference(imageRef string) (string, string)

Types

type Engine

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

func NewEngine

func NewEngine(repo *repo.Repo, inspector ImageInspector, rules []Rule) (*Engine, error)

func NewEngineFromFile

func NewEngineFromFile(repo *repo.Repo, inspector ImageInspector, file string) (*Engine, error)

func (Engine) GetRules

func (e Engine) GetRules() []Rule

func (Engine) Mutate

func (e Engine) Mutate(_ context.Context, imageRef string) (string, []string)

func (Engine) Validate

func (e Engine) Validate(ctx context.Context, imageRef string) (bool, string)

type ImageInspector

type ImageInspector interface {
	GetDigest(context.Context, string) (string, error)
}

type MutationRule

type MutationRule struct {
	Type           MutationType   `yaml:"type"`
	Registry       string         `yaml:"registry,omitempty"`
	RegistryRegexp *regexp.Regexp `yaml:"-"`
	NewRegistry    string         `yaml:"newRegisty,omitempty"`
}

func (MutationRule) Mutate

func (r MutationRule) Mutate(domain string) (string, bool)

type MutationType

type MutationType string
const (
	MutationTypeDefaultRegistry MutationType = "DefaultRegistry"
	MutationTypeRewriteRegistry MutationType = "RewriteRegistry"
)

type Rule

type Rule struct {
	Name           string         `yaml:"name"`
	MutationRule   MutationRule   `yaml:"mutate,omitempty"`
	ValidationRule ValidationRule `yaml:"validate,omitempty"`
}

type Rules

type Rules struct {
	Rules []Rule `yaml:"rules"`
}

type ValidateType

type ValidateType string
const (
	ValidateTypeLatest     ValidateType = "Latest"
	ValidateTypeSemVer     ValidateType = "SemVer"
	ValidateTypeLock       ValidateType = "Lock"
	ValidateTypeRollingTag ValidateType = "RollingTag"
)

type ValidationRule

type ValidationRule struct {
	Type            ValidateType        `yaml:"type"`
	ImageName       string              `yaml:"imageName,omitempty"`
	ImageNameRegexp *regexp.Regexp      `yaml:"-"`
	ImageTag        string              `yaml:"imageTag,omitempty"`
	ImageTagSemVer  *semver.Constraints `yaml:"-"`
	Allow           bool                `yaml:"allow"`
	RollingTagAfter time.Time           `yaml:"after,omitempty"`
}

func (ValidationRule) Match

func (r ValidationRule) Match(ctx context.Context, repo *repo.Repo, inspector ImageInspector, name, tag string) bool

Jump to

Keyboard shortcuts

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