kptfileutil

package
v1.0.0-beta.67 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DeprecatedKptfileVersions = []schema.GroupVersionKind{
	kptfilev1.KptFileGVK().GroupKind().WithVersion("v1alpha1"),
	kptfilev1.KptFileGVK().GroupKind().WithVersion("v1alpha2"),
}
View Source
var SupportedKptfileVersions = []schema.GroupVersionKind{
	kptfilev1.KptFileGVK(),
}

Functions

func DecodeKptfile

func DecodeKptfile(in io.Reader) (*kptfilev1.KptFile, error)

func DefaultKptfile

func DefaultKptfile(name string) *kptfilev1.KptFile

DefaultKptfile returns a new minimal Kptfile.

func Equal

func Equal(kf1, kf2 *kptfilev1.KptFile) (bool, error)

func FromKptGVK

FromKptGVK converts a kpt API schema GroupVersionKind to an apimachinery GroupVersionKind.

func MergeKptfiles

func MergeKptfiles(localKf, updatedKf, originalKf *kptfilev1.KptFile) error

MergeKptfiles merges the Kptfiles from various sources and updates localKf with output please refer to https://github.com/kptdev/kpt/blob/main/docs/design-docs/03-pipeline-merge.md for related design

func ReadKptfile

func ReadKptfile(fs filesys.FileSystem, p string) (*kptfilev1.KptFile, error)

ReadKptfile reads the KptFile in the given pkg. TODO(droot): This method exists for current version of Kptfile. Need to reconcile with the team how we want to handle multiple versions of Kptfile in code. One option is to follow Kubernetes approach to have an internal version of Kptfile that all the code uses. In that case, we will have to implement pieces for IO/Conversion with right interfaces.

func ToKptGVK

ToKptGVK converts an apimachinery GroupVersionKind to the kpt API schema GroupVersionKind.

func UpdateKptfile

func UpdateKptfile(localPath, updatedPath, originPath string, updateUpstream bool) error

UpdateKptfile updates the Kptfile in the package specified by localPath with values from the packages specified in updatedPath using the package specified by originPath as the common ancestor. If updateUpstream is true, the values from the upstream and upstreamLock sections will also be copied into local.

func UpdateKptfileWithoutOrigin

func UpdateKptfileWithoutOrigin(localPath, updatedPath string, updateUpstream bool) error

UpdateKptfileWithoutOrigin updates the Kptfile in the package specified by localPath with values from the package specified by updatedPath using a 3-way merge strategy, but where origin does not have any values. If updateUpstream is true, the values from the upstream and upstreamLock sections will also be copied into local.

func UpdateUpstreamLockFromGit

func UpdateUpstreamLockFromGit(path string, spec *gitutil.RepoSpec) error

UpdateUpstreamLockFromGit updates the upstreamLock of the package specified by path by using the values from spec. It will also populate the commit field in upstreamLock using the latest commit of the git repo given by spec.

func ValidateInventory

func ValidateInventory(inv *kptfilev1.Inventory) (bool, error)

ValidateInventory returns true and a nil error if the passed inventory is valid; otherwiste, false and the reason the inventory is not valid is returned. A valid inventory must have a non-empty namespace, name, and id.

func WriteFile

func WriteFile(dir string, k any) error

func WriteKptfileToFS

func WriteKptfileToFS(fs filesys.FileSystem, dir string, k any) error

WriteKptfileToFS writes a Kptfile to the given filesystem at the specified directory.

Types

type DeprecatedKptfileError

type DeprecatedKptfileError struct {
	Version string
}

DeprecatedKptfileError is an implementation of the error interface that is returned whenever kpt encounters a Kptfile using the legacy format.

func (*DeprecatedKptfileError) Error

func (e *DeprecatedKptfileError) Error() string

type KptfileError

type KptfileError struct {
	Path kptfilev1.UniquePath
	Err  error
}

KptfileError records errors regarding reading or parsing of a Kptfile.

func (*KptfileError) Error

func (k *KptfileError) Error() string

func (*KptfileError) Unwrap

func (k *KptfileError) Unwrap() error

type UnknownKptfileResourceError

type UnknownKptfileResourceError struct {
	GVK schema.GroupVersionKind
}

func (*UnknownKptfileResourceError) Error

Jump to

Keyboard shortcuts

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