porter

package
v0.1.0-raplpha....-c86f6ab Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2018 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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
}

Action describes a custom (non-core) action.

type BaseImage

type BaseImage struct {
	Digest    string `json:"digest,omitempty" toml:"digest"`
	Size      uint64 `json:"size,omitempty" toml:"size"`
	Platform  string `json:"platform,omitempty" toml:"platform"`
	MediaType string `json:"mediaType,omitempty" toml:"mediaType"`
}

BaseImage contains fields shared across image types

type Bundle

type Bundle struct {
	Name             string                         `json:"name" toml:"name"`
	Version          string                         `json:"version" toml:"version"`
	Description      string                         `json:"description" toml:"description"`
	Keywords         []string                       `json:"keywords,omitempty" toml:"keywords,omitempty"`
	Maintainers      []Maintainer                   `json:"maintainers,omitempty" toml:"maintainers,omitempty"`
	InvocationImages []InvocationImage              `json:"invocationImages" toml:"invocationImages"`
	Images           []Image                        `json:"images" toml:"images"`
	Actions          map[string]Action              `json:"actions,omitempty" toml:"actions,omitempty"`
	Parameters       map[string]ParameterDefinition `json:"parameters" toml:"parameters"`
	Credentials      map[string]Location            `json:"credentials" toml:"credentials"`
}

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 unmarshals a Bundle that was not signed.

func (Bundle) Validate

func (b Bundle) Validate() error

Validate the bundle contents.

type Image

type Image struct {
	BaseImage
	// FIXME: Is this the same as "image" on InvocationImage? Which do we prefer?
	Name string        `json:"name" toml:"name"`
	URI  string        `json:"uri" toml:"uri"`
	Refs []LocationRef `json:"refs" toml:"refs"`
}

Image describes a container image in the bundle

type ImagePlatform

type ImagePlatform struct {
	Architecture string `json:"architecture,omitempty" toml:"architecture"`
	OS           string `json:"os,omitempty" toml:"os"`
}

ImagePlatform indicates what type of platform an image is built for

type InvocationImage

type InvocationImage struct {
	BaseImage
	ImageType string `json:"imageType" toml:"imageType"`
	Image     string `json:"image" toml:"image"`
}

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

func (InvocationImage) Validate

func (img InvocationImage) Validate() error

Validate the image contents.

type Location

type Location struct {
	Path                string `json:"path" toml:"path"`
	EnvironmentVariable string `json:"env" toml:"env"`
}

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.

type LocationRef

type LocationRef struct {
	Path  string `json:"path" toml:"path"`
	Field string `json:"field" toml:"field"`
}

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" toml:"name"`
	// Email is an optional email address to contact the named maintainer
	Email string `json:"email" toml:"email"`
	// Url is an optional URL to an address for the named maintainer
	URL string `json:"url" toml:"url"`
}

Maintainer describes a code maintainer of a bundle

type ParameterDefinition

type ParameterDefinition struct {
	DataType      string            `json:"type" toml:"type"`
	DefaultValue  interface{}       `json:"defaultValue,omitempty" toml:"defaultValue,omitempty"`
	AllowedValues []interface{}     `json:"allowedValues,omitempty" toml:"allowedValues,omitempty"`
	Required      bool              `json:"required" toml:"required"`
	MinValue      *int              `json:"minValue,omitempty" toml:"minValue,omitempty"`
	MaxValue      *int              `json:"maxValue,omitempty" toml:"maxValue,omitempty"`
	MinLength     *int              `json:"minLength,omitempty" toml:"minLength,omitempty"`
	MaxLength     *int              `json:"maxLength,omitempty" toml:"maxLength,omitempty"`
	Metadata      ParameterMetadata `json:"metadata,omitempty" toml:"metadata,omitempty"`
	Destination   *Location         `json:"destination,omitemtpty" toml:"destination,omitempty"`
}

ParameterDefinition defines a single parameter for a CNAB bundle

func (ParameterDefinition) CoerceValue

func (pd ParameterDefinition) CoerceValue(value interface{}) interface{}

CoerceValue coerces the given value to the definition's DataType; unlike ConvertValue, which performs string parsing, it assumes the value is already of a suitable type (and validated)

func (ParameterDefinition) ConvertValue

func (pd ParameterDefinition) ConvertValue(val string) (interface{}, error)

ConvertValue tries to convert the given value to the definition's DataType

It will return an error if it cannot be converted

func (ParameterDefinition) ValidateParameterValue

func (pd ParameterDefinition) ValidateParameterValue(value interface{}) error

ValidateParameterValue checks whether a value is valid as the value of the specified parameter.

type ParameterMetadata

type ParameterMetadata struct {
	Description string `json:"description,omitempty" toml:"description,omitempty"`
}

ParameterMetadata contains metadata for a parameter definition.

type Porter

type Porter struct {
	*config.Config
}

Porter is the logic behind the porter client.

func New

func New() *Porter

New porter client, initialized with useful defaults.

func (*Porter) Build

func (p *Porter) Build() error

func (*Porter) Create

func (p *Porter) Create() error

func (*Porter) PrintVersion

func (p *Porter) PrintVersion()

func (*Porter) Run

func (p *Porter) Run(file string, action config.Action) error

func (Porter) WriteFile

func (p Porter) WriteFile(b Bundle, mode os.FileMode) error

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

type TestPorter

type TestPorter struct {
	*Porter
	TestConfig *config.TestConfig
}

func NewTestPorter

func NewTestPorter(t *testing.T) *TestPorter

NewTestPorter initializes a porter test client, with the output buffered, and an in-memory file system.

Jump to

Keyboard shortcuts

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