manifest

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 25 Imported by: 6

Documentation

Index

Constants

View Source
const (

	// SchemaTypeBundle is the default schemaType value for Bundle resources
	SchemaTypeBundle = "Bundle"

	// TemplateDelimiterPrefix must be present at the beginning of any porter.yaml
	// that wants to use ${} as the template delimiter instead of the mustache
	// default of {{}}.
	TemplateDelimiterPrefix = "{{=${ }=}}\n"
)

Variables

View Source
var (

	// SupportedSchemaVersions is the Porter manifest (porter.yaml) schema
	// versions supported by this version of Porter, specified as a semver range.
	// When the Manifest structure is changed, this field should be incremented.
	SupportedSchemaVersions, _ = semver.NewConstraint("1.0.0-alpha.1 || 1.0.0 - 1.0.1")

	// DefaultSchemaVersion is the most recently supported schema version.
	// When the Manifest structure is changed, this field should be incremented.
	DefaultSchemaVersion = semver.MustParse("1.0.1")
)

Functions

func GetCoreActions

func GetCoreActions() []string

func GetParameterSourceForDependency added in v0.28.0

func GetParameterSourceForDependency(ref DependencyOutputReference) string

GetParameterSourceForDependency builds the parameter source name used by Porter internally for wiring up an dependency's output to a parameter.

func GetParameterSourceForOutput added in v0.28.0

func GetParameterSourceForOutput(outputName string) string

GetParameterSourceForOutput builds the parameter source name used by Porter internally for wiring up an output to a parameter.

func IsCoreAction

func IsCoreAction(value string) bool

IsCoreAction determines if the value is a core action from the CNAB spec.

func ParamToEnvVar added in v0.28.0

func ParamToEnvVar(name string) string

Convert a parameter name to an environment variable. Anything more complicated should define the variable explicitly.

func ReadManifestData

func ReadManifestData(cxt *portercontext.Context, path string) ([]byte, error)

func ResolvePath added in v1.0.1

func ResolvePath(value string) string

ResolvePath resolves a path specified in the Porter manifest into an absolute path, assuming the current directory is /cnab/app. Returns an empty string when the specified value is empty.

Types

type BundleCriteria added in v1.0.1

type BundleCriteria struct {
	// Reference is an OCI reference to a bundle for use as the default implementation of the bundle.
	// It should be in the format REGISTRY/NAME:TAG
	Reference string `yaml:"reference"`

	// "When constraint checking is used for checks or validation
	// it will follow a different set of rules that are common for ranges with tools like npm/js and Rust/Cargo.
	// This includes considering prereleases to be invalid if the ranges does not include one.
	// If you want to have it include pre-releases a simple solution is to include -0 in your range."
	// https://github.com/Masterminds/semver/blob/master/README.md#checking-version-constraints
	Version string `yaml:"version,omitempty"`

	// Interface specifies criteria for allowing a bundle to satisfy a dependency.
	Interface *BundleInterface `yaml:"interface,omitempty"`
}

BundleCriteria criteria for selecting a bundle to satisfy a dependency.

type BundleInterface added in v1.0.12

type BundleInterface 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 `yaml:"id,omitempty"`

	// Reference specifies an OCI reference to a bundle to use as the interface on top of how the bundle is used.
	Reference string `yaml:"reference,omitempty"`

	// Document specifies additional constraints that should be added to the bundle interface.
	// By default, Porter only requires the name and the type to match, additional jsonschema values can be specified to restrict matching bundles even further.
	// The value should be a jsonschema document containing relevant sub-documents from a bundle.json that should be applied to the base bundle interface.
	Document *BundleInterfaceDocument `yaml:"document,omitempty"`
}

BundleInterface specifies how a bundle can satisfy a dependency. Porter always infers a base interface based on how the dependency is used in porter.yaml but this allows the bundle author to extend it and add additional restrictions. Either bundle or reference may be specified but not both.

type BundleInterfaceDocument added in v1.0.12

type BundleInterfaceDocument struct {
	// Parameters that are defined on the interface.
	Parameters ParameterDefinitions `yaml:"parameters,omitempty"`

	// Credentials that are defined on the interface.
	Credentials CredentialDefinitions `yaml:"credentials,omitempty"`

	// Outputs that are defined on the interface.
	Outputs OutputDefinitions `yaml:"outputs,omitempty"`
}

BundleInterfaceDocument specifies the interface that a bundle must support in order to satisfy a dependency.

