xpkg

package
v0.34.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package xpkg contains utilities for building and linting UXP packages.

Index

Constants

View Source
const (
	// JSONStreamFile is the name of the file in local Crossplane package
	// that contains the JSON stream representation of the Crossplane package.
	JSONStreamFile string = "package.ndjson"

	// 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.
	ExamplesAnnotation string = "upbound"
)
View Source
const (
	ProviderConfigKind = "ProviderConfig"
)

Variables

This section is empty.

Functions

func BuildPath

func BuildPath(path, name string) string

BuildPath builds a path for a compiled Crossplane package. If file name has extension it will be replaced.

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 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 v0.25.0

func IsFunction(o runtime.Object) error

IsFunction checks that an object is a Function meta type.

func IsMutatingWebhookConfiguration added in v0.25.0

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 v0.25.0

func IsValidatingWebhookConfiguration(o runtime.Object) error

IsValidatingWebhookConfiguration checks that an object is a MutatingWebhookConfiguration.

func IsXRD

func IsXRD(o runtime.Object) error

IsXRD checks that an object is a CompositeResourceDefinition.

func Label added in v0.25.0

func Label(annotation string) string

Label constructs a specially formated label using the annotationKey.

func Layer added in v0.25.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 represetns the layer contents for the xpkg and adds a corresponding label to the image Config for the layer.

func NewConfigurationLinter

func NewConfigurationLinter() linter.Linter

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

func NewFunctionLinter added in v0.25.0

func NewFunctionLinter() linter.Linter

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

func NewProviderLinter

func NewProviderLinter() linter.Linter

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

func OneMeta

func OneMeta(pkg linter.Package) error

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

func PackageValidSemver

func PackageValidSemver(o runtime.Object) error

PackageValidSemver checks that the package uses valid semver ranges.

func ReplaceExt added in v0.25.0

func ReplaceExt(path, ext string) string

ReplaceExt replaces the file extension of the given path.

func SkipContains added in v0.25.0

func SkipContains(pattern string) parser.FilterFn

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

func ToDNSLabel

func ToDNSLabel(s string) string

ToDNSLabel converts the string to a valid DNS label.

func ValidDep added in v0.25.0

func ValidDep(pkg string) (bool, error)

ValidDep --

Types

type AuthExtension added in v0.25.0

type AuthExtension struct {
	Version      string `yaml:"version"`
	Discriminant string `yaml:"discriminant"`
	Sources      []struct {
		Name                string `yaml:"name"`
		Docs                string `yaml:"docs"`
		AdditionalResources []struct {
			Type string `yaml:"type"`
			Ref  string `yaml:"ref"`
		} `yaml:"additionalResources"`
		ShowFields []string `yaml:"showFields"`
	} `yaml:"sources"`
}

type BuildOpt added in v0.25.0

type BuildOpt func(*buildOpts)

A BuildOpt modifies how a package is built.

func WithController added in v0.25.0

func WithController(img v1.Image) BuildOpt

WithController sets the controller image that should serve as the base for the package.

type Builder added in v0.25.0

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

Builder defines an xpkg Builder.

func New added in v0.25.0

func New(pkg, ab, ex parser.Backend, pp parser.Parser, ep *examples.Parser) *Builder

New returns a new Builder.

func (*Builder) Build added in v0.25.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 Image added in v0.25.0

type Image struct {
	Meta  ImageMeta `json:"meta"`
	Image v1.Image
}

Image wraps a v1.Image and extends it with ImageMeta.

type ImageMeta added in v0.25.0

type ImageMeta struct {
	Repo     string `json:"repo"`
	Registry string `json:"registry"`
	Version  string `json:"version"`
	Digest   string `json:"digest"`
}

ImageMeta contains metadata information about the Package Image.

type InitContext added in v0.25.0

type InitContext struct {
	// Name of the package
	Name string
	// Controller Image (only applicable to Provider packages)
	CtrlImage string
	// Crossplane version this package is compatible with
	XPVersion string
	// Dependencies for this package
	DependsOn []metav1.Dependency
}

InitContext defines the details we're interested in for populating a meta file.

type Option added in v0.25.0

type Option func(*Writer)

Option modifies the Writer.

func WithFileBody added in v0.25.0

func WithFileBody(body []byte) Option

WithFileBody specifies the file body that is used to populate the new meta file.

func WithFs added in v0.25.0

func WithFs(fs afero.Fs) Option

WithFs specifies the afero.Fs that is being used.

func WithRoot added in v0.25.0

func WithRoot(root string) Option

WithRoot specifies the root for the new package.

type Package added in v0.25.0

type Package string

Package represents the types of packages we support.

const (
	// Configuration represents a configuration package.
	Configuration Package = "configuration"
	// Provider represents a provider package.
	Provider Package = "provider"
)

func (Package) IsValid added in v0.25.0

func (p Package) IsValid() bool

IsValid is a helper function for determining if the Package is a valid type of package.

type Writer added in v0.25.0

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

Writer defines a writer that is used for creating package meta files.

func NewFileWriter added in v0.25.0

func NewFileWriter(opts ...Option) *Writer

NewFileWriter returns a new Writer.

func (*Writer) NewMetaFile added in v0.25.0

func (w *Writer) NewMetaFile() error

NewMetaFile creates a new meta file per the given options.

Directories

Path Synopsis
dep
parser

Jump to

Keyboard shortcuts

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