Documentation ¶
Overview ¶
Package pkg defines the concept of a kpt package.
Index ¶
- Constants
- Variables
- func CheckKptfileVersion(content []byte) error
- func DecodeKptfile(in io.Reader) (*kptfilev1.KptFile, error)
- func FunctionConfigFilePaths(rootPath types.UniquePath, recursive bool) (sets.String, error)
- func FunctionConfigFilterFunc(pkgPath types.UniquePath, includeMetaResources bool) (kio.LocalPackageSkipFileFunc, error)
- func GetPkgPathAnnotation(rn *yaml.RNode) (string, error)
- func IsPackageDir(path string) (bool, error)
- func IsPackageUnfetched(path string) (bool, error)
- func ReadKptfile(p string) (*kptfilev1.KptFile, error)
- func RemovePkgPathAnnotation(rn *yaml.RNode) error
- func SetPkgPathAnnotation(rn *yaml.RNode, pkgPath types.UniquePath) error
- func Subpackages(rootPath string, matcher SubpackageMatcher, recursive bool) ([]string, error)
- type DeprecatedKptfileError
- type KptfileError
- type Pkg
- func (p *Pkg) DirectSubpackages() ([]*Pkg, error)
- func (p *Pkg) Kptfile() (*kptfilev1.KptFile, error)
- func (p *Pkg) LocalResources(includeMetaResources bool) (resources []*yaml.RNode, err error)
- func (p *Pkg) Pipeline() (*kptfilev1.Pipeline, error)
- func (p *Pkg) RelativePathTo(ancestorPkg *Pkg) (string, error)
- func (p *Pkg) String() string
- func (p *Pkg) ValidatePipeline() error
- type RemoteKptfileError
- type SubpackageMatcher
- type UnknownKptfileResourceError
Constants ¶
const CurDir = "."
const ParentDir = ".."
Variables ¶
var DeprecatedKptfileVersions = []string{
"v1alpha1",
"v1alpha2",
}
var SupportedKptfileVersions = []string{ kptfilev1.KptFileVersion, }
Functions ¶
func CheckKptfileVersion ¶
CheckKptfileVersion verifies the apiVersion and kind of the resource within the Kptfile. If the legacy version is found, the DeprecatedKptfileError is returned. If the currently supported apiVersion and kind is found, no error is returned.
func FunctionConfigFilePaths ¶
FunctionConfigFilePaths returns a set of config file paths that used by package pipeline. rootPath is the path to the package. recursive decides will config file paths in subpackages will be returned. Returned paths are all relative to rootPath.
func FunctionConfigFilterFunc ¶
func FunctionConfigFilterFunc(pkgPath types.UniquePath, includeMetaResources bool) (kio.LocalPackageSkipFileFunc, error)
FunctionConfigFilterFunc returns a kio.LocalPackageSkipFileFunc filter which will be invoked by kio.LocalPackageReader when it reads the package. The filter will return true if the file should be skipped during reading. Skipped files will not be included in all steps following.
func GetPkgPathAnnotation ¶
GetPkgPathAnnotation returns the package path annotation on a given resource.
func IsPackageDir ¶
IsPackageDir checks if there exists a Kptfile on the provided path, i.e. whether the provided path is the root of a package.
func IsPackageUnfetched ¶
IsPackageUnfetched returns true if a package has Upstream information, but no UpstreamLock. For local packages that doesn't have Upstream information, it will always return false. If a Kptfile is not found on the provided path, an error will be returned.
func ReadKptfile ¶
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 RemovePkgPathAnnotation ¶
RemovePkgPathAnnotation removes the package path on a given resource.
func SetPkgPathAnnotation ¶
func SetPkgPathAnnotation(rn *yaml.RNode, pkgPath types.UniquePath) error
SetPkgPathAnnotation sets package path on a given resource.
func Subpackages ¶
func Subpackages(rootPath string, matcher SubpackageMatcher, recursive bool) ([]string, error)
Subpackages returns a slice of paths to any subpackages of the provided path. The matcher parameter decides if all types of subpackages should be considered, and the recursive parameter determines if only direct subpackages are considered. All returned paths will be relative to the provided rootPath. The top level package is not considered a subpackage. If the provided path doesn't exist, an empty slice will be returned. Symlinks are ignored. TODO: For now this accepts the path as a string type. See if we can leverage the package type here.
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 types.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 Pkg ¶
type Pkg struct { // UniquePath represents absolute unique OS-defined path to the package directory on the filesystem. UniquePath types.UniquePath // DisplayPath represents Slash-separated path to the package directory on the filesystem relative // to parent directory of root package on which the command is invoked. // root package is defined as the package on which the command is invoked by user // This is not guaranteed to be unique (e.g. in presence of symlinks) and should only // be used for display purposes and is subject to change. DisplayPath types.DisplayPath // contains filtered or unexported fields }
Pkg represents a kpt package with a one-to-one mapping to a directory on the local filesystem.
func New ¶
New returns a pkg given an absolute or relative OS-defined path. Use ReadKptfile or ReadPipeline on the return value to read meta resources from filesystem.
func (*Pkg) DirectSubpackages ¶
DirectSubpackages returns subpackages of a pkg. It will return all direct subpackages, i.e. subpackages that aren't nested inside other subpackages under the current package. It will return packages that are nested inside directories of the current package. TODO: This does not support symlinks, so we need to figure out how we should support that with kpt.
func (*Pkg) Kptfile ¶
Kptfile returns the Kptfile meta resource by lazy loading it from the filesytem. A nil value represents an implicit package.
func (*Pkg) LocalResources ¶
LocalResources returns resources that belong to this package excluding the subpackage resources.
func (*Pkg) Pipeline ¶
Pipeline returns the Pipeline section of the pkg's Kptfile. if pipeline is not specified in a Kptfile, it returns Zero value of the pipeline.
func (*Pkg) RelativePathTo ¶
RelativePathTo returns current package's path relative to a given package. It returns an error if relative path doesn't exist. In a nested package chain, one can use this method to get the relative path of a subpackage relative to an ancestor package up the chain. Example: rel, _ := subpkg.RelativePathTo(rootPkg) The returned relative path is compatible with the target operating system-defined file paths.
func (*Pkg) ValidatePipeline ¶
Validates the package pipeline.
type RemoteKptfileError ¶
RemoteKptfileError records errors regarding reading or parsing of a Kptfile in a remote repo.
func (*RemoteKptfileError) Error ¶
func (e *RemoteKptfileError) Error() string
func (*RemoteKptfileError) Unwrap ¶
func (e *RemoteKptfileError) Unwrap() error
type SubpackageMatcher ¶
type SubpackageMatcher string
SubpackageMatcher is type for specifying the types of subpackages which should be included when listing them.
const ( // All means all types of subpackages will be returned. All SubpackageMatcher = "ALL" // Local means only local subpackages will be returned. Local SubpackageMatcher = "LOCAL" // remote means only remote subpackages will be returned. Remote SubpackageMatcher = "REMOTE" // None means that no subpackages will be returned. None SubpackageMatcher = "NONE" )
type UnknownKptfileResourceError ¶
type UnknownKptfileResourceError struct {
GVK schema.GroupVersionKind
}
func (*UnknownKptfileResourceError) Error ¶
func (e *UnknownKptfileResourceError) Error() string