xpkg

package
v1.17.1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Overview

Package xpkg contains functionality pertaining to Crossplane packages.

Index

Constants

View Source
const (
	// MetaFile is the name of a Crossplane package metadata file.
	MetaFile string = "crossplane.yaml"

	// StreamFile is the name of the file in a Crossplane package image that
	// contains its YAML stream.
	StreamFile string = "package.yaml"

	// StreamFileMode determines the permissions on the stream file.
	StreamFileMode os.FileMode = 0o644

	// XpkgExtension is the extension for compiled Crossplane packages.
	XpkgExtension string = ".xpkg"

	// XpkgMatchPattern is the match pattern for identifying compiled Crossplane packages.
	XpkgMatchPattern string = "*" + XpkgExtension

	// XpkgExamplesFile is the name of the file in a Crossplane package image
	// that contains the examples YAML stream.
	XpkgExamplesFile string = ".up/examples.yaml"

	// AnnotationKey is the key value for xpkg annotations.
	AnnotationKey string = "io.crossplane.xpkg"

	// PackageAnnotation is the annotation value used for the package.yaml
	// layer.
	PackageAnnotation string = "base"

	// ExamplesAnnotation is the annotation value used for the examples.yaml
	// layer.
	// TODO(lsviben) Consider changing this to "examples".
	ExamplesAnnotation string = "upbound"

	// DefaultRegistry is the registry name that will be used when no registry
	// is provided.
	DefaultRegistry string = "xpkg.upbound.io"
)

Variables

This section is empty.

Functions

func AnnotateLayers added in v1.14.0

func AnnotateLayers(i v1.Image) (v1.Image, error)

AnnotateLayers propagates labels from the supplied image's config file to annotations on its layers.

func BuildMetaScheme

func BuildMetaScheme() (*runtime.Scheme, error)

BuildMetaScheme builds the default scheme used for identifying metadata in a Crossplane package.

func BuildObjectScheme

func BuildObjectScheme() (*runtime.Scheme, error)

BuildObjectScheme builds the default scheme used for identifying objects in a Crossplane package.

func BuildPath

func BuildPath(path, name, ext string) string

BuildPath builds a path with the provided extension.

func FindXpkgInDir

func FindXpkgInDir(fs afero.Fs, root string) (string, error)

FindXpkgInDir finds compiled Crossplane packages in a directory.

func FriendlyID

func FriendlyID(name, hash string) string

FriendlyID builds a valid DNS label string made up of the name of a package and its image digest.

func GzipReadCloser added in v1.7.0

func GzipReadCloser(rc io.ReadCloser) (io.ReadCloser, error)

GzipReadCloser constructs a new gzipReadCloser from the passed file.

func IsCRD

func IsCRD(o runtime.Object) error

IsCRD checks that an object is a CustomResourceDefinition.

func IsComposition

func IsComposition(o runtime.Object) error

IsComposition checks that an object is a Composition.

func IsConfiguration

func IsConfiguration(o runtime.Object) error

IsConfiguration checks that an object is a Configuration meta type.

func IsFunction added in v1.13.0

func IsFunction(o runtime.Object) error

IsFunction checks that an object is a Function meta type.

func IsMutatingWebhookConfiguration added in v1.5.3

func IsMutatingWebhookConfiguration(o runtime.Object) error

IsMutatingWebhookConfiguration checks that an object is a MutatingWebhookConfiguration.

func IsProvider

func IsProvider(o runtime.Object) error

IsProvider checks that an object is a Provider meta type.

func IsValidatingWebhookConfiguration added in v1.5.3

func IsValidatingWebhookConfiguration(o runtime.Object) error

IsValidatingWebhookConfiguration checks that an object is a ValidatingWebhookConfiguration.

func IsXRD

func IsXRD(o runtime.Object) error

IsXRD checks that an object is a CompositeResourceDefinition.

func JoinedReadCloser added in v1.7.0

func JoinedReadCloser(r io.Reader, c io.Closer) io.ReadCloser

JoinedReadCloser constructs a new joinedReadCloser from the passed reader and closer.

func Label added in v1.14.0

func Label(annotation string) string

Label constructs a specially formated label using the annotationKey.

func Layer added in v1.14.0

func Layer(r io.Reader, fileName, annotation string, fileSize int64, mode os.FileMode, cfg *v1.Config) (v1.Layer, error)

Layer creates a v1.Layer that represents the layer contents for the xpkg and adds a corresponding label to the image Config for the layer.

func NewConfigurationLinter

func NewConfigurationLinter() parser.Linter

