extensions

package
v0.38.11 Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DependenciesExtensionShortHand is the short suffix of the DependenciesExtensionKey
	DependenciesExtensionShortHand = "dependencies"

	// DependenciesExtensionKey represents the full key for the DependenciesExtension.
	DependenciesExtensionKey = OfficialExtensionsPrefix + DependenciesExtensionShortHand

	// DependenciesSchema represents the schema for the Dependencies Extension
	DependenciesSchema = "https://cnab.io/v1/dependencies.schema.json"
)
View Source
const (
	// DockerExtensionShortHand is the short suffix of the DockerExtensionKey.
	DockerExtensionShortHand = "docker"

	// DockerExtensionKey represents the full key for the Docker Extension
	DockerExtensionKey = OfficialExtensionsPrefix + DockerExtensionShortHand

	// DockerExtensionSchema represents the schema for the Docker Extension
	DockerExtensionSchema = "schema/io-cnab-docker.schema.json"
)
View Source
const (
	// PorterExtensionsPrefix is the prefix applied to any custom CNAB extensions developed by Porter.
	PorterExtensionsPrefix = "sh.porter."

	// OfficialExtensionsPrefix is the prefix applied to extensions defined in the CNAB spec.
	OfficialExtensionsPrefix = "io.cnab."
)
View Source
const (
	// FileParameterExtensionShortHand is the short suffix of the FileParameterExtensionKey.
	FileParameterExtensionShortHand = "file-parameters"

	// FileParameterExtensionKey represents the full key for the File Parameter extension.
	FileParameterExtensionKey = PorterExtensionsPrefix + FileParameterExtensionShortHand
)
View Source
const (
	// ParameterSourcesExtensionShortHand is the short suffix of the ParameterSourcesExtensionKey.
	ParameterSourcesExtensionShortHand = "parameter-sources"

	// ParameterSourcesExtensionKey represents the full key for the Parameter Sources Extension.
	ParameterSourcesExtensionKey = OfficialExtensionsPrefix + ParameterSourcesExtensionShortHand

	// 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

DependenciesExtension represents the required extension to enable dependencies

View Source
var DockerExtension = RequiredExtension{
	Shorthand: DockerExtensionShortHand,
	Key:       DockerExtensionKey,
	Schema:    "schema/io-cnab-docker.schema.json",
	Reader:    DockerExtensionReader,
}

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

FileParameterExtension represents a required extension that indicates that the bundle requires support for parameters of type "file"

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 FileParameterReader added in v0.32.0

func FileParameterReader(_ cnabbundle.Bundle) (interface{}, error)

FileParameterReader is a Reader for the FileParameterExtension. The extension does not have any data, it's presence indicates that parameters of type "file" should be supported by the tooling.

func GetParameterType added in v0.32.0

func GetParameterType(b bundle.Bundle, def *definition.Schema) string

GetParameterType determines the type of parameter accounting for Porter-specific parameter types like file.

func HasDependencies added in v0.28.0

func HasDependencies(b bundle.Bundle) bool

HasParameterSources returns whether or not the bundle has parameter sources 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 IsFileType added in v0.32.0

func IsFileType(b bundle.Bundle, def *definition.Schema) bool

IsFileType determines if the parameter/credential is of type "file".

func IsPorterBundle added in v0.32.0

func IsPorterBundle(b bundle.Bundle) bool

IsPorterBundle determines if the bundle was created by Porter.

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

func SupportsDependencies added in v0.32.0

func SupportsDependencies(b bundle.Bundle) bool

SupportsDependencies checks if the bundle supports dependencies

func SupportsExtension added in v0.32.0

func SupportsExtension(b bundle.Bundle, key string) bool

SupportsExtension checks if the bundle supports the specified CNAB extension.

func SupportsFileParameters added in v0.32.0

func SupportsFileParameters(b bundle.Bundle) bool

SupportsFileParameters checks if the bundle supports file parameters.

func SupportsParameterSources added in v0.32.0

func SupportsParameterSources(b bundle.Bundle) bool

SupportsParameterSources checks if the bundle supports parameter sources.

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) FileParameterSupport added in v0.32.0

func (e ProcessedExtensions) FileParameterSupport() bool

FileParameterSupport checks if the file parameter extension is present.

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