Documentation ¶
Overview ¶
Package update contains libraries for updating packages.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var Strategies = []string{ string(FastForward), string(ForceDeleteReplace), string(AlphaGitPatch), string(KResourceMerge), }
Functions ¶
func ReplaceNonKRMFiles ¶ added in v0.18.0
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 // 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 }
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:
type DiffError ¶
type DiffError string
DiffError is returned if the local package and upstream package contents do not match.
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 // 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 }
type Updater ¶
type Updater interface {
Update(options UpdateOptions) error
}
Updater updates a local package