NewConfigurationLinter is a convenience function for creating a package linter for configurations.

func NewFunctionLinter added in v1.13.0

func NewFunctionLinter() parser.Linter

NewFunctionLinter is a convenience function for creating a package linter for functions.

func NewProviderLinter

func NewProviderLinter() parser.Linter

NewProviderLinter is a convenience function for creating a package linter for providers.

func OneMeta

func OneMeta(pkg parser.Lintable) error

OneMeta checks that there is only one meta object in the package.

func PackageCrossplaneCompatible

func PackageCrossplaneCompatible(v version.Operations) parser.ObjectLinterFn

PackageCrossplaneCompatible checks that the current Crossplane version is compatible with the package constraints.

func PackageValidSemver

func PackageValidSemver(o runtime.Object) error

PackageValidSemver checks that the package uses valid semver ranges.

func ParseNameFromMeta

func ParseNameFromMeta(fs afero.Fs, path string) (string, error)

ParseNameFromMeta extracts the package name from its meta file.

func ParsePackageSourceFromReference added in v1.4.0

func ParsePackageSourceFromReference(ref name.Reference) string

ParsePackageSourceFromReference parses a package source from an OCI image reference. A source is defined as an OCI image reference with the identifier (tag or digest) stripped and no other changes to the original reference source. This is necessary because go-containerregistry will convert docker.io to index.docker.io for backwards compatibility before pulling an image. We do not want to do that in cases where we are not pulling an image because it breaks comparison with dependencies defined in a Configuration manifest.

func SkipContains added in v1.14.0

func SkipContains(pattern string) parser.FilterFn

SkipContains supplies a FilterFn that skips paths that contain the give pattern.

func TeeReadCloser added in v1.7.0

func TeeReadCloser(r io.ReadCloser, w io.WriteCloser) io.ReadCloser

TeeReadCloser constructs a teeReadCloser from the passed reader and writer.

func ToDNSLabel

func ToDNSLabel(s string) string

ToDNSLabel converts the string to a valid DNS label.

func TryConvert

func TryConvert(obj runtime.Object, candidates ...conversion.Hub) (runtime.Object, bool)

TryConvert converts the supplied object to the first supplied candidate that does not return an error. Returns the converted object and true when conversion succeeds, or the original object and false if it does not.

func TryConvertToPkg

func TryConvertToPkg(obj runtime.Object, candidates ...conversion.Hub) (pkgmetav1.Pkg, bool)

TryConvertToPkg converts the supplied object to a pkgmeta.Pkg, if possible.

Types

type BuildOpt added in v1.14.0

type BuildOpt func(*buildOpts)

A BuildOpt modifies how a package is built.

func WithBase added in v1.14.0

func WithBase(img v1.Image) BuildOpt

WithBase sets the base image of the package.

type Builder added in v1.14.0

type Builder struct {
	// contains filtered or unexported fields
}

Builder defines an xpkg Builder.

func New added in v1.14.0

func New(packageSource, exampleSource parser.Backend, packageParser parser.Parser, examplesParser *examples.Parser) *Builder

New returns a new Builder.

func (*Builder) Build added in v1.14.0

func (b *Builder) Build(ctx context.Context, opts ...BuildOpt) (v1.Image, runtime.Object, error)

Build compiles a Crossplane package from an on-disk package.

type Fetcher

type Fetcher interface {
	Fetch(ctx context.Context, ref name.Reference, secrets ...string) (v1.Image, error)
	Head(ctx context.Context, ref name.Reference, secrets ...string) (*v1.Descriptor, error)
	Tags(ctx context.Context, ref name.Reference, secrets ...string) ([]string, error)
}

Fetcher fetches package images.

type FetcherOpt added in v1.6.0

type FetcherOpt func(k *K8sFetcher) error

FetcherOpt can be used to add optional parameters to NewK8sFetcher.

func WithCustomCA added in v1.6.0

func WithCustomCA(rootCAs *x509.CertPool) FetcherOpt

WithCustomCA is a FetcherOpt that can be used to add a custom CA bundle to a K8sFetcher.

func WithNamespace added in v1.10.0

func WithNamespace(ns string) FetcherOpt

WithNamespace is a FetcherOpt that sets the Namespace for fetching package pull secrets.

func WithServiceAccount added in v1.10.0

func WithServiceAccount(sa string) FetcherOpt

WithServiceAccount is a FetcherOpt that sets the ServiceAccount name for fetching package pull secrets.

func WithUserAgent added in v1.11.0

func WithUserAgent(userAgent string) FetcherOpt

