update

package
v0.39.3 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package update contains libraries for updating packages.

Index

Examples

Constants

This section is empty.

Variables

Functions

func MergeSubPackages added in v0.34.0

func MergeSubPackages(localRoot, updatedRoot, originalRoot string) error

MergeSubPackages merges the Kptfiles in the nested subdirectories of the root package and also sets the setter definitions in updated to match with locally set values so the the resources are correctly identified and merged

func ReplaceNonKRMFiles added in v0.18.0

func ReplaceNonKRMFiles(updatedDir, originalDir, localDir string) error

replaceNonKRMFiles replaces the non KRM files in localDir with the corresponding files in updatedDir, it also deletes non KRM files and sub dirs which are present in localDir and not in updatedDir

Types

type Command

type Command struct {
	// Path is the filepath to the local package
	Path string

	// FullPackagePath is the absolute path to the local package
	FullPackagePath string

	// Ref is the ref to update to
	Ref string

	// Repo is the repo to update to
	Repo string

	// Strategy is the update strategy to use
	Strategy StrategyType

	// DryRun if set will print the patch instead of applying it
	DryRun bool

	// Verbose if set will print verbose information about the commands being run
	Verbose bool

	// SimpleMessage if set will create simple git commit messages that omit values
	// generated for tests
	SimpleMessage bool

	// Output is where dry-run information is written
	Output io.Writer

	// Perform setters automatically based on environment
	AutoSet bool
}

Command updates the contents of a local package to a different version.

Example
package main

import (
	"path/filepath"

	"github.com/GoogleContainerTools/kpt/internal/util/update"
)

func main() {
	err := update.Command{
		Path:     filepath.Join("path", "to", "package"),
		Ref:      "v1.2",
		Strategy: update.AlphaGitPatch,
	}.Run()
	if err != nil {
		// handle error
	}
}
Output:

func (Command) Run

func (u Command) Run() error

Run runs the Command.

type DiffError

type DiffError string

DiffError is returned if the local package and upstream package contents do not match.

func (DiffError) Error

func (d DiffError) Error() string

type FastForwardUpdater

type FastForwardUpdater struct{}

Updater updates a package to a new upstream version.

If the package at pkgPath differs from the upstream ref it was fetch from, then Update will fail without making any changes.

func (FastForwardUpdater) Update

func (u FastForwardUpdater) Update(options UpdateOptions) error

type GitPatchUpdater

type GitPatchUpdater struct {
	UpdateOptions
	// contains filtered or unexported fields
}

Updater updates a package to a new upstream version.

If the package at pkgPath differs from the upstream ref it was fetch from, then Update will attempt to create a patch from the upstream source version and upstream update version.

func (GitPatchUpdater) Update

func (u GitPatchUpdater) Update(options UpdateOptions) error

type ReplaceUpdater

type ReplaceUpdater struct{}

Updater updates a package to a new upstream version.

If the package at pkgPath differs from the upstream ref it was fetch from, then Update will delete the local package. This will wipe all local changes.

func (ReplaceUpdater) Update

func (u ReplaceUpdater) Update(options UpdateOptions) error

type ResourceMergeUpdater

type ResourceMergeUpdater struct{}

ResourceMergeUpdater updates a package by fetching the original and updated source packages, and performing a 3-way merge of the Resources.

func (ResourceMergeUpdater) Update

func (u ResourceMergeUpdater) Update(options UpdateOptions) error

type StrategyType

type StrategyType string

StrategyType controls the update strategy to use when the local package has been modifed from its original remote source.

const (
	// FastForward will fail the package update if the local
	// package contents do not match the contents for the remote
	// repository at the commit it was fetched from
	FastForward StrategyType = "fast-forward"

	// ForceDeleteReplace will delete the existing local package
	// and replace the contents with a new version fetched from
	// a remote repository
	ForceDeleteReplace StrategyType = "force-delete-replace"

	// AlphaGitPatch will merge upstream changes using `git format-patch` and `git am`.
	AlphaGitPatch StrategyType = "alpha-git-patch"

	KResourceMerge StrategyType = "resource-merge"

	// Default defaults to the recommended strategy, which is FailOnChanges.
	// The recommended strategy may change as new strategies are introduced.
	Default StrategyType = ""
)

type UpdateOptions

type UpdateOptions struct {
	// KptFile is the current local package KptFile
	KptFile kptfile.KptFile

	// ToRef is the ref to update to
	ToRef string

	// ToRepo is the repo to use for updating
	ToRepo string

	// PackagePath is the relative path to the local package
	PackagePath string

	// AbsPackagePath is the absolute path to the local package
	AbsPackagePath string

	// DryRun configures AlphaGitPatch to print a patch rather
	// than apply it
	DryRun bool

	// Verbose configures updaters to write verbose output
	Verbose bool

	// SimpleMessage is used for testing so commit messages in patches
	// don't contain the names of generated paths
	SimpleMessage bool

	Output io.Writer

	// Perform setters automatically based on environment
	AutoSet bool
}

type Updater

type Updater interface {
	Update(options UpdateOptions) error
}

Updater updates a local package

Jump to

Keyboard shortcuts

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