krm

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2023 License: 0BSD Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PackageFile             = "kobold.yaml"
	CommentPrefix           = "# kobold: "
	DefaultImagerefTemplate = "{{ .Image }}:{{ .Tag }}@{{ .Digest }}"
)
View Source
const (
	TypeExact  = "exact"
	TypeSemver = "semver"
	TypeRegex  = "regex"
)
View Source
const (
	KeyType = "type"
	KeyTag  = "tag"
)
View Source
const (
	KubeFieldContainerImage = "image"
	KubeFieldContainerName  = "name"
)
View Source
const (
	ComposeFieldServices = "services"
	ComposeFieldImage    = "image"
)
View Source
const (
	KoFieldDefaultBaseImage   = "defaultBaseImage"
	KoFieldBaseImageOverrides = "baseImageOverrides"
)

Variables

This section is empty.

Functions

func MatchTag

func MatchTag(tag string, opts Options) (bool, error)

check if the provided tag matches per options. Exact, semver or regex

func NewRenderer

func NewRenderer(opts ...RendererOption) renderer

create a new renderer with the given options

Types

type Change

type Change struct {
	Source            string
	Parent            string
	OldImageRef       string
	NewImageRef       string
	OptionsExpression string
}

type ImageNodeHandler

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

The ImageNodeHandler is used to encapsulate the logic of handling update nodes. It holds a template to avoid creating it on each run new

func NewImageNodeHandler

func NewImageNodeHandler(t string, nameOptions ...name.Option) *ImageNodeHandler

FIXME: this panics on invalid template. There should be a better way since this function will not only run at program start

func (*ImageNodeHandler) AddNameOptions

func (h *ImageNodeHandler) AddNameOptions(opts ...name.Option)

func (*ImageNodeHandler) HandleImageNode

func (h *ImageNodeHandler) HandleImageNode(imgNode *yaml.MapNode, events []events.PushData) (bool, Change, error)

Check if the given map node is eligible for an image update and update the image of so. The check is based on an inline comment in the form of:

kobold: tag: [tag|semver-constraint|regex-pattern]; type: [exact|semver|regex]

If the image has been updated, change data is returned.

type ImageNodeHandlerFunc

type ImageNodeHandlerFunc func(source, parent string, imgNode *yaml.MapNode) error

the image node handler func is responsible for handling the actual image nodes found be the resolver. It may mutate the image ref or do nothing

type NopRenderer

type NopRenderer struct{}

func (NopRenderer) Render

func (NopRenderer) Render(ctx context.Context, dir string, events []events.PushData) ([]Change, error)

type Options

type Options struct {
	Type string
	Tag  string
}

func ParseOpts

func ParseOpts(expr string) (Options, error)

type Renderer

type Renderer interface {
	Render(ctx context.Context, dir string, events []events.PushData) ([]Change, error)
}

type RendererOption

type RendererOption func(r *renderer)

func WithDefaultRegistry

func WithDefaultRegistry(registry string) RendererOption

the default registry will be used for any image that has no fully qualified domain name

func WithImagerefTemplate

func WithImagerefTemplate(t string) RendererOption

the imageref template is used to format the new image ref when updating image nodes.

func WithScopes

func WithScopes(scopes []string) RendererOption

scope this renderer to the list of glob pattern

func WithSelector

func WithSelector(selector *ResolverSelector) RendererOption

the selector determines which resolver to use for a given file name

func WithWriter

func WithWriter(w kio.Writer) RendererOption

type Resolver

type Resolver func(node *yaml.RNode, source string, handleImage ImageNodeHandlerFunc) error

the resolver is responsible for finding one or more image node in a given yaml document

func NewCustomResolver

func NewCustomResolver(name string, paths []string) Resolver

type ResolverSelector

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

the resolver selector should return the correct resolver based on the file for example for a docker-compose.yaml, the compose resolver should be returned

func NewSelector

func NewSelector(resolvers []config.ResolverSpec, associations []config.FileTypeSpec) *ResolverSelector

func (ResolverSelector) Select

func (s ResolverSelector) Select(ctx context.Context, source string) Resolver

Jump to

Keyboard shortcuts

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