extensions

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DependenciesKey represents the full key for the Dependencies Extension
	DependenciesKey = "io.cnab.dependencies"
	// DependenciesSchema represents the schema for the Dependencies Extension
	DependenciesSchema = "https://cnab.io/v1/dependencies.schema.json"
)
View Source
const (
	// DockerExtensionKey represents the full key for the Docker Extension
	DockerExtensionKey = "io.cnab.docker"
	// DockerExtensionSchema represents the schema for the Docker Extension
	DockerExtensionSchema = "schema/io-cnab-docker.schema.json"
)
View Source
const (
	// ParameterSourcesExtensionKey represents the full key for the Parameter Sources Extension.
	ParameterSourcesKey = "io.cnab.parameter-sources"
	// ParameterSourcesExtensionSchema represents the schema for the Docker Extension.
	ParameterSourcesSchema = "https://cnab.io/v1/parameter-sources.schema.json"
	// ParameterSourceTypeOutput defines a type of parameter source that is provided by a bundle output.
	ParameterSourceTypeOutput = "output"
	// ParameterSourceTypeDependencyOutput defines a type of parameter source that is provided by a bundle's dependency
	// output.
	ParameterSourceTypeDependencyOutput = "dependencies.output"
)

Variables

View Source
var DependenciesExtension = RequiredExtension{
	Shorthand: "dependencies",
	Key:       DependenciesKey,
	Schema:    DependenciesSchema,
	Reader:    DependencyReader,
}

DependenciesExtension represents the required extension to enable dependencies

View Source
var DockerExtension = RequiredExtension{
	Shorthand: "docker",
	Key:       DockerExtensionKey,
	Schema:    DockerExtensionSchema,
	Reader:    DockerExtensionReader,
}

DockerExtension represents a required extension enabling access to the host Docker daemon

View Source
var ParameterSourcesExtension = RequiredExtension{
	Shorthand: "parameter-sources",
	Key:       ParameterSourcesKey,
	Schema:    ParameterSourcesSchema,
	Reader:    ParameterSourcesReader,
}

ParameterSourcesExtension represents a required extension that specifies how to default parameter values.

SupportedExtensions represent a listing of the current required extensions that Porter supports

Functions

func BuildPrerequisiteInstallationName added in v0.28.0

func BuildPrerequisiteInstallationName(installation string, dependency string) string

BuildPrerequisiteInstallationName generates the name of a prerequisite dependency installation.

func DependencyReader

func DependencyReader(bun bundle.Bundle) (interface{}, error)

DependencyReader is a Reader for the DependenciesExtension, which reads from the applicable section in the provided bundle and returns a the raw data in the form of an interface

func DockerExtensionReader

func DockerExtensionReader(bun bundle.Bundle) (interface{}, error)

DockerExtensionReader is a Reader for the DockerExtension, which reads from the applicable section in the provided bundle and returns a the raw data in the form of an interface

func HasDependencies added in v0.28.0

func HasDependencies(bun bundle.Bundle) bool

HasDependencies returns whether or not the bundle has dependencies defined.

func HasParameterSources added in v0.28.0

func HasParameterSources(b bundle.Bundle) bool

HasParameterSources returns whether or not the bundle has parameter sources defined.

func ParameterSourcesReader added in v0.28.0

func ParameterSourcesReader(bun bundle.Bundle) (interface{}, error)

ParameterSourcesReader is a Reader for the ParameterSourcesExtension, which reads from the applicable section in the provided bundle and returns a the raw data in the form of an interface

Types

type Dependencies

type Dependencies struct {
	// Sequence is a list to order the dependencies
	Sequence []string `json:"sequence,omitempty" mapstructure:"sequence"`

	// Requires is a list of bundles required by this bundle
	Requires map[string]Dependency `json:"requires,omitempty" mapstructure:"requires"`
}

Dependencies describes the set of custom extension metadata associated with the dependencies spec https://github.com/cnabio/cnab-spec/blob/master/500-CNAB-dependencies.md

func ReadDependencies

func ReadDependencies(bun bundle.Bundle) (Dependencies, error)

ReadDependencies is a convenience method for returning a bonafide Dependencies reference after reading from the applicable section from the provided bundle

func (Dependencies) ListBySequence added in v0.29.0

func (d Dependencies) ListBySequence() []Dependency

ListBySequence returns the dependencies by the defined sequence, if none is specified, they are unsorted.

type Dependency

type Dependency struct {
	// Name of the dependency
	Name string `json:"name" mapstructure:"name"`

	// Bundle is the location of the bundle in a registry, for example REGISTRY/NAME:TAG
	Bundle string `json:"bundle" mapstructure:"bundle"`

	// Version is a set of allowed versions
	Version *DependencyVersion `json:"version,omitempty" mapstructure:"version"`
}

Dependency describes a dependency on another bundle

type DependencyLock

type DependencyLock struct {
	Alias     string
	Reference string
}

type DependencyOutputParameterSource added in v0.28.0

