release

package
v0.37.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultDataFilters = []DataFilter{
		IgnoreHookTestEvents,
	}
)

Functions

func Digest

func Digest(algo digest.Algorithm, rel Observation) digest.Digest

Digest calculates the digest of the given Observation by JSON encoding it into a hash.Hash of the given digest.Algorithm. The algorithm is expected to have been confirmed to be available by the caller, not doing this may result in panics.

func GetTestHooks

func GetTestHooks(rls *helmrelease.Release) map[string]*helmrelease.Hook

GetTestHooks returns the list of test hooks for the given release, indexed by hook name.

func IgnoreHookTestEvents

func IgnoreHookTestEvents(rel *Observation)

IgnoreHookTestEvents ignores test event hooks. For example, to exclude it while generating a digest for the object. To prevent manual test triggers from a user to interfere with the checksum.

func IsHookForEvent

func IsHookForEvent(hook *helmrelease.Hook, event helmrelease.HookEvent) bool

IsHookForEvent returns if the given hook fires on the provided event.

func ObservedToSnapshot

func ObservedToSnapshot(rls Observation) *v2.Snapshot

ObservedToSnapshot returns a v2beta2.Snapshot constructed from the Observation data. Calculating the (config) digest using the digest.Canonical algorithm.

func ShortenName

func ShortenName(name string) string

ShortenName returns a short release name in the format of '<shortened releaseName>-<hash>' for the given name if it exceeds 53 characters in length.

The shortening is done by hashing the given release name with SHA256 and taking the first 12 characters of the resulting hash. The hash is then appended to the release name shortened to 40 characters divided by a hyphen separator.

For example: 'some-front-appended-namespace-release-wi-1234567890ab' where '1234567890ab' are the first 12 characters of the SHA hash.

func TestHooksFromRelease

func TestHooksFromRelease(rls *helmrelease.Release) map[string]*v2.TestHookStatus

TestHooksFromRelease returns the list of v2beta2.TestHookStatus for the given release, indexed by name.

Types

type DataFilter

type DataFilter func(rel *Observation)

DataFilter allows for filtering data from the returned Observation while making an observation.

type Observation

type Observation struct {
	// Name of the release.
	Name string `json:"name"`
	// Version of the release, at times also called revision.
	Version int `json:"version"`
	// Info provides information about the release.
	Info helmrelease.Info `json:"info"`
	// ChartMetadata contains the current Chartfile data of the release.
	ChartMetadata chart.Metadata `json:"chartMetadata"`
	// Config is the set of extra Values added to the chart.
	// These values override the default values inside the chart.
	Config map[string]interface{} `json:"config"`
	// Manifest is the string representation of the rendered template.
	Manifest string `json:"manifest"`
	// Hooks are all the hooks declared for this release, and the current
	// state they are in.
	Hooks []helmrelease.Hook `json:"hooks"`
	// Namespace is the Kubernetes namespace of the release.
	Namespace string `json:"namespace"`
}

Observation is a copy of a Helm release object, as observed to be written to the storage by a storage.Observer. The object is detached from the Helm storage object, and mutations to it do not change the underlying release object.

func ObserveRelease

func ObserveRelease(rel *helmrelease.Release, filter ...DataFilter) Observation

ObserveRelease deep copies the values from the provided release.Release into a new Observation while omitting all chart data except metadata. If no filters are provided, it defaults to DefaultDataFilters. To not use any filters, pass an explicit empty slice.

func (Observation) Encode

func (o Observation) Encode(w io.Writer) error

Encode JSON encodes the Observation and writes it into the given writer.

func (Observation) Targets

func (o Observation) Targets(name, namespace string, version int) bool

Targets returns if the release matches the given name, namespace and version. If the version is 0, it matches any version.

Jump to

Keyboard shortcuts

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