v2

package
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package v2 defines the v2 Porter Dependency specification, org.getporter.dependencies@v2.

Index

Constants

View Source
const (
	// SharingModeGroup specifies that a dependency may be shared with other bundles in the same sharing group.
	// Group is the default sharing mode.
	SharingModeGroup = "group"

	// SharingModeNone specifies that a dependency must not be shared with other bundles.
	SharingModeNone = "none"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Dependencies

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

	// Provides specifies how the bundle can satisfy a dependency.
	// This declares that the bundle can provide a dependency that another bundle requires.
	Provides *DependencyProvider `json:"provides,omitempty" mapstructure:"provides,omitempty"`
}

Dependencies describes the set of custom extension metadata associated with v2 of Porter's implementation of dependencies.

type Dependency

type Dependency struct {
	// Name of the dependency
	// This is used internally but isn't persisted to bundle.json
	Name string `json:"-" mapstructure:"-"`

	// 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 defined according to the https://github.com/Masterminds/semver constraint syntax.
	Version string `json:"version,omitempty" mapstructure:"version"`

	// Interface defines how the dependency is used by this bundle.
	Interface *DependencyInterface `json:"interface,omitempty" mapstructure:"interface,omitempty"`

	// Sharing is a set of rules for sharing a dependency with other bundles.
	Sharing SharingCriteria `json:"sharing,omitempty" mapstructure:"sharing,omitempty"`

	// Parameters to pass from the bundle to the dependency.
	// The value may use templates with the bundle and installation variables
	Parameters map[string]string `json:"parameters,omitempty" mapstructure:"parameters,omitempty"`

	// Credentials to pass from the bundle to the dependency.
	// The value may use templates with the bundle and installation variables
	Credentials map[string]string `json:"credentials,omitempty" mapstructure:"credentials,omitempty"`

	// Outputs to promote from the dependency to the parent bundle.
	// The value may use templates with the bundle, installation, and outputs variables.
	// The outputs variable is a copy of bundle.dependencies.CURRENT_DEP.outputs.
	Outputs map[string]string `json:"outputs,omitempty" mapstructure:"outputs,omitempty"`
}

Dependency describes a dependency on another bundle

type DependencyInterface

type DependencyInterface struct {
	// ID is the identifier or name of the bundle interface. It should be matched
	// against the Dependencies.Provides.Interface.ID to determine if two interfaces
	// are equivalent.
	ID string `json:"id,omitempty" mapstructure:"id,omitempty"`

	// Reference is an OCI reference to a bundle. The bundle.json is used to define
	// the interface using the bundle's credentials, parameters and outputs.
	Reference string `json:"reference,omitempty" mapstructure:"reference,omitempty"`

	// Document is an embedded subset of a bundle.json document, defining relevant
	// portions of a bundle's interface, such as credentials, parameters and outputs.
	Document DependencyInterfaceDocument `json:"document,omitempty" mapstructure:"document,omitempty"`
}

DependencyInterface defines how the dependency is used by this bundle.

type DependencyInterfaceDocument added in v1.0.16

type DependencyInterfaceDocument struct {
	// Outputs defined on the bundle interface
	Outputs map[string]bundle.Output `json:"outputs,omitempty" mapstructure:"outputs,omitempty"`
	// Parameters defined on the bundle interface
	Parameters map[string]bundle.Parameter `json:"parameters,omitempty" mapstructure:"parameters,omitempty"`
	// Credentials defined on the bundle interface
	Credentials map[string]bundle.Credential `json:"credentials,omitempty" mapstructure:"credentials,omitempty"`
}

DependencyInterfaceDocument declares an inline bundle.json that defines the bundle interface

type DependencyProvider

type DependencyProvider struct {
	// Interface declares the bundle interface that the current bundle provides.
	Interface InterfaceDeclaration `json:"interface,omitempty" mapstructure:"interface,omitempty"`
}

DependencyProvider specifies how the current bundle can be used to satisfy a dependency.

type DependencySource

type DependencySource struct {
	// Value species a hard-coded value to pass to the dependency.
	Value string `json:"value,omitempty" mapstructure:"value,omitempty"`

	// Dependency is the name of another dependency from which the Output is defined.
	Dependency string `json:"dependency,omitempty" mapstructure:"dependency,omitempty"`

	// Credential is the name of a credential defined on the parent bundle.
	Credential string `json:"credential,omitempty" mapstructure:"credential,omitempty"`

	// Parameter is the name of a parameter defined on the parent bundle.
	Parameter string `json:"parameter,omitempty" mapstructure:"parameter,omitempty"`

	// Output is the name of an output defined on `dependency`. Used to pass an
	// output from a dependency to another dependency. MUST be specified with
	// `dependency`.
	Output string `json:"output,omitempty" mapstructure:"output,omitempty"`
}

DependencySource represents how to pass data between dependencies. For example, passing the output of a dependency to the parameter of another.

Exactly one of `value`, `parameter`, `credential` or `output` must be specified. A parent bundle can pass a hard-coded value, the value of a parameter or credential, or the output from another child dependency to the credential of a child dependency.

func ParseDependencySource

func ParseDependencySource(templateVariable string) (DependencySource, error)

ParseDependencySource identifies the components specified in a template variable.

func (DependencySource) AsBundleWiring

func (s DependencySource) AsBundleWiring() string

AsBundleWiring is the wiring string representation in the bundle definition. For example, bundle.parameters.PARAM or bundle.dependencies.DEP.outputs.OUTPUT

func (DependencySource) AsWorkflowWiring

func (s DependencySource) AsWorkflowWiring(jobID string) string

AsWorkflowWiring is the wiring string representation in a workflow definition. For example, workflow.jobs.JOB.outputs.OUTPUT

func (DependencySource) WiringSuffix

func (s DependencySource) WiringSuffix() string

WiringSuffix identifies the data to retrieve from the source. For example, parameters.PARAM or outputs.OUTPUT

type InterfaceDeclaration

type InterfaceDeclaration struct {
	// ID is the URI of the interface that this bundle provides. Usually a well-known name defined by Porter or CNAB.
	ID string `json:"id,omitempty" mapstructure:"id,omitempty"`
}

InterfaceDeclaration declares that the current bundle supports the specified bundle interface Reserved for future use. Right now we only use an interface id, but could support other fields later.

type SharingCriteria

type SharingCriteria struct {
	// Mode defines how a dependency can be shared.
	// * false: The dependency cannot be shared, even within the same dependency graph.
	// * true: The dependency is shared with other bundles who defined the dependency with the same sharing group.
	Mode bool `json:"mode,omitempty" mapstructure:"mode,omitempty"`

	// Group defines matching criteria for determining if two dependencies are in the same sharing group.
	Group SharingGroup `json:"group,omitempty" mapstructure:"group,omitempty"`
}

SharingCriteria is a set of rules for sharing a dependency with other bundles.

type SharingGroup

type SharingGroup struct {
	// Name of the sharing group. The name of the group must match for two bundles to share the same dependency.
	Name string `json:"name,omitempty" mapstructure:"name,omitempty"`
}

SharingGroup defines a set of characteristics for sharing a dependency with other bundles. Reserved for future use: We may add more characteristics to the sharing group (such as labels) if it seems useful.

Jump to

Keyboard shortcuts

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