type BundleOutput

type BundleOutput struct {
	Name                string `yaml:"name"`
	Path                string `yaml:"path"`
	EnvironmentVariable string `yaml:"env"`
}

type CredentialDefinition

type CredentialDefinition struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description,omitempty"`

	// Required specifies if the credential must be specified for applicable actions. Defaults to true.
	Required bool `yaml:"required,omitempty"`

	// ApplyTo lists the actions to which the credential applies. When unset, defaults to all actions.
	ApplyTo []string `yaml:"applyTo,omitempty"`

	Location `yaml:",inline"`
}

CredentialDefinition represents the structure or fields of a credential parameter

func (*CredentialDefinition) UnmarshalYAML

func (cd *CredentialDefinition) UnmarshalYAML(unmarshal func(interface{}) error) error

type CredentialDefinitions added in v0.28.0

type CredentialDefinitions map[string]CredentialDefinition

CredentialDefinitions allows us to represent credentials as a list in the YAML and work with them as a map internally

func (CredentialDefinitions) MarshalYAML added in v0.28.0

func (cd CredentialDefinitions) MarshalYAML() (interface{}, error)

func (*CredentialDefinitions) UnmarshalYAML added in v0.28.0

func (cd *CredentialDefinitions) UnmarshalYAML(unmarshal func(interface{}) error) error

type CustomActionDefinition

type CustomActionDefinition struct {
	Description       string `yaml:"description,omitempty"`
	ModifiesResources bool   `yaml:"modifies,omitempty"`
	Stateless         bool   `yaml:"stateless,omitempty"`
}

type CustomDefinitions added in v0.35.0

type CustomDefinitions map[string]interface{}

func (*CustomDefinitions) UnmarshalYAML added in v0.35.0

func (cd *CustomDefinitions) UnmarshalYAML(unmarshal func(interface{}) error) error

type Dependencies added in v1.0.1

