chartutils

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package chartutils implements helper functions to manipulate helm Charts

Index

Constants

This section is empty.

Variables

View Source
var ErrNoImagesToAnnotate = errors.New("no container images to annotate found")

ErrNoImagesToAnnotate is returned when the chart can't be annotated because there are no container images

Functions

func AnnotateChart

func AnnotateChart(chartPath string, opts ...Option) error

AnnotateChart parses the values.yaml file in the chart specified by chartPath and annotates the Chart with the list of found images

func GetChartRoot

func GetChartRoot(chartPath string) (string, error)

GetChartRoot returns the chart root directory to the chart provided (which may point to its Chart.yaml file)

func GetImageLockFilePath added in v0.4.0

func GetImageLockFilePath(chartPath string) (string, error)

GetImageLockFilePath returns the path to the Images.lock file for the chart

func IsRemoteChart added in v0.4.0

func IsRemoteChart(path string) bool

IsRemoteChart returns true if the chart is a remote chart

func PullImages

func PullImages(lock *imagelock.ImagesLock, imagesDir string, opts ...Option) error

PullImages downloads the list of images specified in the provided ImagesLock

func PushImages

func PushImages(lock *imagelock.ImagesLock, imagesDir string, opts ...Option) error

PushImages push the list of images in imagesDir to the destination specified in the ImagesLock

func ReadLockFromChart added in v0.4.0

func ReadLockFromChart(chartPath string) (*imagelock.ImagesLock, error)

ReadLockFromChart reads the Images.lock file from the chart

func WithAnnotationsKey

func WithAnnotationsKey(str string) func(cfg *Configuration)

WithAnnotationsKey customizes the annotations key to use when reading/writing images to the Chart.yaml

func WithArtifactsDir

func WithArtifactsDir(dir string) func(cfg *Configuration)

WithArtifactsDir configures the ArtifactsDir

func WithAuth added in v0.4.0

func WithAuth(username, password string) func(cfg *Configuration)

WithAuth configures the Auth

func WithContext

func WithContext(ctx context.Context) func(cfg *Configuration)

WithContext provides an execution context

func WithFetchArtifacts

func WithFetchArtifacts(fetch bool) func(cfg *Configuration)

WithFetchArtifacts configures the FetchArtifacts setting

func WithInsecureMode added in v0.3.1

func WithInsecureMode(insecure bool) func(cfg *Configuration)

WithInsecureMode configures Insecure transport

func WithLog

func WithLog(l log.Logger) func(cfg *Configuration)

WithLog provides a log to use

func WithMaxRetries

func WithMaxRetries(retries int) func(cfg *Configuration)

WithMaxRetries configures the number of retries on error

func WithProgressBar

func WithProgressBar(pb log.ProgressBar) func(cfg *Configuration)

WithProgressBar provides a ProgressBar for long running operations

func WithValuesFiles added in v0.4.0

func WithValuesFiles(files ...string) func(cfg *Configuration)

WithValuesFiles customizes the values files in the chart

Types

type Auth added in v0.4.0

type Auth struct {
	Username string
	Password string
}

Auth defines the authentication settings

type Chart

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

Chart defines a helm Chart with extra functionalities

func LoadChart

func LoadChart(path string, opts ...Option) (*Chart, error)

LoadChart returns the Chart defined by path

func (*Chart) AbsFilePath

func (c *Chart) AbsFilePath(name string) string

AbsFilePath returns the absolute path to the Chart relative file name

func (*Chart) Chart

func (c *Chart) Chart() *Chart

Chart returns the Chart object (required to implement wrapping.Unwrapable)

func (*Chart) ChartDir

func (c *Chart) ChartDir() string

ChartDir returns the Chart root directory (required to implement wrapping.Unwrapable)

func (*Chart) ChartFullPath

func (c *Chart) ChartFullPath() string

ChartFullPath returns the wrapped chart ChartFullPath

func (*Chart) Dependencies

func (c *Chart) Dependencies() []*Chart

Dependencies returns the chart dependencies

func (*Chart) File

func (c *Chart) File(name string) *chart.File

File returns the chart.File for the provided name or nil if not found

func (*Chart) GetAnnotatedImages

func (c *Chart) GetAnnotatedImages() (imagelock.ImageList, error)