WithUserAgent is a FetcherOpt that can be used to set the user agent on all HTTP requests.

type FsPackageCache added in v1.7.0

type FsPackageCache struct {
	// contains filtered or unexported fields
}

FsPackageCache stores and retrieves package content in a filesystem-backed cache in a thread-safe manner.

func NewFsPackageCache added in v1.7.0

func NewFsPackageCache(dir string, fs afero.Fs) *FsPackageCache

NewFsPackageCache creates a new FsPackageCache.

func (*FsPackageCache) Delete added in v1.7.0

func (c *FsPackageCache) Delete(id string) error

Delete removes package contents from the cache.

func (*FsPackageCache) Get added in v1.7.0

func (c *FsPackageCache) Get(id string) (io.ReadCloser, error)

Get retrieves package contents from the cache.

func (*FsPackageCache) Has added in v1.7.0

func (c *FsPackageCache) Has(id string) bool

Has indicates whether an item with the given id is in the cache.

func (*FsPackageCache) Store added in v1.7.0

func (c *FsPackageCache) Store(id string, content io.ReadCloser) error

Store saves the package contents to the cache.

type K8sFetcher

type K8sFetcher struct {
	// contains filtered or unexported fields
}

K8sFetcher uses kubernetes credentials to fetch package images.

func NewK8sFetcher

func NewK8sFetcher(client kubernetes.Interface, opts ...FetcherOpt) (*K8sFetcher, error)

NewK8sFetcher creates a new K8sFetcher.

func (*K8sFetcher) Fetch

func (i *K8sFetcher) Fetch(ctx context.Context, ref name.Reference, secrets ...string) (v1.Image, error)

Fetch fetches a package image.

func (*K8sFetcher) Head

func (i *K8sFetcher) Head(ctx context.Context, ref name.Reference, secrets ...string) (*v1.Descriptor, error)

Head fetches a package descriptor.

func (*K8sFetcher) Tags

func (i *K8sFetcher) Tags(ctx context.Context, ref name.Reference, secrets ...string) ([]string, error)

Tags fetches a package's tags.

type NopCache

type NopCache struct{}

NopCache is a cache implementation that does not store anything and always returns an error on get.

func NewNopCache

func NewNopCache() *NopCache

NewNopCache creates a new NopCache.

func (*NopCache) Delete

func (c *NopCache) Delete(string) error

Delete removes content from the NopCache.

func (*NopCache) Get

func (c *NopCache) Get(string) (io.ReadCloser, error)

Get retrieves content from the NopCache.

func (*NopCache) Has added in v1.7.0

func (c *NopCache) Has(string) bool

Has indicates whether content is in the NopCache.

func (*NopCache) Store

func (c *NopCache) Store(string, io.ReadCloser) error

Store saves content to the NopCache.

type NopFetcher

type NopFetcher struct{}

NopFetcher always returns an empty image and never returns error.

func NewNopFetcher

func NewNopFetcher() *NopFetcher

NewNopFetcher creates a new NopFetcher.

func (*NopFetcher) Fetch

func (n *NopFetcher) Fetch(_ context.Context, _ name.Reference, _ ...string) (v1.Image, error)

Fetch fetches an empty image and does not return error.

func (*NopFetcher) Head

func (n *NopFetcher) Head(_ context.Context, _ name.Reference, _ ...string) (*v1.Descriptor, error)

Head returns a nil descriptor and does not return error.

func (*NopFetcher) Tags

func (n *NopFetcher) Tags(_ context.Context, _ name.Reference, _ ...string) ([]string, error)

Tags returns a nil slice and does not return error.

type PackageCache added in v1.7.0

type PackageCache interface {
	Has(id string) bool
	Get(id string) (io.ReadCloser, error)
	Store(id string, content io.ReadCloser) error
	Delete(id string) error
}

A PackageCache caches package content.

Directories

Path Synopsis
Package fake contains mock Crossplane package implementations.
Package fake contains mock Crossplane package implementations.
parser
examples
Package examples contains utilities for parsing examples.
Package examples contains utilities for parsing examples.
yaml
Package yaml contains utilities for reading yaml packages.
Package yaml contains utilities for reading yaml packages.
Package upbound implements authentication for xpkg.upbound.io.
Package upbound implements authentication for xpkg.upbound.io.
config
Package config manages the Crossplane CLI configuration.
Package config manages the Crossplane CLI configuration.
credhelper
Package credhelper provides a docker credential helper for the Upbound marketplace.
Package credhelper provides a docker credential helper for the Upbound marketplace.

Jump to

Keyboard shortcuts

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