Help us shape the future of Go! Take the 2026 Go Developer Survey

update

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// K8sCliExtensionKey is preserved from setters2
	K8sCliExtensionKey = "x-k8s-cli"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {
	OldValue string
	NewValue string
	Setter   string
}

Change contains the setter that resulted in a Change, the old and the new value after the Change.

type ObjectChanges

type ObjectChanges map[ObjectIdentifier][]Change

ObjectChanges contains all the changes made to objects.

type ObjectIdentifier

type ObjectIdentifier struct {
	yaml.ResourceIdentifier
}

ObjectIdentifier holds the identifying data for a particular object. This won't always have a name (e.g., a kustomization.yaml).

type Result

type Result struct {
	FileChanges map[string]ObjectChanges
	// contains filtered or unexported fields
}

Result contains the file changes made during the update. It contains details about the exact changes made to the files and the objects in them. It has a nested structure file->objects->changes.

func UpdateWithSetters

func UpdateWithSetters(tracelog logr.Logger, inpath, outpath string, policies []reflectorv1.ImagePolicy) (Result, error)

UpdateWithSetters takes all YAML files from `inpath`, updates any that contain an "in scope" image policy marker, and writes files it updated (and only those files) back to `outpath`. It also returns the result of the changes it made as Result.

func (*Result) AddChange

func (r *Result) AddChange(file string, objectID ObjectIdentifier, changes ...Change)

AddChange adds changes to Result for a given file, object and changes associated with it.

func (Result) Changes

func (r Result) Changes() []Change

Changes returns all the changes that were made in at least one update, ordered by file name, then object, then the order within the object.

func (Result) Objects

func (r Result) Objects() ObjectChanges

Objects returns ObjectChanges, regardless of which file they appear in. Changes of an object found in several files are ordered by file name.

func (Result) Summary added in v1.3.0

func (r Result) Summary() string

Summary returns a description of the changes, one line per distinct change, sorted and joined by newlines, without a trailing newline. A change made by a full-reference setter is described as "<old> -> <new>". A change made by a tag, name or digest setter is prefixed with the policy's image name and the field, e.g. "<image> tag <old> -> <new>"; the digest label also carries the policy's tag. Values are printed as written to the file. A result without changes gives an empty string.

type ScreeningLocalReader

type ScreeningLocalReader struct {
	Token string
	Path  string

	Trace logr.Logger

	// This records the relative path of each file that passed
	// screening (i.e., contained the token), but couldn't be parsed.
	ProblemFiles []string
}

ScreeningLocalReader is a kio.Reader that includes only files that are pertinent to automation. In practice this means looking for a particular token in each file, and ignoring those files without the token. This avoids most problematic cases -- e.g., templates in a Helm chart, which won't parse as YAML -- and cheaply filters for only those files that need processing.

func (*ScreeningLocalReader) Read

func (r *ScreeningLocalReader) Read() ([]*yaml.RNode, error)

Read scans the .Path recursively for files that contain .Token, and parses any that do. It applies the filename annotation used by [`kio.LocalPackageWriter`](https://godoc.org/sigs.k8s.io/kustomize/kyaml/kio#LocalPackageWriter) so that the same will write files back to their original location. The implementation follows that of [LocalPackageReader.Read](https://godoc.org/sigs.k8s.io/kustomize/kyaml/kio#LocalPackageReader.Read), adapting lightly (mainly to leave features out).

type SetAllCallback

type SetAllCallback struct {
	SettersSchema *spec.Schema
	Callback      func(setter, oldValue, newValue string)
	Trace         logr.Logger
}

func (*SetAllCallback) Filter

func (s *SetAllCallback) Filter(object *yaml.RNode) (*yaml.RNode, error)

func (*SetAllCallback) TraceOrDiscard

func (s *SetAllCallback) TraceOrDiscard() logr.Logger

Jump to

Keyboard shortcuts

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