type DependencyOutputParameterSource struct {
	Dependency string `json:"dependency" mapstructure:"dependency"`
	OutputName string `json:"name" mapstructure:"name"`
}

DependencyOutputParameterSource represents a parameter that is set using the value from a bundle's dependency output.

type DependencySolver

type DependencySolver struct {
}

func (*DependencySolver) ResolveDependencies

func (s *DependencySolver) ResolveDependencies(bun bundle.Bundle) ([]DependencyLock, error)

func (*DependencySolver) ResolveVersion

func (s *DependencySolver) ResolveVersion(name string, dep Dependency) (reference.NamedTagged, error)

ResolveVersion returns the bundle name, its version and any error.

type DependencyVersion

type DependencyVersion struct {
	// Ranges of semantic versions, with or without the leading v prefix, allowed by the dependency
	Ranges []string `json:"ranges,omitempty" mapstructure:"ranges"`

	// AllowPrereleases specifies if prerelease versions can satisfy the dependency
	AllowPrereleases bool `json:"prereleases" mapstructure:"prereleases"`
}

DependencyVersion is a set of allowed versions for a dependency

type Docker

type Docker struct {
	// Privileged represents whether or not the Docker container should run as --privileged
	Privileged bool `json:"privileged,omitempty"`
}

Docker describes the set of custom extension metadata associated with the Docker extension

type OutputParameterSource added in v0.28.0

type OutputParameterSource struct {
	OutputName string `json:"name" mapstructure:"name"`
}

OutputParameterSource represents a parameter that is set using the value from a bundle output.

type ParameterSource added in v0.28.0

type ParameterSource struct {
	// Priority is an array of source types in the priority order that they should be used to
	// populated the parameter.
	Priority []string `json:"priority" mapstructure:"priority"`

	// Sources is a map of key/value pairs of a source type and definition for
	// the parameter value.
	Sources ParameterSourceMap `json:"sources" mapstructure:"sources"`
}

func (ParameterSource) ListSourcesByPriority added in v0.28.0

func (s ParameterSource) ListSourcesByPriority() []ParameterSourceDefinition

ListSourcesByPriority returns the parameter sources by the requested priority, if none is specified, they are unsorted.

type ParameterSourceDefinition added in v0.28.0

type ParameterSourceDefinition interface {
}

type ParameterSourceMap added in v0.28.0

type ParameterSourceMap map[string]ParameterSourceDefinition

func (*ParameterSourceMap) UnmarshalJSON added in v0.28.0

func (m *ParameterSourceMap) UnmarshalJSON(data []byte) error

type ParameterSources added in v0.28.0

type ParameterSources map[string]ParameterSource

ParameterSources describes the set of custom extension metadata associated with the Parameter Sources extension

func ReadParameterSources added in v0.28.0

func ReadParameterSources(bun bundle.Bundle) (ParameterSources, error)

ReadParameterSources is a convenience method for returning a bonafide ParameterSources reference after reading from the applicable section from the provided bundle

func (*ParameterSources) SetParameterFromDependencyOutput added in v0.28.0

func (ps *ParameterSources) SetParameterFromDependencyOutput(parameter string, dep string, output string)

SetParameterFromDependencyOutput creates an entry in the parameter sources section setting the parameter's value using the specified dependency's output value.

func (*ParameterSources) SetParameterFromOutput added in v0.28.0

func (ps *ParameterSources) SetParameterFromOutput(parameter string, output string)

SetParameterFromOutput creates an entry in the parameter sources section setting the parameter's value using the specified output's value.

type ProcessedExtensions

type ProcessedExtensions map[string]interface{}

ProcessedExtensions represents a map of the extension name to the processed extension configuration

func ProcessRequiredExtensions

func ProcessRequiredExtensions(b bundle.Bundle) (ProcessedExtensions, error)

ProcessRequiredExtensions checks all required extensions in the provided bundle and makes sure Porter supports them.

If an unsupported required extension is found, an error is returned.

For each supported required extension, the configuration for that extension is read and returned in the form of a map of the extension name to the extension configuration

func (ProcessedExtensions) GetDocker added in v0.28.0

func (e ProcessedExtensions) GetDocker() (dockerExt Docker, dockerRequired bool, err error)

GetDocker checks if the docker extension is present and returns its extension configuration.

func (ProcessedExtensions) GetParameterSources added in v0.28.0

func (e ProcessedExtensions) GetParameterSources() (ParameterSources, bool, error)

GetParameterSources checks if the parameter sources extension is present and returns its extension configuration.

type RequiredExtension

type RequiredExtension struct {
	Shorthand string
	Key       string
	Schema    string
	Reader    func(b bundle.Bundle) (interface{}, error)
}

RequiredExtension represents a required extension that is known and supported by Porter

func GetSupportedExtension

func GetSupportedExtension(e string) (*RequiredExtension, error)

GetSupportedExtension returns a supported extension according to the provided name, or an error

Jump to

Keyboard shortcuts

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