type Dependencies struct {
	// Requires specifies bundles required by the current bundle.
	Requires []*Dependency `yaml:"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 `yaml:"provides,omitempty"`
}

Dependencies defies both v2 and v1 dependencies. Dependencies v1 is a subset of Dependencies v2.

type Dependency

type Dependency struct {
	// Name of the dependency, used to reference the dependency from other parts of
	// the bundle such as the template syntax, bundle.dependencies.NAME
	Name string `yaml:"name"`

	// Bundle specifies criteria for selecting a bundle to satisfy the dependency.
	Bundle BundleCriteria `yaml:"bundle"`

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

	// Parameters is a map of values, keyed by the destination where the value is the
	// source, to pass from the bundle to the dependency. May either be a hard-coded
	// value, or a template value such as ${bundle.parameters.NAME}. The key is the
	// dependency's parameter name, and the value is the data being passed to the
	// dependency parameter.
	Parameters map[string]string `yaml:"parameters,omitempty"`

	// Credentials is a map of values, keyed by the destination where the value is
	// the source, to pass from the bundle to the dependency. May either be a
	// hard-coded value, or a template value such as ${bundle.credentials.NAME}. The
	// key is the dependency's credential name, and the value is the data being
	// passed to the dependency credential.
	Credentials map[string]string `yaml:"credentials,omitempty"`

	// Outputs is a map of values, keyed by the destination where the value is the
	// source, to pass from the dependency and promote to a bundle-level outputs of
	// the parent bundle. May either be the name of an output from the dependency, or
	// a template value such as ${outputs.NAME} where the outputs variable holds the
	// current dependency's outputs. The long form of the template syntax,
	// ${bundle.dependencies.DEP.outputs.NAME}, is also supported. The key is the
	// parent bundle's output name, and the value is the data being passed to the
	// dependency parameter.
	Outputs map[string]string `yaml:"outputs,omitempty"`
}

Dependency defines a parent child relationship between this bundle (parent) and the specified bundle (child).

func (*Dependency) UsesV2Features added in v1.0.12

func (d *Dependency) UsesV2Features() bool

UsesV2Features returns true if the dependency uses features from v2 of Porter's implementation of dependencies, and returns false if the v1 implementation of dependencies would suffice.

func (*Dependency) Validate

func (d *Dependency) Validate(cxt *portercontext.Context) error

type DependencyOutputReference added in v0.28.0

type DependencyOutputReference struct {
	Dependency string
	Output     string
}

func (DependencyOutputReference) String added in v0.28.0

func (r DependencyOutputReference) String() string

type DependencyOutputReferences added in v0.28.0

type DependencyOutputReferences map[string]DependencyOutputReference

type DependencyProvider added in v1.0.12

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

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

type DependencySource added in v1.0.12

type DependencySource string

type InterfaceDeclaration added in v1.0.12

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 `yaml:"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 Location

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

Location represents a Parameter or Credential location in an InvocationImage

func (Location) IsEmpty

func (l Location) IsEmpty() bool

type MaintainerDefinition added in v1.0.1

type MaintainerDefinition struct {
	Name  string `yaml:"name,omitempty"`
	Email string `yaml:"email,omitempty"`
	Url   string `yaml:"url,omitempty"`
}

type Manifest

type Manifest struct {
	// ManifestPath is location to the original, user-supplied manifest, such as the path on the filesystem or a url
	ManifestPath string `yaml:"-"`

	// TemplateVariables are the variables used in the templating, e.g. bundle.parameters.NAME, or bundle.outputs.NAME
	TemplateVariables []string `yaml:"-"`

	// SchemaType indicates the type of resource contained in an imported file.
	SchemaType string `yaml:"schemaType,omitempty"`

	// SchemaVersion is a semver value that indicates which version of the porter.yaml schema is used in the file.
	SchemaVersion string `yaml:"schemaVersion"`
	Name          string `yaml:"name,omitempty"`
	Description   string `yaml:"description,omitempty"`
	Version       string `yaml:"version,omitempty"`

	Maintainers []MaintainerDefinition `yaml:"maintainers,omitempty"`

	// Registry is the OCI registry and org/subdomain for the bundle
	Registry string `yaml:"registry,omitempty"`

	// Reference is the optional, full bundle reference
	// in the format REGISTRY/NAME or REGISTRY/NAME:TAG
	Reference string `yaml:"reference,omitempty"`

	// DockerTag is the Docker tag portion of the published bundle
	// image and bundle.  It will only be set at time of publishing.
	DockerTag string `yaml:"-"`

	// Image is the name of the bundle image in the format REGISTRY/NAME:TAG
	// It doesn't map to any field in the manifest as it has been deprecated
	// and isn't meant to be user-specified
	Image string `yaml:"-"`

	// Dockerfile is the relative path to the Dockerfile template for the bundle image
	Dockerfile string `yaml:"dockerfile,omitempty"`

	Mixins []MixinDeclaration `yaml:"mixins,omitempty"`

	Install   Steps `yaml:"install"`
	Uninstall Steps `yaml:"uninstall"`
	Upgrade   Steps `yaml:"upgrade"`

	Custom                  CustomDefinitions                 `yaml:"custom,omitempty"`
	CustomActions           map[string]Steps                  `yaml:"-"`
	CustomActionDefinitions map[string]CustomActionDefinition `yaml:"customActions,omitempty"`

	StateBag     StateBag              `yaml:"state,omitempty"`
	Parameters   ParameterDefinitions  `yaml:"parameters,omitempty"`
	Credentials  CredentialDefinitions `yaml:"credentials,omitempty"`
	Dependencies Dependencies          `yaml:"dependencies,omitempty"`
	Outputs      OutputDefinitions     `yaml:"outputs,omitempty"`

	// ImageMap is a map of images referenced in the bundle. If an image relocation mapping is later provided, that
	// will be mounted at as a file at runtime to /cnab/app/relocation-mapping.json.
	ImageMap map[string]MappedImage `yaml:"images,omitempty"`

	Required []RequiredExtension `yaml:"required,omitempty"`
}

func LoadManifestFrom

func LoadManifestFrom(ctx context.Context, config *config.Config, file string) (*Manifest, error)

LoadManifestFrom reads and validates the manifest at the specified location, and returns a populated Manifest structure.

func ReadManifest

func ReadManifest(cxt *portercontext.Context, path string, config *config.Config) (*Manifest, error)

ReadManifest determines if specified path is a URL or a filepath. After reading the data in the path it returns a Manifest and any errors

func UnmarshalManifest

func UnmarshalManifest(cxt *portercontext.Context, manifestData []byte) (*Manifest, error)

func (*Manifest) DetermineDependenciesExtensionUsed added in v1.0.12

func (m *Manifest) DetermineDependenciesExtensionUsed() string

DetermineDependenciesExtensionUsed looks for how dependencies are used by the bundle and which version of the dependency extension can be used.

func (*Manifest) GetTemplateParameterName added in v1.1.0

func (m *Manifest) GetTemplateParameterName(value string) (string, bool)

GetTemplateParameterName returns the parameter name from the template variable.

func (*Manifest) GetTemplatePrefix added in v1.0.1

func (m *Manifest) GetTemplatePrefix() string

func (*Manifest) GetTemplatedDependencyOutputs added in v0.28.0

func (m *Manifest) GetTemplatedDependencyOutputs() DependencyOutputReferences

GetTemplatedOutputs returns the output definitions for any bundle level outputs that have been templated, keyed by "DEPENDENCY.OUTPUT".

func (*Manifest) GetTemplatedOutputs added in v0.28.0

func (m *Manifest) GetTemplatedOutputs() OutputDefinitions

GetTemplatedOutputs returns the output definitions for any bundle level outputs that have been templated, keyed by the output name.

func (*Manifest) GetTemplatedParameters added in v1.1.0

func (m *Manifest) GetTemplatedParameters() ParameterDefinitions

GetTemplatedParameters returns the output definitions for any bundle level outputs that have been templated, keyed by the output name.

func (*Manifest) ScanManifestTemplating added in v1.1.0

func (m *Manifest) ScanManifestTemplating(data []byte, config *config.Config) (templateScanResult, error)

func (*Manifest) SetBundleImageAndReference added in v1.2.0

func (m *Manifest) SetBundleImageAndReference(ref string) error

SetBundleImageAndReference sets the bundle image name and the bundle reference on the manifest per the provided reference or via the registry or name values on the manifest.

func (*Manifest) SetDefaults

func (m *Manifest) SetDefaults() error

SetDefaults updates the manifest with default values where not populated

func (*Manifest) Validate

func (m *Manifest) Validate(ctx context.Context, cfg *config.Config) error

type MappedImage

type MappedImage struct {
	Description string            `yaml:"description"`
	ImageType   string            `yaml:"imageType"`
	Repository  string            `yaml:"repository"`
	Digest      string            `yaml:"digest,omitempty"`
	Size        uint64            `yaml:"size,omitempty"`
	MediaType   string            `yaml:"mediaType,omitempty"`
	Labels      map[string]string `yaml:"labels,omitempty"`
	Tag         string            `yaml:"tag,omitempty"`
}

func (*MappedImage) ToOCIReference added in v1.0.1

func (mi *MappedImage) ToOCIReference() (cnab.OCIReference, error)

func (*MappedImage) Validate

func (mi *MappedImage) Validate() error

type MixinDeclaration

type MixinDeclaration struct {
	Name    string
	Version *semver.Constraints
	Config  interface{}
}

func (MixinDeclaration) MarshalYAML

func (m MixinDeclaration) MarshalYAML() (interface{}, error)

MarshalYAML allows mixin declarations to either be a normal list of strings mixins: - exec - helm3 or allow some entries to have config data defined

  • az: extensions:
  • iot

func (*MixinDeclaration) UnmarshalYAML

func (m *MixinDeclaration) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML allows mixin declarations to either be a normal list of strings mixins: - exec - helm3 or allow some entries to have config data defined

  • az: extensions:
  • iot

for each type, we can optionally support a version number in the name field mixins: - exec@2.1.1 or

  • az@2.1.1 extensions:
  • iot

type OutputDefinition

type OutputDefinition struct {
	Name      string   `yaml:"name"`
	ApplyTo   []string `yaml:"applyTo,omitempty"`
	Sensitive bool     `yaml:"sensitive"`

	// This is not in the CNAB spec, but it allows a mixin to create a file
	// and porter will take care of making it a proper output.
	Path string `yaml:"path,omitempty"`

	definition.Schema `yaml:",inline"`

	// IsState identifies if the output was generated from a state variable
	IsState bool `yaml:"-"`
}

OutputDefinition defines a single output for a CNAB

func (*OutputDefinition) DeepCopy

func (od *OutputDefinition) DeepCopy() *OutputDefinition

DeepCopy copies a ParameterDefinition and returns the copy

func (*OutputDefinition) Validate

func (od *OutputDefinition) Validate() error

type OutputDefinitions added in v0.28.0

type OutputDefinitions map[string]OutputDefinition

OutputDefinitions allows us to represent parameters as a list in the YAML and work with them as a map internally

func (OutputDefinitions) MarshalYAML added in v0.28.0

func (od OutputDefinitions) MarshalYAML() (interface{}, error)

func (*OutputDefinitions) UnmarshalYAML added in v0.28.0

func (od *OutputDefinitions) UnmarshalYAML(unmarshal func(interface{}) error) error

type ParameterDefinition

type ParameterDefinition struct {
	Name      string          `yaml:"name"`
	Sensitive bool            `yaml:"sensitive"`
	Source    ParameterSource `yaml:"source,omitempty"`

	// These fields represent a subset of bundle.Parameter as defined in cnabio/cnab-go,
	// minus the 'Description' field (definition.Schema's will be used) and `Definition` field
	ApplyTo     []string `yaml:"applyTo,omitempty"`
	Destination Location `yaml:",inline,omitempty"`

	definition.Schema `yaml:",inline"`

	// IsState identifies if the parameter was generated from a state variable
	IsState bool `yaml:"-"`
}

ParameterDefinition defines a single parameter for a CNAB bundle

func (*ParameterDefinition) AppliesTo

func (pd *ParameterDefinition) AppliesTo(action string) bool

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

func (*ParameterDefinition) DeepCopy

func (pd *ParameterDefinition) DeepCopy() *ParameterDefinition

DeepCopy copies a ParameterDefinition and returns the copy

func (*ParameterDefinition) GetApplyTo added in v0.38.4

func (pd *ParameterDefinition) GetApplyTo() []string

func (*ParameterDefinition) UpdateApplyTo added in v0.28.0

func (pd *ParameterDefinition) UpdateApplyTo(m *Manifest)

UpdateApplyTo updates a parameter definition's applyTo section based on the provided manifest

func (*ParameterDefinition) Validate

func (pd *ParameterDefinition) Validate() error

type ParameterDefinitions added in v0.28.0

type ParameterDefinitions map[string]ParameterDefinition

ParameterDefinitions allows us to represent parameters as a list in the YAML and work with them as a map internally

func (ParameterDefinitions) MarshalYAML added in v0.28.0

func (pd ParameterDefinitions) MarshalYAML() (interface{}, error)

func (*ParameterDefinitions) UnmarshalYAML added in v0.28.0

func (pd *ParameterDefinitions) UnmarshalYAML(unmarshal func(interface{}) error) error

type ParameterSource added in v0.28.0

type ParameterSource struct {
	Dependency string `yaml:"dependency,omitempty"`
	Output     string `yaml:"output"`
}

type RequiredExtension

type RequiredExtension struct {
	Name   string
	Config map[string]interface{}
}

RequiredExtension represents a custom extension that is required in order for a bundle to work correctly

func (*RequiredExtension) UnmarshalYAML

func (r *RequiredExtension) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML allows required extensions to either be a normal list of strings required: - docker or allow some entries to have config data defined

  • vpn: name: mytrustednetwork

type SharingCriteria added in v1.0.12

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. This is the default mode.
	Mode bool `yaml:"mode"`

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

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

func (SharingCriteria) GetEffectiveMode added in v1.0.12

func (s SharingCriteria) GetEffectiveMode() bool

GetEffectiveMode returns the mode, taking into account the default value when no mode is specified.

type SharingGroup added in v1.0.12

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 `yaml:"name"`
}

SharingGroup defines a set of characteristics for sharing a dependency with other bundles. Reserved for future use: We can add more characteristics later to expands how we share if needed

type StateBag added in v1.0.1

type StateBag []StateVariable

StateBag is the set of state files and variables that Porter should track between bundle executions.

type StateVariable added in v1.0.1

type StateVariable struct {
	// Name of the state variable
	Name string `yaml:"name"`

	// Description of the state variable and how it's used by the bundle
	Description string `yaml:"description,omitempty"`

	// Mixin is the name of the mixin that manages the state variable.
	Mixin string `yaml:"mixin,omitempty"`

	// Location defines where the state variable is located in the bundle.
	Location `yaml:",inline"`
}

type Step

type Step struct {
	Data map[string]interface{} `yaml:",inline"`
}

func (*Step) GetDescription

func (s *Step) GetDescription() (string, error)

GetDescription returns a description of the step. Every step must have this property.

func (*Step) GetMixinName

func (s *Step) GetMixinName() string

func (*Step) Validate

func (s *Step) Validate(m *Manifest) error

type Steps

type Steps []*Step

func (Steps) Validate

func (s Steps) Validate(m *Manifest) error

Jump to

Keyboard shortcuts

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