GetAnnotatedImages returns the chart images specified in the annotations

func (*Chart) GetImagesLock added in v0.4.0

func (c *Chart) GetImagesLock() (*imagelock.ImagesLock, error)

GetImagesLock returns the chart's ImagesLock object

func (*Chart) ImageArtifactsDir

func (c *Chart) ImageArtifactsDir() string

ImageArtifactsDir returns the imags artifacts directory

func (*Chart) ImagesDir

func (c *Chart) ImagesDir() string

ImagesDir returns the images directory inside the chart root directory

func (*Chart) LockFilePath

func (c *Chart) LockFilePath() string

LockFilePath returns the absolute path to the chart Images.lock

func (*Chart) Metadata

func (c *Chart) Metadata() *chart.Metadata

Metadata returns the metadata of the chart

func (*Chart) Name

func (c *Chart) Name() string

Name returns the name of the chart

func (*Chart) RootDir

func (c *Chart) RootDir() string

RootDir returns the Chart root directory

func (*Chart) ValuesFiles added in v0.4.0

func (c *Chart) ValuesFiles() []*chart.File

ValuesFiles returns all the values chart.File

func (*Chart) VerifyLock added in v0.4.0

func (c *Chart) VerifyLock(opts ...imagelock.Option) error

VerifyLock verifies the Images.lock file for the chart

func (*Chart) Version

func (c *Chart) Version() string

Version returns the version of the chart

type Configuration

type Configuration struct {
	AnnotationsKey string
	Log            log.Logger
	Context        context.Context
	ProgressBar    log.ProgressBar
	ArtifactsDir   string
	FetchArtifacts bool
	MaxRetries     int
	InsecureMode   bool
	Auth           Auth
	ValuesFiles    []string
}

Configuration defines configuration settings used in chartutils functions

func NewConfiguration

func NewConfiguration(opts ...Option) *Configuration

NewConfiguration returns a new Configuration

type Option

type Option func(c *Configuration)

Option defines a configuration option

type ValuesImageElement

type ValuesImageElement struct {
	Registry   string
	Repository string
	Digest     string
	Tag        string
	// contains filtered or unexported fields
}

ValuesImageElement defines a docker image element definition found when parsing values.yaml

func (*ValuesImageElement) Name

func (v *ValuesImageElement) Name() string

Name returns the image name

func (*ValuesImageElement) Relocate

func (v *ValuesImageElement) Relocate(prefix string) error

Relocate modifies the ValuesImageElement Registry and Repository based on the provided prefix

func (*ValuesImageElement) ToMap

func (v *ValuesImageElement) ToMap() map[string]string

ToMap returns the map[string]string representation of the ValuesImageElement

func (*ValuesImageElement) URL

func (v *ValuesImageElement) URL() string

URL returns the full URL to the image

func (*ValuesImageElement) YamlLocationPath

func (v *ValuesImageElement) YamlLocationPath() string

YamlLocationPath returns the jsonpath-like location of the element in values.yaml

func (*ValuesImageElement) YamlReplaceMap

func (v *ValuesImageElement) YamlReplaceMap() map[string]string

YamlReplaceMap returns the yaml paths to the different image definition elements and the current value

type ValuesImageElementList

type ValuesImageElementList []*ValuesImageElement

ValuesImageElementList defines a list of ValuesImageElement

func FindImageElementsInValuesFile

func FindImageElementsInValuesFile(chartPath string) (ValuesImageElementList, error)

FindImageElementsInValuesFile looks for a list of ValuesImageElement in the values.yaml for the specified chartPath

func FindImageElementsInValuesMap

func FindImageElementsInValuesMap(data map[string]interface{}) (ValuesImageElementList, error)

FindImageElementsInValuesMap parses the provided data looking for ValuesImageElement and returns the list

func (ValuesImageElementList) Len

func (imgs ValuesImageElementList) Len() int

func (ValuesImageElementList) Less

func (imgs ValuesImageElementList) Less(i, j int) bool

func (ValuesImageElementList) Swap

func (imgs ValuesImageElementList) Swap(i, j int)

func (ValuesImageElementList) ToAnnotation

func (imgs ValuesImageElementList) ToAnnotation() ([]byte, error)

ToAnnotation returns the annotation text representation of the ValuesImageElementList

Jump to

Keyboard shortcuts

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