Documentation ¶
Overview ¶
Package xpkg contains functionality pertaining to Crossplane packages.
Index ¶
- Constants
- func Build(ctx context.Context, b parser.Backend, p parser.Parser, l parser.Linter) (v1.Image, error)
- func BuildMetaScheme() (*runtime.Scheme, error)
- func BuildObjectScheme() (*runtime.Scheme, error)
- func BuildPath(path, name, ext string) string
- func FindXpkgInDir(fs afero.Fs, root string) (string, error)
- func FriendlyID(name, hash string) string
- func GzipReadCloser(rc io.ReadCloser) (io.ReadCloser, error)
- func IsCRD(o runtime.Object) error
- func IsComposition(o runtime.Object) error
- func IsConfiguration(o runtime.Object) error
- func IsFunction(o runtime.Object) error
- func IsMutatingWebhookConfiguration(o runtime.Object) error
- func IsProvider(o runtime.Object) error
- func IsValidatingWebhookConfiguration(o runtime.Object) error
- func IsXRD(o runtime.Object) error
- func JoinedReadCloser(r io.Reader, c io.Closer) io.ReadCloser
- func NewConfigurationLinter() parser.Linter
- func NewFunctionLinter() parser.Linter
- func NewProviderLinter() parser.Linter
- func OneMeta(pkg *parser.Package) error
- func PackageCrossplaneCompatible(v version.Operations) parser.ObjectLinterFn
- func PackageValidSemver(o runtime.Object) error
- func ParseNameFromMeta(fs afero.Fs, path string) (string, error)
- func ParsePackageSourceFromReference(ref name.Reference) string
- func TeeReadCloser(r io.ReadCloser, w io.WriteCloser) io.ReadCloser
- func ToDNSLabel(s string) string
- func TryConvert(obj runtime.Object, candidates ...conversion.Hub) (runtime.Object, bool)
- func TryConvertToPkg(obj runtime.Object, candidates ...conversion.Hub) (pkgmetav1.Pkg, bool)
- type Fetcher
- type FetcherOpt
- type FsPackageCache
- type K8sFetcher
- func (i *K8sFetcher) Fetch(ctx context.Context, ref name.Reference, secrets ...string) (v1.Image, error)
- func (i *K8sFetcher) Head(ctx context.Context, ref name.Reference, secrets ...string) (*v1.Descriptor, error)
- func (i *K8sFetcher) Tags(ctx context.Context, ref name.Reference, secrets ...string) ([]string, error)
- type NopCache
- type NopFetcher
- type PackageCache
Constants ¶
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 )
Variables ¶
This section is empty.
Functions ¶
func Build ¶
func Build(ctx context.Context, b parser.Backend, p parser.Parser, l parser.Linter) (v1.Image, error)
Build compiles a Crossplane package from an on-disk package.
func BuildMetaScheme ¶
BuildMetaScheme builds the default scheme used for identifying metadata in a Crossplane package.
func BuildObjectScheme ¶
BuildObjectScheme builds the default scheme used for identifying objects in a Crossplane package.
func FindXpkgInDir ¶
FindXpkgInDir finds compiled Crossplane packages in a directory.
func FriendlyID ¶
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 IsComposition ¶
IsComposition checks that an object is a Composition.
func IsConfiguration ¶
IsConfiguration checks that an object is a Configuration meta type.
func IsFunction ¶ added in v1.13.0
IsFunction checks that an object is a Function meta type.
func IsMutatingWebhookConfiguration ¶ added in v1.5.3
IsMutatingWebhookConfiguration checks that an object is a MutatingWebhookConfiguration.
func IsProvider ¶
IsProvider checks that an object is a Provider meta type.
func IsValidatingWebhookConfiguration ¶ added in v1.5.3
IsValidatingWebhookConfiguration checks that an object is a ValidatingWebhookConfiguration.
func JoinedReadCloser ¶ added in v1.7.0
JoinedReadCloser constructs a new joinedReadCloser from the passed reader and closer.
func NewConfigurationLinter ¶
NewConfigurationLinter is a convenience function for creating a package linter for configurations.
func NewFunctionLinter ¶ added in v1.13.0
NewFunctionLinter is a convenience function for creating a package linter for functions.
func NewProviderLinter ¶
NewProviderLinter is a convenience function for creating a package linter for providers.
func PackageCrossplaneCompatible ¶
func PackageCrossplaneCompatible(v version.Operations) parser.ObjectLinterFn
PackageCrossplaneCompatible checks that the current Crossplane version is compatible with the package constraints.
func PackageValidSemver ¶
PackageValidSemver checks that the package uses valid semver ranges.
func ParseNameFromMeta ¶
ParseNameFromMeta extracts the package name from its meta file.
func ParsePackageSourceFromReference ¶ added in v1.4.0
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 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 ¶
ToDNSLabel converts the string to a valid DNS label.
func TryConvert ¶
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 ¶
TryConvertToPkg converts the supplied object to a pkgmeta.Pkg, if possible.
Types ¶
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.
type NopCache ¶
type NopCache struct{}
NopCache is a cache implementation that does not store anything and always returns an error on get.
func (*NopCache) Get ¶
func (c *NopCache) Get(string) (io.ReadCloser, error)
Get retrieves content from the NopCache.
type NopFetcher ¶
type NopFetcher struct{}
NopFetcher always returns an empty image and never returns 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.