Documentation ¶
Overview ¶
Package defines Kptfile schema. Version: v1 swagger:meta
Index ¶
- Constants
- Variables
- func AreKRM(nodes []*yaml.RNode) error
- func GetValidatedFnConfigFromPath(fsys filesys.FileSystem, pkgPath types.UniquePath, configPath string) (*yaml.RNode, error)
- func IsKRM(n *yaml.RNode) error
- func UpdateStrategiesAsStrings() []string
- func ValidateFunctionImageURL(name string) error
- type Function
- type Git
- type GitLock
- type Inventory
- type KptFile
- type OriginType
- type PackageInfo
- type Pipeline
- type Selector
- type Subpackage
- type UpdateStrategyType
- type Upstream
- type UpstreamLock
- type ValidateError
Constants ¶
const ( KptFileName = "Kptfile" KptFileKind = "Kptfile" KptFileGroup = "kpt.dev" KptFileVersion = "v1" KptFileAPIVersion = KptFileGroup + "/" + KptFileVersion )
Variables ¶
var TypeMeta = yaml.ResourceMeta{ TypeMeta: yaml.TypeMeta{ APIVersion: KptFileAPIVersion, Kind: KptFileKind, }, }
TypeMeta is the TypeMeta for KptFile instances.
var UpdateStrategies = []UpdateStrategyType{ ResourceMerge, FastForward, ForceDeleteReplace, }
UpdateStrategies is a slice with all the supported update strategies.
Functions ¶
func GetValidatedFnConfigFromPath ¶
func GetValidatedFnConfigFromPath(fsys filesys.FileSystem, pkgPath types.UniquePath, configPath string) (*yaml.RNode, error)
GetValidatedFnConfigFromPath validates the functionConfig at the path specified by the package path (pkgPath) and configPath, returning the functionConfig as an RNode if the validation is successful.
func IsKRM ¶
IsKRM validates if given resource is a valid KRM resource by ensuring that resource has a valid apiVersion, kind and metadata.name field. It excludes kustomization resource from KRM check.
func UpdateStrategiesAsStrings ¶
func UpdateStrategiesAsStrings() []string
UpdateStrategiesAsStrings returns a list of update strategies as strings.
func ValidateFunctionImageURL ¶
ValidateFunctionImageURL validates the function name. According to Docker implementation https://github.com/docker/distribution/blob/master/reference/reference.go. A valid name definition is:
name := [domain '/'] path-component ['/' path-component]* domain := domain-component ['.' domain-component]* [':' port-number] domain-component := /([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])/ port-number := /[0-9]+/ path-component := alpha-numeric [separator alpha-numeric]* alpha-numeric := /[a-z0-9]+/ separator := /[_.]|__|[-]*/
Types ¶
type Function ¶
type Function struct { // `Image` specifies the function container image. // It can either be fully qualified, e.g.: // // image: gcr.io/kpt-fn/set-labels // // Optionally, kpt can be configured to use a image // registry host-path that will be used to resolve the image path in case // the image path is missing (Defaults to gcr.io/kpt-fn). // e.g. The following resolves to gcr.io/kpt-fn/set-labels: // // image: set-labels Image string `yaml:"image,omitempty" json:"image,omitempty"` // Exec specifies the function binary executable. // The executable can be fully qualified or it must exists in the $PATH e.g: // // exec: set-namespace // exec: /usr/local/bin/my-custom-fn Exec string `yaml:"exec,omitempty" json:"exec,omitempty"` // `ConfigPath` specifies a slash-delimited relative path to a file in the current directory // containing a KRM resource used as the function config. This resource is // excluded when resolving 'sources', and as a result cannot be operated on // by the pipeline. ConfigPath string `yaml:"configPath,omitempty" json:"configPath,omitempty"` // `ConfigMap` is a convenient way to specify a function config of kind ConfigMap. ConfigMap map[string]string `yaml:"configMap,omitempty" json:"configMap,omitempty"` // `Name` is used to uniquely identify the function declaration // this is primarily used for merging function declaration with upstream counterparts Name string `yaml:"name,omitempty" json:"name,omitempty"` // `Selectors` are used to specify resources on which the function should be executed // if not specified, all resources are selected Selectors []Selector `yaml:"selectors,omitempty" json:"selectors,omitempty"` // `Exclude` are used to specify resources on which the function should NOT be executed. // If not specified, all resources selected by `Selectors` are selected. Exclusions []Selector `yaml:"exclude,omitempty" json:"exclude,omitempty"` }
Function specifies a KRM function.
type Git ¶
type Git struct { // Repo is the git repository the package. // e.g. 'https://github.com/kubernetes/examples.git' Repo string `yaml:"repo,omitempty" json:"repo,omitempty"` // Directory is the sub directory of the git repository. // e.g. 'staging/cockroachdb' Directory string `yaml:"directory,omitempty" json:"directory,omitempty"` // Ref can be a Git branch, tag, or a commit SHA-1. Ref string `yaml:"ref,omitempty" json:"ref,omitempty"` }
Git is the user-specified locator for a package on Git.
type GitLock ¶
type GitLock struct { // Repo is the git repository that was fetched. // e.g. 'https://github.com/kubernetes/examples.git' Repo string `yaml:"repo,omitempty" json:"repo,omitempty"` // Directory is the sub directory of the git repository that was fetched. // e.g. 'staging/cockroachdb' Directory string `yaml:"directory,omitempty" json:"directory,omitempty"` // Ref can be a Git branch, tag, or a commit SHA-1 that was fetched. // e.g. 'master' Ref string `yaml:"ref,omitempty" json:"ref,omitempty"` // Commit is the SHA-1 for the last fetch of the package. // This is set by kpt for bookkeeping purposes. Commit string `yaml:"commit,omitempty" json:"commit,omitempty"` }
GitLock is the resolved locator for a package on Git.
type Inventory ¶
type Inventory struct { // Namespace for the inventory resource. Namespace string `yaml:"namespace,omitempty" json:"namespace,omitempty"` // Name of the inventory resource. Name string `yaml:"name,omitempty" json:"name,omitempty"` // Unique label to identify inventory resource in cluster. InventoryID string `yaml:"inventoryID,omitempty" json:"inventoryID,omitempty"` Labels map[string]string `yaml:"labels,omitempty" json:"labels,omitempty"` Annotations map[string]string `yaml:"annotations,omitempty" json:"annotations,omitempty"` }
Inventory encapsulates the parameters for the inventory resource applied to a cluster. All of the the parameters are required if any are set.
type KptFile ¶
type KptFile struct { yaml.ResourceMeta `yaml:",inline" json:",inline"` Upstream *Upstream `yaml:"upstream,omitempty" json:"upstream,omitempty"` // UpstreamLock is a resolved locator for the last fetch of the package. UpstreamLock *UpstreamLock `yaml:"upstreamLock,omitempty" json:"upstreamLock,omitempty"` // Info contains metadata such as license, documentation, etc. Info *PackageInfo `yaml:"info,omitempty" json:"info,omitempty"` // Pipeline declares the pipeline of functions. Pipeline *Pipeline `yaml:"pipeline,omitempty" json:"pipeline,omitempty"` // Inventory contains parameters for the inventory object used in apply. Inventory *Inventory `yaml:"inventory,omitempty" json:"inventory,omitempty"` }
KptFile contains information about a package managed with kpt. swagger:model kptfile
func (*KptFile) Validate ¶
func (kf *KptFile) Validate(fsys filesys.FileSystem, pkgPath types.UniquePath) error
type OriginType ¶
type OriginType string
OriginType defines the type of origin for a package.
const ( // GitOrigin specifies a package as having been cloned from a git repository. GitOrigin OriginType = "git" )
type PackageInfo ¶
type PackageInfo struct { // Site is the URL for package web page. Site string `yaml:"site,omitempty" json:"site,omitempty"` // Email is the list of emails for the package authors. Emails []string `yaml:"emails,omitempty" json:"emails,omitempty"` // SPDX license identifier (e.g. "Apache-2.0"). See: https://spdx.org/licenses/ License string `yaml:"license,omitempty" json:"license,omitempty"` // Relative slash-delimited path to the license file (e.g. LICENSE.txt) LicenseFile string `yaml:"licenseFile,omitempty" json:"licenseFile,omitempty"` // Description contains a short description of the package. Description string `yaml:"description,omitempty" json:"description,omitempty"` // Keywords is a list of keywords for this package. Keywords []string `yaml:"keywords,omitempty" json:"keywords,omitempty"` // Man is the path to documentation about the package Man string `yaml:"man,omitempty" json:"man,omitempty"` }
PackageInfo contains optional information about the package such as license, documentation, etc. These fields are not consumed by any functionality in kpt and are simply passed through. Note that like any other KRM resource, humans and automation can also use `metadata.labels` and `metadata.annotations` as the extension mechanism.
type Pipeline ¶
type Pipeline struct { // Mutators defines a list of of KRM functions that mutate resources. Mutators []Function `yaml:"mutators,omitempty" json:"mutators,omitempty"` // Validators defines a list of KRM functions that validate resources. // Validators are not permitted to mutate resources. Validators []Function `yaml:"validators,omitempty" json:"validators,omitempty"` }
Pipeline declares a pipeline of functions used to mutate or validate resources.
type Selector ¶
type Selector struct { // APIVersion of the target resources APIVersion string `yaml:"apiVersion,omitempty" json:"apiVersion,omitempty"` // Kind of the target resources Kind string `yaml:"kind,omitempty" json:"kind,omitempty"` // Name of the target resources Name string `yaml:"name,omitempty" json:"name,omitempty"` // Namespace of the target resources Namespace string `yaml:"namespace,omitempty" json:"namespace,omitempty"` // Labels on the target resources Labels map[string]string `yaml:"labels,omitempty" json:"labels,omitempty"` // Annotations on the target resources Annotations map[string]string `yaml:"annotations,omitempty" json:"annotations,omitempty"` }
Selector specifies the selection criteria please update IsEmpty method if more properties are added
type Subpackage ¶
type Subpackage struct { // Name of the immediate subdirectory relative to this Kptfile where the suppackage // either exists (local subpackages) or will be fetched to (remote subpckages). // This must be unique across all subpckages of a package. LocalDir string `yaml:"localDir,omitempty" json:"localDir,omitempty"` // Upstream is a reference to where the subpackage should be fetched from. // Whether a subpackage is local or remote is determined by whether Upstream is specified. Upstream *Upstream `yaml:"upstream,omitempty" json:"upstream,omitempty"` }
Subpackages declares a local or remote subpackage.
type UpdateStrategyType ¶
type UpdateStrategyType string
UpdateStrategyType defines the strategy for updating a package from upstream.
const ( // ResourceMerge performs a structural schema-aware comparison and // merges the changes into the local package. ResourceMerge UpdateStrategyType = "resource-merge" // FastForward fails without updating if the local package was modified // since it was fetched. FastForward UpdateStrategyType = "fast-forward" // ForceDeleteReplace wipes all local changes to the package. ForceDeleteReplace UpdateStrategyType = "force-delete-replace" )
func ToUpdateStrategy ¶
func ToUpdateStrategy(strategy string) (UpdateStrategyType, error)
ToUpdateStrategy takes a string representing an update strategy and will return the strategy as an UpdateStrategyType. If the provided string does not match any known update strategies, an error will be returned.
type Upstream ¶
type Upstream struct { // Type is the type of origin. Type OriginType `yaml:"type,omitempty" json:"type,omitempty"` // Git is the locator for a package stored on Git. Git *Git `yaml:"git,omitempty" json:"git,omitempty"` // UpdateStrategy declares how a package will be updated from upstream. UpdateStrategy UpdateStrategyType `yaml:"updateStrategy,omitempty" json:"updateStrategy,omitempty"` }
Upstream is a user-specified upstream locator for a package.
type UpstreamLock ¶
type UpstreamLock struct { // Type is the type of origin. Type OriginType `yaml:"type,omitempty" json:"type,omitempty"` // Git is the resolved locator for a package on Git. Git *GitLock `yaml:"git,omitempty" json:"git,omitempty"` }
UpstreamLock is a resolved locator for the last fetch of the package.
type ValidateError ¶
type ValidateError struct { // Field is the field that causes error Field string // Value is the value of invalid field Value string // Reason is the reason for the error Reason string }
ValidateError is the error returned when validation fails.
func (*ValidateError) Error ¶
func (e *ValidateError) Error() string