mover

package
Version: v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2021 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Overview

Example

Package level documentation

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

// Next we just need to call Move providing the destination path of the rewritten Helm Chart
// i.e chartMover.Move("./helm-chart-relocated.tgz")
// Additionally, some extra metadata about the provided Helm Chart can be retrieved.
// Useful to generate custom destination filepaths
chartMetadata, err := chartMover.ChartMetadata()
if err != nil {
	fmt.Println(err)
	return
}

// i.e ./mariadb-7.5.relocated.tgz
destinationPath := fmt.Sprintf("./%s-%s.relocated.tgz", chartMetadata.Name, chartMetadata.Version)
// Perform the push, rewrite and repackage of the Helm Chart
chartMover.Move(destinationPath)
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
)

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")
)

Functions

This section is empty.

Types

type ChartMetadata

type ChartMetadata struct {
	Name    string
	Version string
}

ChartMetadata exposes metadata about the Helm Chart to be relocated

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(chartPath string, imageHintsFile string, rules *RewriteRules, opts ...Option) (*ChartMover, error)

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

func (*ChartMover) ChartMetadata

func (cm *ChartMover) ChartMetadata() (*ChartMetadata, error)

ChartMetadata returns information from the Helm Chart ready to be relocated

func (*ChartMover) Move

func (cm *ChartMover) Move(toChartFilename string) error

Move executes the Chart relocation which includes

1 - Push all the images to their new locations

2 - Rewrite the Helm Chart and its subcharts

3 - Repackage the Helm chart as toChartFilename

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 Logger

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

Logger represents an interface used to output moving information

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
}

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

Source Files

Directories

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL