bundle

package
v0.23.2 Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: MIT Imports: 12 Imported by: 38

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CNABSpecVersion string = "cnab-core-1.2.0"

CNABSpecVersion represents the CNAB Spec version of the Bundle that this library implements This value is prefixed with e.g. `cnab-core-` so isn't itself valid semver.

Functions

func AppliesTo added in v0.17.0

func AppliesTo(s Scoped, action string) bool

AppliesTo returns a boolean value specifying whether or not the scoped item applies to the provided action.

func GetDefaultSchemaVersion

func GetDefaultSchemaVersion() schema.Version

GetDefaultSchemaVersion returns the default semver CNAB schema version of the Bundle that this library implements

func ValuesOrDefaults

func ValuesOrDefaults(vals map[string]interface{}, b *Bundle, action string) (map[string]interface{}, error)

ValuesOrDefaults returns parameter values or the default parameter values. An error is returned when the parameter value does not pass the schema validation or a required parameter is missing, assuming the parameter applies to the provided action.

Types

type Action

type Action struct {
	// Modifies indicates whether this action modifies the release.
	//
	// If it is possible that an action modify a release, this must be set to true.
	Modifies bool `json:"modifies,omitempty" yaml:"modifies,omitempty"`
	// Stateless indicates that the action is purely informational, that credentials are not required, and that the runtime should not keep track of its invocation
	Stateless bool `json:"stateless,omitempty" yaml:"stateless,omitempty"`
	// Description describes the action as a user-readable string
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
}

Action describes a custom (non-core) action.

type BaseImage

type BaseImage struct {
	ImageType string            `json:"imageType" yaml:"imageType"`
	Image     string            `json:"image" yaml:"image"`
	Digest    string            `json:"contentDigest,omitempty" yaml:"contentDigest,omitempty"`
	Size      uint64            `json:"size,omitempty" yaml:"size,omitempty"`
	Labels    map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
	MediaType string            `json:"mediaType,omitempty" yaml:"mediaType,omitempty"`
}

BaseImage contains fields shared across image types

func (*BaseImage) DeepCopy

func (i *BaseImage) DeepCopy() *BaseImage

type Bundle

type Bundle struct {
	SchemaVersion      schema.Version         `json:"schemaVersion" yaml:"schemaVersion"`
	Name               string                 `json:"name" yaml:"name"`
	Version            string                 `json:"version" yaml:"version"`
	Description        string                 `json:"description" yaml:"description"`
	Keywords           []string               `json:"keywords,omitempty" yaml:"keywords,omitempty"`
	Maintainers        []Maintainer           `json:"maintainers,omitempty" yaml:"maintainers,omitempty"`
	InvocationImages   []InvocationImage      `json:"invocationImages" yaml:"invocationImages"`
	Images             map[string]Image       `json:"images,omitempty" yaml:"images,omitempty"`
	Actions            map[string]Action      `json:"actions,omitempty" yaml:"actions,omitempty"`
	Parameters         map[string]Parameter   `json:"parameters,omitempty" yaml:"parameters,omitempty"`
	Credentials        map[string]Credential  `json:"credentials,omitempty" yaml:"credentials,omitempty"`
	Outputs            map[string]Output      `json:"outputs,omitempty" yaml:"outputs,omitempty"`
	Definitions        definition.Definitions `json:"definitions,omitempty" yaml:"definitions,omitempty"`
	License            string                 `json:"license,omitempty" yaml:"license,omitempty"`
	RequiredExtensions []string               `json:"requiredExtensions,omitempty" yaml:"requiredExtensions,omitempty"`

	// Custom extension metadata is a named collection of auxiliary data whose
	// meaning is defined outside of the CNAB specification.
	Custom map[string]interface{} `json:"custom,omitempty" yaml:"custom,omitempty"`
}

Bundle is a CNAB metadata document

func ParseReader

func ParseReader(r io.Reader) (Bundle, error)

ParseReader reads CNAB metadata from a JSON string

func Unmarshal

func Unmarshal(data []byte) (*Bundle, error)

Unmarshal a Bundle from json.

func (Bundle) GetAction added in v0.22.0

func (b Bundle) GetAction(action string) (Action, error)

GetAction returns the definition for the specified action or an error if undefined. Assumes that all core actions such as install, upgrade, uninstall, are defined. Since the upgrade action is optional, and the bundle.json does not know if the action is supported using the metadata in bundle.json, calling upgrade at runtime may result in an error. You won't know until you try.

func (Bundle) IsOutputSensitive

func (b Bundle) IsOutputSensitive(outputName string) (bool, error)

IsOutputSensitive is a convenience function that determines if an output's value is sensitive.

func (Bundle) Marshal added in v0.20.0

func (b Bundle) Marshal() ([]byte, error)

Marshal the bundle to canonical json.

func (Bundle) Validate

