mover

package
v0.3.49 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2021 License: BSD-2-Clause Imports: 21 Imported by: 1

Documentation

Overview

Example

Package level documentation

// i.e ./mariadb-7.5.relocated.tgz
destinationPath := "%s-%s.relocated.tgz"

// Initialize the Mover action
chartMover, err := NewChartMover(
	&ChartMoveRequest{
		Source: Source{
			// The Helm Chart can be provided in either tarball or directory form
			Chart: ChartSpec{Local: &LocalChart{Path: "./helm_chart.tgz"}},
			// path to file containing rules such as // {{.image.registry}}:{{.image.tag}}
			ImageHintsFile: "./image-hints.yaml",
		},
		Target: Target{
			Chart: ChartSpec{Local: &LocalChart{Path: destinationPath}},
			// Where to push and how to rewrite the found images
			// i.e docker.io/bitnami/mariadb => myregistry.com/myteam/mariadb
			Rules: RewriteRules{
				Registry:         "myregistry.com",
				RepositoryPrefix: "/myteam",
			},
		},
	},
)
if err != nil {
	fmt.Println(err)
	return
}

// Perform the push, rewrite and repackage of the Helm Chart
err = chartMover.Move()
if err != nil {
	fmt.Println(err)
	return
}
Output:

Index

Examples

Constants

View Source
const (
	// EmbeddedHintsFilename to be present in the Helm Chart rootpath
	EmbeddedHintsFilename = ".relok8s-images.yaml"
	// DefaultRetries indicates the default number of retries for pull/push operations
	DefaultRetries = 3

	// IntermediateBundleHintsFilename to be present in the intermediate archive root path
	IntermediateBundleHintsFilename = "hints.yaml"
)

Variables

View Source
var (
	// ErrImageHintsMissing indicates that neither the hints file was provided nor found in the Helm chart
	ErrImageHintsMissing = errors.New("no image hints provided")

	// ErrOCIRewritesMissing indicates that no rewrite rules have been provided
	ErrOCIRewritesMissing = errors.New("at least one rewrite rule is required")
)
View Source
var (
	// ErrNotIntermediateBundle when a verified path does not have expected intermediate bundle contents
	ErrNotIntermediateBundle = errors.New("not an intermediate chart bundle")
)

Functions

func IsIntermediateBundle added in v0.3.49

func IsIntermediateBundle(bundlePath string) bool

IsIntermediateBundle returns tue only if VerifyIntermediateBundle finds no errors

Types

type ChartLoadingError added in v0.3.45

type ChartLoadingError struct {
	Path  string
	Inner error
}

func (*ChartLoadingError) Error added in v0.3.45

func (e *ChartLoadingError) Error() string

func (*ChartLoadingError) Unwrap added in v0.3.45

func (e *ChartLoadingError) Unwrap() error

type ChartMetadata

type ChartMetadata struct {
	Name    string
	Version string
}

ChartMetadata exposes metadata about the Helm Chart to be relocated

type ChartMoveRequest added in v0.3.45

type ChartMoveRequest struct {
	Source Source
	Target Target
}

ChartMoveRequest defines a chart move

type ChartMover

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

ChartMover represents a Helm Chart moving relocation. It's initialization must be done view NewChartMover

func NewChartMover

func NewChartMover(req *ChartMoveRequest, opts ...Option) (*ChartMover, error)

NewChartMover creates a ChartMover to relocate a chart following the given imagePatters and rules.

func (*ChartMover) Move

func (cm *ChartMover) Move() error
Move performs the relocation.

A regular move executes the Chart relocation which includes - Push all the images to their new locations - Rewrite the Helm Chart and its subcharts - Repackage the Helm chart as toChartFilename

A save to an offline tarball bundle will: - Drop all images to disk, with the original chart (unpacked) and hints file - Package all in a single compressed tarball

func (*ChartMover) Print

func (cm *ChartMover) Print()

Print shows the changes expected to be performed during relocation, including the new location of the Helm Chart Images as well as the expected rewrites in the Helm Chart.

func (*ChartMover) WithRetries

func (cm *ChartMover) WithRetries(retries uint) *ChartMover

WithRetries sets how many times to retry push operations

type ChartSpec added in v0.3.45

type ChartSpec struct {
	Local              *LocalChart
	IntermediateBundle *IntermediateBundle
}

ChartSpec of possible chart inputs or outputs

type ContainerRepository added in v0.3.45

type ContainerRepository struct {
	Server             string
	Username, Password string
}

ContainerRepository defines a private repo name and credentials

func (ContainerRepository) Authorization added in v0.3.45

func (repo ContainerRepository) Authorization() (*authn.AuthConfig, error)

Authorization implements an authn.Authenticator

See https://pkg.go.dev/github.com/google/go-containerregistry/pkg/authn#Authenticator

Returns an authn.AuthConfig with a user / password pair to be used for authentication

func (ContainerRepository) Resolve added in v0.3.45

func (repo ContainerRepository) Resolve(resource authn.Resource) (authn.Authenticator, error)

Resolve implements an authn.KeyChain

See https://pkg.go.dev/github.com/google/go-containerregistry/pkg/authn#Keychain

Returns a custom credentials authn.Authenticator if the given resource RegistryStr() matches the Repository, otherwise it falls back to the default KeyChain which may include local docker credentials.

type Containers added in v0.3.45

type Containers struct {
	ContainerRepository
}

Containers is the section for private repository definition

type IntermediateBundle added in v0.3.49

type IntermediateBundle LocalChart

IntermediateBundle is a self contained version of the original chart with the hints file and container images

type LocalChart added in v0.3.45

type LocalChart struct {
	Path string
}

LocalChart is a reference to a local chart

type Logger

type Logger interface {
	Printf(format string, i ...interface{})
	Println(i ...interface{})
}

Logger represents an interface used to output moving information

var DefaultLogger Logger = defaultLogger{}

DefaultLogger to stdout

var NoLogger Logger = noLogger{}

DefaultNoLogger swallows all logs

type Option

type Option func(*ChartMover)

Option adds optional functionality to NewChartMover constructor

func WithLogger

func WithLogger(l Logger) Option

WithLogger sets a custom Logger interface

func WithRetries

func WithRetries(retries uint) Option

WithRetries defines how many times to retry the push operation

type RewriteRules

type RewriteRules struct {
	// Registry overrides the registry part of the image FQDN, i.e myregistry.io
	Registry string
	// RepositoryPrefix will override the image path by being prepended before the image name
	RepositoryPrefix string
	// Push the image even if there is already an image with a different digest
	ForcePush bool
}

RewriteRules indicate What kind of target registry overrides we want to apply to the found images

func (*RewriteRules) Validate added in v0.3.45

func (r *RewriteRules) Validate() error

type Source added in v0.3.45

type Source struct {
	Chart          ChartSpec
	ImageHintsFile string
	Containers     Containers
}

Source of the chart move

type Target added in v0.3.45

type Target struct {
	Chart      ChartSpec
	Rules      RewriteRules
	Containers Containers
}

Target of the chart move

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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