func (b Bundle) Validate() error

Validate the bundle contents.

func (Bundle) WriteFile

func (b Bundle) WriteFile(dest string, mode os.FileMode) error

WriteFile serializes the bundle and writes it to a file as JSON.

func (Bundle) WriteTo

func (b Bundle) WriteTo(w io.Writer) (int64, error)

WriteTo writes unsigned JSON to an io.Writer using the standard formatting.

type Credential

type Credential struct {
	Location    `yaml:",inline"`
	Description string   `json:"description,omitempty" yaml:"description,omitempty"`
	Required    bool     `json:"required,omitempty" yaml:"required,omitempty"`
	ApplyTo     []string `json:"applyTo,omitempty" yaml:"applyTo,omitempty"`
}

Credential represents the definition of a CNAB credential

func (*Credential) AppliesTo added in v0.17.0

func (c *Credential) AppliesTo(action string) bool

AppliesTo returns a boolean value specifying whether or not the Credential applies to the provided action

func (*Credential) GetApplyTo added in v0.17.0

func (c *Credential) GetApplyTo() []string

GetApplyTo returns the list of actions that the Credential applies to.

func (*Credential) Validate

func (c *Credential) Validate() error

Validate a Credential

type Image

type Image struct {
	BaseImage   `yaml:",inline"`
	Description string `json:"description" yaml:"description"` //TODO: change? see where it's being used? change to description?
}

Image describes a container image in the bundle

func (*Image) DeepCopy

func (i *Image) DeepCopy() *Image

type InvocationImage

type InvocationImage struct {
	BaseImage `yaml:",inline"`
}

InvocationImage contains the image type and location for the installation of a bundle

func (*InvocationImage) DeepCopy

func (img *InvocationImage) DeepCopy() *InvocationImage

func (InvocationImage) Validate

func (img InvocationImage) Validate() error

Validate the image contents.

type Location

type Location struct {
	Path                string `json:"path,omitempty" yaml:"path,omitempty"`
	EnvironmentVariable string `json:"env,omitempty" yaml:"env,omitempty"`
}

Location provides the location where a value should be written in the invocation image.

A location may be either a file (by path) or an environment variable.

func (Location) Validate

func (l Location) Validate() error

Validate the Location

type LocationRef

type LocationRef struct {
	Path      string `json:"path" yaml:"path"`
	Field     string `json:"field" yaml:"field"`
	MediaType string `json:"mediaType" yaml:"mediaType"`
}

LocationRef specifies a location within the invocation package

type Maintainer

type Maintainer struct {
	// Name is a user name or organization name
	Name string `json:"name" yaml:"name"`
	// Email is an optional email address to contact the named maintainer
	Email string `json:"email,omitempty" yaml:"email,omitempty"`
	// Url is an optional URL to an address for the named maintainer
	URL string `json:"url,omitempty" yaml:"url,omitempty"`
}

Maintainer describes a code maintainer of a bundle

type Output

type Output struct {
	Definition  string   `json:"definition" yaml:"definition"`
	ApplyTo     []string `json:"applyTo,omitempty" yaml:"applyTo,omitempty"`
	Description string   `json:"description,omitempty" yaml:"description,omitempty"`
	Path        string   `json:"path" yaml:"path"`
}

func (Output) AppliesTo

func (o Output) AppliesTo(action string) bool

AppliesTo returns a boolean value specifying whether or not the Output applies to the provided action

func (Output) GetApplyTo added in v0.17.0

func (o Output) GetApplyTo() []string

GetApplyTo returns the list of actions that the Output applies to.

func (*Output) Validate added in v0.20.0

func (o *Output) Validate(name string, bun Bundle) error

Validate an Output

type Parameter

type Parameter struct {
	Definition  string    `json:"definition" yaml:"definition"`
	ApplyTo     []string  `json:"applyTo,omitempty" yaml:"applyTo,omitempty"`
	Description string    `json:"description,omitempty" yaml:"description,omitempty"`
	Destination *Location `json:"destination" yaml:"destination"`
	Required    bool      `json:"required,omitempty" yaml:"required,omitempty"`
}

Parameter defines a single parameter for a CNAB bundle

func (*Parameter) AppliesTo

func (p *Parameter) AppliesTo(action string) bool

AppliesTo returns a boolean value specifying whether or not the Parameter applies to the provided action

func (*Parameter) GetApplyTo added in v0.17.0

func (p *Parameter) GetApplyTo() []string

GetApplyTo returns the list of actions that the Parameter applies to.

func (*Parameter) Validate

func (p *Parameter) Validate(name string, bun Bundle) error

Validate a Parameter

type Scoped added in v0.17.0

type Scoped interface {
	// GetApplyTo returns the list of applicable actions.
	GetApplyTo() []string
}

Scoped represents an item whose scope is limited to a set of actions.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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