storage

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Overview

See an example of implementation: pkg/storage/plugins/mongodb package

Index

Constants

View Source
const (
	CollectionInstallations = "installations"
	CollectionRuns          = "runs"
	CollectionResults       = "results"
	CollectionOutputs       = "outputs"
)
View Source
const (
	// SchemaTypeCredentialSet is the default schemaType value for CredentialSet resources
	SchemaTypeCredentialSet = "CredentialSet"

	// SchemaTypeInstallation is the default schemaType value for Installation resources
	SchemaTypeInstallation = "Installation"

	// SchemaTypeParameterSet is the default schemaType value for ParameterSet resources
	SchemaTypeParameterSet = "ParameterSet"

	// DefaultCredentialSetSchemaVersion represents the version associated with the schema
	// credential set documents.
	DefaultCredentialSetSchemaVersion = cnab.SchemaVersion("1.0.1")

	// DefaultInstallationSchemaVersion represents the version associated with the schema
	// for all installation documents: installations, runs, results and outputs.
	DefaultInstallationSchemaVersion = cnab.SchemaVersion("1.0.2")

	// DefaultParameterSetSchemaVersion represents the version associated with the schema
	//	// for parameter set documents.
	DefaultParameterSetSchemaVersion = cnab.SchemaVersion("1.0.1")
)
View Source
const (
	CollectionCredentials = "credentials"
)
View Source
const (
	CollectionParameters = "parameters"
)
View Source
const (
	INTERNAL_PARAMETERER_SET = "internal-parameter-set"
)

Variables

View Source
var (
	// DefaultCredentialSetSemverSchemaVersion is the semver representation of the DefaultCredentialSetSchemaVersion  that is suitable for doing semver comparisons.
	DefaultCredentialSetSemverSchemaVersion = semver.MustParse(string(DefaultCredentialSetSchemaVersion))

	// DefaultInstallationSemverSchemaVersion is the semver representation of the DefaultInstallationSchemaVersion that is suitable for doing semver comparisons.
	DefaultInstallationSemverSchemaVersion = semver.MustParse(string(DefaultInstallationSchemaVersion))

	// DefaultParameterSetSemverSchemaVersion is the semver representation of the DefaultParameterSetSchemaVersion  that is suitable for doing semver comparisons.
	DefaultParameterSetSemverSchemaVersion = semver.MustParse(string(DefaultParameterSetSchemaVersion))

	// SupportedCredentialSetSchemaVersions represents the set of allowed schema versions for CredentialSet documents.
	SupportedCredentialSetSchemaVersions = schema.MustParseConstraint("1.0.1")

	// SupportedInstallationSchemaVersions represents the set of allowed schema versions for Installation documents.
	SupportedInstallationSchemaVersions = schema.MustParseConstraint("1.0.2")

	// SupportedParameterSetSchemaVersions represents the set of allowed schema versions for ParameterSet documents.
	SupportedParameterSetSchemaVersions = schema.MustParseConstraint("1.0.1")
)

Functions

func EnsureCredentialIndices added in v1.0.1

func EnsureCredentialIndices(ctx context.Context, store Store) error

EnsureCredentialIndices creates indices on the credentials collection.

func EnsureInstallationIndices added in v1.0.1

func EnsureInstallationIndices(ctx context.Context, store Store) error

EnsureInstallationIndices created indices on the installations collection.

func EnsureParameterIndices added in v1.0.1

func EnsureParameterIndices(ctx context.Context, store Store) error

EnsureParameterIndices creates indices on the parameters collection.

func ParseVariableAssignments added in v1.0.1

func ParseVariableAssignments(params []string) (map[string]string, error)

ParseVariableAssignments converts a string array of variable assignments into a map of keys and values Example: [a=b c=abc1232=== d=banana d=pineapple] becomes map[a:b c:abc1232=== d:[pineapple]]

func Validate added in v1.0.1

func Validate(given secrets.Set, spec map[string]bundle.Credential, action string) error

Validate compares the given credentials with the spec.

This will result in an error only when the following conditions are true: - a credential in the spec is not present in the given set - the credential is required - the credential applies to the specified action

It is allowed for spec to specify both an env var and a file. In such case, if the given set provides either, it will be considered valid.

func ValueStrategy added in v1.0.1

func ValueStrategy(name string, value string) secrets.Strategy

ValueStrategy is the strategy used to store non-sensitive parameters

Types

type AggregateOptions added in v1.0.1

type AggregateOptions struct {
	// Pipeline document to aggregate, filter, and shape the results.
	// See https://docs.mongodb.com/manual/reference/operator/aggregation-pipeline/
	Pipeline []bson.D
}

AggregateOptions is the set of options available to the Aggregate operation on any storage provider.

func (AggregateOptions) ToPluginOptions added in v1.0.1

func (o AggregateOptions) ToPluginOptions(collection string) plugins.AggregateOptions

type BundleDocument added in v1.0.1

type BundleDocument bundle.Bundle

BundleDocument is the storage representation of a Bundle in mongo (as a string containing quoted json).

func (BundleDocument) MarshalJSON added in v1.0.1

func (b BundleDocument) MarshalJSON() ([]byte, error)

MarshalJSON converts the bundle to a json string.

func (*BundleDocument) UnmarshalJSON added in v1.0.1

func (b *BundleDocument) UnmarshalJSON(data []byte) error

UnmarshalJSON converts the bundle from a json string.

type CountOptions added in v1.0.1

type CountOptions struct {
	// Query is a query filter document
	// See https://docs.mongodb.com/manual/core/document/#std-label-document-query-filter
	Filter bson.M
}

CountOptions is the set of options available to the Count operation on any storage provider.

func (CountOptions) ToPluginOptions added in v1.0.1

func (o CountOptions) ToPluginOptions(collection string) plugins.CountOptions

type CredentialSet added in v1.0.1

type CredentialSet struct {
	CredentialSetSpec `yaml:",inline"`
	Status            CredentialSetStatus `json:"status" yaml:"status" toml:"status"`
}

CredentialSet defines mappings from a credential needed by a bundle to where to look for it when the bundle is run. For example: Bundle needs Azure storage connection string, and it should look for it in an environment variable named `AZURE_STORATE_CONNECTION_STRING` or a key named `dev-conn`.

Porter discourages storing the value of the credential directly, though it is possible. Instead, Porter encourages the best practice of defining mappings in the credential sets, and then storing the values in secret stores such as a key/value store like Hashicorp Vault, or Azure Key Vault. See the get.porter.sh/porter/pkg/secrets package for more on how Porter handles accessing secrets.

func NewCredentialSet added in v1.0.1

func NewCredentialSet(namespace string, name string, creds ...secrets.Strategy) CredentialSet

NewCredentialSet creates a new CredentialSet with the required fields initialized.

func (CredentialSet) DefaultDocumentFilter added in v1.0.1

func (s CredentialSet) DefaultDocumentFilter() map[string]interface{}

func (CredentialSet) String added in v1.0.1

func (s CredentialSet) String() string

func (*CredentialSet) Validate added in v1.0.1

func (s *CredentialSet) Validate(ctx context.Context, strategy schema.CheckStrategy) error

type CredentialSetProvider added in v1.0.1

type CredentialSetProvider interface {
	GetDataStore() Store
	ResolveAll(ctx context.Context, creds CredentialSet) (secrets.Set, error)
	Validate(ctx context.Context, creds CredentialSet) error
	InsertCredentialSet(ctx context.Context, creds CredentialSet) error
	ListCredentialSets(ctx context.Context, listOptions ListOptions) ([]CredentialSet, error)
	GetCredentialSet(ctx context.Context, namespace string, name string) (CredentialSet, error)
	UpdateCredentialSet(ctx context.Context, creds CredentialSet) error
	RemoveCredentialSet(ctx context.Context, namespace string, name string) error
	UpsertCredentialSet(ctx context.Context, creds CredentialSet) error
}

CredentialSetProvider is Porter's interface for managing and resolving credentials.

type CredentialSetSpec added in v1.0.1

type CredentialSetSpec struct {
	// SchemaType is the type of resource in the current document.
	SchemaType string `json:"schemaType,omitempty" yaml:"schemaType,omitempty" toml:"schemaType,omitempty"`

	// SchemaVersion is the version of the credential-set schema.
	SchemaVersion cnab.SchemaVersion `json:"schemaVersion" yaml:"schemaVersion" toml:"schemaVersion"`

	// Namespace to which the credential set is scoped.
	Namespace string `json:"namespace" yaml:"namespace" toml:"namespace"`

	// Name of the credential set.
	Name string `json:"name" yaml:"name" toml:"name"`

	// Labels applied to the credential set.
	Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty" toml:"labels,omitempty"`

	// Credentials is a list of credential resolution strategies.
	Credentials []secrets.Strategy `json:"credentials" yaml:"credentials" toml:"credentials"`
}

CredentialSetSpec represents the set of user-modifiable fields on a CredentialSet.

type CredentialSetStatus added in v1.0.1

type CredentialSetStatus struct {
	// Created timestamp.
	Created time.Time `json:"created" yaml:"created" toml:"created"`

	// Modified timestamp.
	Modified time.Time `json:"modified" yaml:"modified" toml:"modified"`
}

CredentialSetStatus contains additional status metadata that has been set by Porter.

type CredentialStore added in v1.0.1

type CredentialStore struct {
	Documents Store
	Secrets   secrets.Store
}

CredentialStore is a wrapper around Porter's datastore providing typed access and additional business logic around credential sets, usually referred to as "credentials" as a shorthand.

func NewCredentialStore added in v1.0.1

func NewCredentialStore(storage Store, secrets secrets.Store) *CredentialStore

func (CredentialStore) GetCredentialSet added in v1.0.1

func (s CredentialStore) GetCredentialSet(ctx context.Context, namespace string, name string) (CredentialSet, error)

func (CredentialStore) GetDataStore added in v1.0.1

func (s CredentialStore) GetDataStore() Store

func (CredentialStore) InsertCredentialSet added in v1.0.1

func (s CredentialStore) InsertCredentialSet(ctx context.Context, creds CredentialSet) error

func (CredentialStore) ListCredentialSets added in v1.0.1

func (s CredentialStore) ListCredentialSets(ctx context.Context, listOptions ListOptions) ([]CredentialSet, error)

func (CredentialStore) RemoveCredentialSet added in v1.0.1

func (s CredentialStore) RemoveCredentialSet(ctx context.Context, namespace string, name string) error

func (CredentialStore) ResolveAll added in v1.0.1

func (s CredentialStore) ResolveAll(ctx context.Context, creds CredentialSet) (secrets.Set, error)

func (CredentialStore) UpdateCredentialSet added in v1.0.1

func (s CredentialStore) UpdateCredentialSet(ctx context.Context, creds CredentialSet) error

func (CredentialStore) UpsertCredentialSet added in v1.0.1

func (s CredentialStore) UpsertCredentialSet(ctx context.Context, creds CredentialSet) error

func (CredentialStore) Validate added in v1.0.1

func (s CredentialStore) Validate(ctx context.Context, creds CredentialSet) error

type Document added in v1.0.1

type Document interface {
	// DefaultDocumentFilter is the default filter to match the current document.
	DefaultDocumentFilter() map[string]interface{}
}

Document represents a stored Porter document with accessor methods to make persistence more straightforward.

type EncryptionHandler added in v1.0.1

type EncryptionHandler func([]byte) ([]byte, error)

EncryptionHandler is a function that transforms data by encrypting or decrypting it.

type EnsureIndexOptions added in v1.0.1

type EnsureIndexOptions struct {
	// Indices to create if not found.
	Indices []Index
}

EnsureIndexOptions is the set of options available to the EnsureIndex operation.

func (EnsureIndexOptions) ToPluginOptions added in v1.0.1

func (o EnsureIndexOptions) ToPluginOptions() plugins.EnsureIndexOptions

type ErrNotFound added in v1.0.1

type ErrNotFound struct {
	Collection string
	Item       string
}

ErrNotFound indicates that the requested document was not found. You can test for this error using errors.Is(err, storage.ErrNotFound{})

func (ErrNotFound) Error added in v1.0.1

func (e ErrNotFound) Error() string

func (ErrNotFound) Is added in v1.0.1

func (e ErrNotFound) Is(err error) bool

type FindOptions added in v1.0.1

type FindOptions struct {
	// Sort is a list of field names by which the results should be sorted.
	// Prefix a field with "-" to sort in reverse order.
	Sort []string

	// Skip is the number of results to skip past and exclude from the results.
	Skip int64

	// Limit is the number of results to return.
	Limit int64

	// Filter specifies a filter the results.
	// See https://docs.mongodb.com/manual/core/document/#std-label-document-query-filter
	Filter bson.M

	// Select is a projection document. The entire document is returned by default.
	// See https://docs.mongodb.com/manual/tutorial/project-fields-from-query-results/
	Select bson.D
}

FindOptions is the set of options available to the StorageProtocol.Find operation.

func (FindOptions) ToPluginOptions added in v1.0.1

func (o FindOptions) ToPluginOptions(collection string) plugins.FindOptions

type GetOptions added in v1.0.1

type GetOptions struct {
	// ID of the document to retrieve.
	ID string

	// Name of the document to retrieve.
	Name string

	// Namespace of the document to retrieve.
	Namespace string
}

GetOptions is the set of options available for the Get operation. Documents can be retrieved by either ID or Namespace + Name.

func (GetOptions) ToFindOptions added in v1.0.1

func (o GetOptions) ToFindOptions() FindOptions

ToFindOptions converts from the convenience method Get to FindOne.

type Index added in v1.0.1

type Index struct {
	// Collection name to which the index applies.
	Collection string

	// Keys describes the fields and their sort order.
	// Example: ["namespace", "name", "-timestamp"]
	Keys []string

	// Unique specifies if the index should enforce that the indexed fields for each document are unique.
	Unique bool
}

Index on a collection.

type InsertOptions added in v1.0.1

type InsertOptions struct {
	// Documents is a set of documents to insert.
	Documents []interface{}
}

InsertOptions is the set of options for the StorageProtocol.Insert operation.

func (InsertOptions) ToPluginOptions added in v1.0.1

func (o InsertOptions) ToPluginOptions(collection string) (plugins.InsertOptions, error)

type Installation added in v1.0.1

type Installation struct {
	// ID is the unique identifier for an installation record.
	ID string `json:"id"`

	InstallationSpec

	// Status of the installation.
	Status InstallationStatus `json:"status,omitempty"`
}

func NewInstallation added in v1.0.1

func NewInstallation(namespace string, name string) Installation

func (Installation) AddToTrace added in v1.0.1

func (i Installation) AddToTrace(ctx context.Context)

func (*Installation) ApplyResult added in v1.0.1

func (i *Installation) ApplyResult(run Run, result Result)

ApplyResult updates cached status data on the installation from the last bundle run.

func (Installation) DefaultDocumentFilter added in v1.0.1

func (i Installation) DefaultDocumentFilter() map[string]interface{}

func (Installation) IsDefined added in v1.0.1

func (i Installation) IsDefined() bool

IsDefined checks if the installation is has already been defined but not installed yet.

func (Installation) IsInstalled added in v1.0.1

func (i Installation) IsInstalled() bool

IsInstalled checks if the installation is currently installed.

func (Installation) IsUninstalled added in v1.0.1

func (i Installation) IsUninstalled() bool

IsUninstalled checks if the installation has been uninstalled.

func (Installation) NewInternalParameterSet added in v1.0.1

func (i Installation) NewInternalParameterSet(params ...secrets.Strategy) ParameterSet

NewInternalParameterSet creates a new ParameterSet that's used to store parameter overrides with the required fields initialized.

func (Installation) NewRun added in v1.0.1

func (i Installation) NewRun(action string) Run

NewRun creates a run of the current bundle.

func (*Installation) SetLabel added in v1.0.1

func (i *Installation) SetLabel(key string, value string)

SetLabel on the installation.

func (*Installation) TrackBundle added in v1.0.1

func (i *Installation) TrackBundle(ref cnab.OCIReference)

TrackBundle updates the bundle that the installation is tracking.

type InstallationProvider added in v1.0.1

type InstallationProvider interface {
	// InsertInstallation saves a new Installation document.
	InsertInstallation(ctx context.Context, installation Installation) error

	// InsertRun saves a new Run document.
	InsertRun(ctx context.Context, run Run) error

	// InsertResult saves a new Result document.
	InsertResult(ctx context.Context, result Result) error

	// InsertOutput saves a new Output document.
	InsertOutput(ctx context.Context, output Output) error

	// UpdateInstallation saves changes to an existing Installation document.
	UpdateInstallation(ctx context.Context, installation Installation) error

	// UpsertRun saves changes a Run document, creating it if it doesn't already exist.
	UpsertRun(ctx context.Context, run Run) error

	// UpsertInstallation saves an Installation document, creating it if it doesn't already exist.
	UpsertInstallation(ctx context.Context, installation Installation) error

	// FindInstallations applies the find operation against installations collection
	// using the specified options.
	FindInstallations(ctx context.Context, opts FindOptions) ([]Installation, error)

	// GetInstallation retrieves an Installation document by name.
	GetInstallation(ctx context.Context, namespace string, name string) (Installation, error)

	// ListInstallations returns Installations sorted in ascending order by the namespace and then name.
	ListInstallations(ctx context.Context, listOption ListOptions) ([]Installation, error)

	// ListRuns returns Run documents sorted in ascending order by ID.
	ListRuns(ctx context.Context, namespace string, installation string) ([]Run, map[string][]Result, error)

	// ListResults returns Result documents sorted in ascending order by ID.
	ListResults(ctx context.Context, runID string) ([]Result, error)

	// ListOutputs returns Output documents sorted in ascending order by name.
	ListOutputs(ctx context.Context, resultID string) ([]Output, error)

	// GetRun returns a Run document by ID.
	GetRun(ctx context.Context, id string) (Run, error)

	// GetResult returns a Result document by ID.
	GetResult(ctx context.Context, id string) (Result, error)

	// GetLastRun returns the last run of an Installation.
	GetLastRun(ctx context.Context, namespace string, installation string) (Run, error)

	// GetLastOutput returns the most recent value (last) of the specified
	// Output associated with the installation.
	GetLastOutput(ctx context.Context, namespace string, installation string, name string) (Output, error)

	// GetLastOutputs returns the most recent (last) value of each Output
	// associated with the installation.
	GetLastOutputs(ctx context.Context, namespace string, installation string) (Outputs, error)

	// RemoveInstallation by its name.
	RemoveInstallation(ctx context.Context, namespace string, name string) error

	// GetLogs returns the logs from the specified Run.
	GetLogs(ctx context.Context, runID string) (logs string, hasLogs bool, err error)

	// GetLastLogs returns the logs from the last run of an Installation.
	GetLastLogs(ctx context.Context, namespace string, installation string) (logs string, hasLogs bool, err error)
}

InstallationProvider is an interface for interacting with Porter's claim data.

type InstallationSpec added in v1.0.2

type InstallationSpec struct {
	// SchemaType indicates the type of resource imported from a file.
	SchemaType string `json:"schemaType"`

	// SchemaVersion is the version of the installation state schema.
	SchemaVersion cnab.SchemaVersion `json:"schemaVersion"`

	// Name of the installation. Immutable.
	Name string `json:"name"`

	// Namespace in which the installation is defined.
	Namespace string `json:"namespace"`

	// Uninstalled specifies if the installation isn't used anymore and should be uninstalled.
	Uninstalled bool `json:"uninstalled,omitempty"`

	// Bundle specifies the bundle reference to use with the installation.
	Bundle OCIReferenceParts `json:"bundle"`

	// Custom extension data applicable to a given runtime.
	// TODO(carolynvs): remove and populate in ToCNAB when we firm up the spec
	Custom interface{} `json:"custom,omitempty"`

	// Labels applied to the installation.
	Labels map[string]string `json:"labels,omitempty"`

	// CredentialSets that should be included when the bundle is reconciled.
	CredentialSets []string `json:"credentialSets,omitempty"`

	// ParameterSets that should be included when the bundle is reconciled.
	ParameterSets []string `json:"parameterSets,omitempty"`

	// Parameters specified by the user through overrides.
	// Does not include defaults, or values resolved from parameter sources.
	Parameters ParameterSet `json:"parameters,omitempty"`

	// Status of the installation.
	Status InstallationStatus `json:"status,omitempty"`
}

InstallationSpec contains installation fields that represent the desired state of the installation.

func (*InstallationSpec) Apply added in v1.0.2

func (i *InstallationSpec) Apply(input InstallationSpec)

Apply user-provided changes to an existing installation. Only updates fields that users are allowed to modify. For example, Name, Namespace and Status cannot be modified.

func (InstallationSpec) String added in v1.0.2

func (i InstallationSpec) String() string

func (*InstallationSpec) Validate added in v1.0.8

func (i *InstallationSpec) Validate(ctx context.Context, strategy schema.CheckStrategy) error

Validate the installation document and report the first error.

type InstallationStatus added in v1.0.1

type InstallationStatus struct {
	// RunID of the bundle execution that last altered the installation status.
	RunID string `json:"runId" yaml:"runId" toml:"runId"`

	// Action of the bundle run that last informed the installation status.
	Action string `json:"action" yaml:"action" toml:"action"`

	// ResultID of the result that last informed the installation status.
	ResultID string `json:"resultId" yaml:"resultId" toml:"resultId"`

	// ResultStatus is the status of the result that last informed the installation status.
	ResultStatus string `json:"resultStatus" yaml:"resultStatus" toml:"resultStatus"`

	// Created timestamp of the installation.
	Created time.Time `json:"created" yaml:"created" toml:"created"`

	// Modified timestamp of the installation.
	Modified time.Time `json:"modified" yaml:"modified" toml:"modified"`

	// Installed indicates if the install action has successfully completed for this installation.
	// Once that state is reached, Porter should not allow it to be reinstalled as a protection from installations
	// being overwritten.
	Installed *time.Time `json:"installed" yaml:"installed" toml:"installed"`

	// Uninstalled indicates if the installation has successfully completed the uninstall action.
	// Once that state is reached, Porter should not allow further stateful actions.
	Uninstalled *time.Time `json:"uninstalled" yaml:"uninstalled" toml:"uninstalled"`

	// BundleReference of the bundle that last altered the installation state.
	BundleReference string `json:"bundleReference" yaml:"bundleReference" toml:"bundleReference"`

	// BundleVersion is the version of the bundle that last altered the installation state.
	BundleVersion string `json:"bundleVersion" yaml:"bundleVersion" toml:"bundleVersion"`

	// BundleDigest is the digest of the bundle that last altered the installation state.
	BundleDigest string `json:"bundleDigest" yaml:"bundleDigest" toml:"bundleDigest"`
}

InstallationStatus's purpose is to assist with making porter list be able to display everything with a single database query. Do not replicate data available on Run and Result here.

type InstallationStore added in v1.0.1

type InstallationStore struct {
	// contains filtered or unexported fields
}

InstallationStore is a persistent store for installation documents.

func NewInstallationStore added in v1.0.1

func NewInstallationStore(datastore Store) InstallationStore

NewInstallationStore creates a persistent store for installations using the specified backing datastore.

func (InstallationStore) FindInstallations added in v1.0.1

func (s InstallationStore) FindInstallations(ctx context.Context, findOpts FindOptions) ([]Installation, error)

func (InstallationStore) GetInstallation added in v1.0.1

func (s InstallationStore) GetInstallation(ctx context.Context, namespace string, name string) (Installation, error)

func (InstallationStore) GetLastLogs added in v1.0.1

func (s InstallationStore) GetLastLogs(ctx context.Context, namespace string, installation string) (string, bool, error)

func (InstallationStore) GetLastOutput added in v1.0.1

func (s InstallationStore) GetLastOutput(ctx context.Context, namespace string, installation string, name string) (Output, error)

func (InstallationStore) GetLastOutputs added in v1.0.1

func (s InstallationStore) GetLastOutputs(ctx context.Context, namespace string, installation string) (Outputs, error)

func (InstallationStore) GetLastRun added in v1.0.1

func (s InstallationStore) GetLastRun(ctx context.Context, namespace string, installation string) (Run, error)

func (InstallationStore) GetLogs added in v1.0.1

func (s InstallationStore) GetLogs(ctx context.Context, runID string) (string, bool, error)

func (InstallationStore) GetResult added in v1.0.1

func (s InstallationStore) GetResult(ctx context.Context, id string) (Result, error)

func (InstallationStore) GetRun added in v1.0.1

func (s InstallationStore) GetRun(ctx context.Context, id string) (Run, error)

func (InstallationStore) InsertInstallation added in v1.0.1

func (s InstallationStore) InsertInstallation(ctx context.Context, installation Installation) error

func (InstallationStore) InsertOutput added in v1.0.1

func (s InstallationStore) InsertOutput(ctx context.Context, output Output) error

func (InstallationStore) InsertResult added in v1.0.1

func (s InstallationStore) InsertResult(ctx context.Context, result Result) error

func (InstallationStore) InsertRun added in v1.0.1

func (s InstallationStore) InsertRun(ctx context.Context, run Run) error

func (InstallationStore) ListInstallations added in v1.0.1

func (s InstallationStore) ListInstallations(ctx context.Context, listOptions ListOptions) ([]Installation, error)

func (InstallationStore) ListOutputs added in v1.0.1

func (s InstallationStore) ListOutputs(ctx context.Context, resultID string) ([]Output, error)

func (InstallationStore) ListResults added in v1.0.1

func (s InstallationStore) ListResults(ctx context.Context, runID string) ([]Result, error)

func (InstallationStore) ListRuns added in v1.0.1

func (s InstallationStore) ListRuns(ctx context.Context, namespace string, installation string) ([]Run, map[string][]Result, error)

func (InstallationStore) RemoveInstallation added in v1.0.1

func (s InstallationStore) RemoveInstallation(ctx context.Context, namespace string, name string) error

RemoveInstallation and all associated data.

func (InstallationStore) UpdateInstallation added in v1.0.1

func (s InstallationStore) UpdateInstallation(ctx context.Context, installation Installation) error

func (InstallationStore) UpsertInstallation added in v1.0.1

func (s InstallationStore) UpsertInstallation(ctx context.Context, installation Installation) error

func (InstallationStore) UpsertRun added in v1.0.1

func (s InstallationStore) UpsertRun(ctx context.Context, run Run) error

type ListOptions added in v1.0.1

type ListOptions struct {
	// Namespace in which the particular result list is defined.
	Namespace string

	// Name specifies whether the result list name contain the specified substring.
	Name string

	// Labels is used to filter result list based on a key-value pair.
	Labels map[string]string

	// Skip is the number of results to skip past and exclude from the results.
	Skip int64

	// Limit is the number of results to return.
	Limit int64
}

ListOptions is the set of options available to the list operation on any storage provider.

func (ListOptions) ToFindOptions added in v1.0.1

func (o ListOptions) ToFindOptions() FindOptions

ToFindOptions builds a query for a list of documents with these conditions: * sorted in ascending order by namespace first and then name * filtered by matching namespace, name contains substring, and labels contain all matches * skipped and limited to a certain number of result

type MigrateOptions added in v1.0.1

type MigrateOptions struct {
	// OldHome is the path to the PORTER_HOME directory for the previous version of porter.
	OldHome string

	// OldStorageAccount is the name of the storage account configured in MigrateOptions.OldHome
	// where records should be migrated from.
	OldStorageAccount string

	// NewNamespace is the namespace into which records should be imported.
	NewNamespace string
}

MigrateOptions are the set of available options to configure a storage data migration from an older version of Porter into the current version.

type OCIReferenceParts added in v1.0.1

type OCIReferenceParts struct {
	// Repository is the OCI repository of the bundle.
	// For example, "getporter/porter-hello".
	Repository string `json:"repository,omitempty" yaml:"repository,omitempty" toml:"repository,omitempty"`

	// Version is the current version of the bundle.
	// For example, "1.2.3".
	Version string `json:"version,omitempty" yaml:"version,omitempty" toml:"version,omitempty"`

	// Digest is the current digest of the bundle.
	// For example, "sha256:abc123"
	Digest string `json:"digest,omitempty" yaml:"digest,omitempty" toml:"digest,omitempty"`

	// Tag is the OCI tag of the bundle.
	// For example, "latest".
	Tag string `json:"tag,omitempty" yaml:"tag,omitempty" toml:"tag,omitempty"`
}

OCIReferenceParts is our storage representation of cnab.OCIReference with the parts explicitly stored separately so that they are queryable.

func (OCIReferenceParts) GetBundleReference added in v1.0.1

func (r OCIReferenceParts) GetBundleReference() (cnab.OCIReference, bool, error)

type Output added in v1.0.1

type Output struct {
	SchemaVersion cnab.SchemaVersion `json:"schemaVersion"`
	Name          string             `json:"name"`
	Namespace     string             `json:"namespace"`
	Installation  string             `json:"installation"`
	RunID         string             `json:"runId"`
	ResultID      string             `json:"resultId"`

	// Key holds the secret key to retrieve a sensitive output value
	Key   string `json:"key"`
	Value []byte `json:"value"`
}

func (Output) DefaultDocumentFilter added in v1.0.1

func (o Output) DefaultDocumentFilter() map[string]interface{}

func (Output) GetSchema added in v1.0.1

func (o Output) GetSchema(b cnab.ExtendedBundle) (definition.Schema, bool)

GetSchema returns the schema for the output from the specified bundle, or false if the schema is not defined.

type Outputs added in v1.0.1

type Outputs struct {
	// contains filtered or unexported fields
}

func NewOutputs added in v1.0.1

func NewOutputs(outputs []Output) Outputs

func (Outputs) GetByIndex added in v1.0.1

func (o Outputs) GetByIndex(i int) (Output, bool)

func (Outputs) GetByName added in v1.0.1

func (o Outputs) GetByName(name string) (Output, bool)

func (Outputs) Len added in v1.0.1

func (o Outputs) Len() int

func (Outputs) Less added in v1.0.1

func (o Outputs) Less(i, j int) bool

func (Outputs) Swap added in v1.0.1

func (o Outputs) Swap(i, j int)

func (Outputs) Value added in v1.0.1

func (o Outputs) Value() []Output

Value returns a list of outputs.

type ParameterSet added in v1.0.1

type ParameterSet struct {
	ParameterSetSpec `yaml:",inline"`
	Status           ParameterSetStatus `json:"status" yaml:"status" toml:"status"`
}

ParameterSet represents a collection of parameters and their sources/strategies for value resolution

func LinkSensitiveParametersToSecrets added in v1.0.1

func LinkSensitiveParametersToSecrets(pset ParameterSet, bun cnab.ExtendedBundle, id string) ParameterSet

LinkSensitiveParametersToSecrets creates a reference key for sensitive data and replace the sensitive value with the reference key. The id argument is used to associate the reference key with the corresponding run or installation record in porter's database.

func NewInternalParameterSet added in v1.0.1

func NewInternalParameterSet(namespace string, name string, params ...secrets.Strategy) ParameterSet

NewInternalParameterSet creates a new internal ParameterSet with the required fields initialized.

func NewParameterSet added in v1.0.1

func NewParameterSet(namespace string, name string, params ...secrets.Strategy) ParameterSet

NewParameterSet creates a new ParameterSet with the required fields initialized.

func (ParameterSet) DefaultDocumentFilter added in v1.0.1

func (s ParameterSet) DefaultDocumentFilter() map[string]interface{}

func (ParameterSet) String added in v1.0.1

func (s ParameterSet) String() string

func (*ParameterSet) Validate added in v1.0.1

func (s *ParameterSet) Validate(ctx context.Context, strategy schema.CheckStrategy) error

type ParameterSetProvider added in v1.0.1

type ParameterSetProvider interface {
	GetDataStore() Store

	// ResolveAll parameter values in the parameter set.
	ResolveAll(ctx context.Context, params ParameterSet) (secrets.Set, error)

	// Validate the parameter set is defined properly.
	Validate(ctx context.Context, params ParameterSet) error

	InsertParameterSet(ctx context.Context, params ParameterSet) error
	ListParameterSets(ctx context.Context, listOptions ListOptions) ([]ParameterSet, error)
	GetParameterSet(ctx context.Context, namespace string, name string) (ParameterSet, error)
	UpdateParameterSet(ctx context.Context, params ParameterSet) error
	UpsertParameterSet(ctx context.Context, params ParameterSet) error
	RemoveParameterSet(ctx context.Context, namespace string, name string) error
}

ParameterSetProvider interface for managing sets of parameters.

type ParameterSetSpec added in v1.0.1

type ParameterSetSpec struct {
	// SchemaType helps when we export the definition so editors can detect the type of document, it's not used by porter.
	SchemaType string `json:"schemaType,omitempty" yaml:"schemaType,omitempty"`

	// SchemaVersion is the version of the parameter-set schema.
	SchemaVersion cnab.SchemaVersion `json:"schemaVersion" yaml:"schemaVersion" toml:"schemaVersion"`

	// Namespace to which the credential set is scoped.
	Namespace string `json:"namespace" yaml:"namespace" toml:"namespace"`

	// Name is the name of the parameter set.
	Name string `json:"name" yaml:"name" toml:"name"`

	// Labels applied to the parameter set.
	Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty" toml:"labels,omitempty"`

	// Parameters is a list of parameter specs.
	Parameters []secrets.Strategy `json:"parameters" yaml:"parameters" toml:"parameters"`
}

ParameterSetSpec represents the set of user-modifiable fields on a ParameterSet.

type ParameterSetStatus added in v1.0.1

type ParameterSetStatus struct {
	// Created timestamp of the parameter set.
	Created time.Time `json:"created" yaml:"created" toml:"created"`

	// Modified timestamp of the parameter set.
	Modified time.Time `json:"modified" yaml:"modified" toml:"modified"`
}

ParameterSetStatus contains additional status metadata that has been set by Porter.

type ParameterStore added in v1.0.1

type ParameterStore struct {
	Documents Store
	Secrets   secrets.Store
}

ParameterStore provides access to parameter sets by instantiating plugins that implement CRUD storage.

func NewParameterStore added in v1.0.1

func NewParameterStore(storage Store, secrets secrets.Store) *ParameterStore

func (ParameterStore) GetDataStore added in v1.0.1

func (s ParameterStore) GetDataStore() Store

func (ParameterStore) GetParameterSet added in v1.0.1

func (s ParameterStore) GetParameterSet(ctx context.Context, namespace string, name string) (ParameterSet, error)

func (ParameterStore) InsertParameterSet added in v1.0.1

func (s ParameterStore) InsertParameterSet(ctx context.Context, params ParameterSet) error

func (ParameterStore) ListParameterSets added in v1.0.1

func (s ParameterStore) ListParameterSets(ctx context.Context, listOptions ListOptions) ([]ParameterSet, error)

func (ParameterStore) RemoveParameterSet added in v1.0.1

func (s ParameterStore) RemoveParameterSet(ctx context.Context, namespace string, name string) error

func (ParameterStore) ResolveAll added in v1.0.1

func (s ParameterStore) ResolveAll(ctx context.Context, params ParameterSet) (secrets.Set, error)

func (ParameterStore) UpdateParameterSet added in v1.0.1

func (s ParameterStore) UpdateParameterSet(ctx context.Context, params ParameterSet) error

func (ParameterStore) UpsertParameterSet added in v1.0.1

func (s ParameterStore) UpsertParameterSet(ctx context.Context, params ParameterSet) error

func (ParameterStore) Validate added in v1.0.1

func (s ParameterStore) Validate(ctx context.Context, params ParameterSet) error

type PatchOptions added in v1.0.1

type PatchOptions struct {
	// Query is a query filter document
	// See https://docs.mongodb.com/manual/core/document/#std-label-document-query-filter
	QueryDocument bson.M

	// Transformation is set of instructions to modify matching
	// documents.
	Transformation bson.D
}

PatchOptions is the set of options for the StorageProtocol.Patch operation.

func (PatchOptions) ToPluginOptions added in v1.0.1

func (o PatchOptions) ToPluginOptions(collection string) plugins.PatchOptions

type PluginAdapter added in v1.0.1

type PluginAdapter struct {
	// contains filtered or unexported fields
}

PluginAdapter converts between the low-level plugin.StorageProtocol which operates on bson documents, and the document types stored by Porter which are marshaled using json.

Specifically it handles converting from bson.Raw to the type specified by ResultType on plugin.ResultOptions so that you can just cast the result to the specified type safely.

func NewPluginAdapter added in v1.0.1

func NewPluginAdapter(plugin plugins.StorageProtocol) PluginAdapter

NewPluginAdapter wraps the specified storage plugin.

func (PluginAdapter) Aggregate added in v1.0.1

func (a PluginAdapter) Aggregate(ctx context.Context, collection string, opts AggregateOptions, out interface{}) error

func (PluginAdapter) Close added in v1.0.1

func (a PluginAdapter) Close() error

func (PluginAdapter) Count added in v1.0.1

func (a PluginAdapter) Count(ctx context.Context, collection string, opts CountOptions) (int64, error)

func (PluginAdapter) EnsureIndex added in v1.0.1

func (a PluginAdapter) EnsureIndex(ctx context.Context, opts EnsureIndexOptions) error

func (PluginAdapter) Find added in v1.0.1

func (a PluginAdapter) Find(ctx context.Context, collection string, opts FindOptions, out interface{}) error

func (PluginAdapter) FindOne added in v1.0.1

func (a PluginAdapter) FindOne(ctx context.Context, collection string, opts FindOptions, out interface{}) error

FindOne queries a collection and returns the first result, returning ErrNotFound when no results are returned.

func (PluginAdapter) Get added in v1.0.1

func (a PluginAdapter) Get(ctx context.Context, collection string, opts GetOptions, out interface{}) error

func (PluginAdapter) Insert added in v1.0.1

func (a PluginAdapter) Insert(ctx context.Context, collection string, opts InsertOptions) error

func (PluginAdapter) Patch added in v1.0.1

func (a PluginAdapter) Patch(ctx context.Context, collection string, opts PatchOptions) error

func (PluginAdapter) Remove added in v1.0.1

func (a PluginAdapter) Remove(ctx context.Context, collection string, opts RemoveOptions) error

func (PluginAdapter) Update added in v1.0.1

func (a PluginAdapter) Update(ctx context.Context, collection string, opts UpdateOptions) error

type Provider added in v1.0.1

type Provider interface {
	Store

	// WriteSchema persists an up-to-date schema to the underlying storage.
	WriteSchema(ctx context.Context) error

	// Migrate executes a migration on any/all of Porter's storage sub-systems.
	Migrate(ctx context.Context, opts MigrateOptions) error
}

Provider handles high level functions over Porter's storage systems such as migrating data formats.

type RemoveOptions added in v1.0.1

type RemoveOptions struct {
	// Filter is a query filter document
	// See https://docs.mongodb.com/manual/core/document/#std-label-document-query-filter
	Filter bson.M

	// All matching documents should be removed. Defaults to false, which only
	// removes the first matching document.
	All bool

	// ID of the document to remove. This sets the Filter to an _id match using the specified value.
	ID string

	// Name of the document to remove.
	Name string

	// Namespace of the document to remove.
	Namespace string
}

RemoveOptions is the set of options for the StorageProtocol.Remove operation.

func (RemoveOptions) ToPluginOptions added in v1.0.1

func (o RemoveOptions) ToPluginOptions(collection string) plugins.RemoveOptions

type Result added in v1.0.1

type Result struct {
	// SchemaVersion of the document.
	SchemaVersion cnab.SchemaVersion `json:"schemaVersion"`

	// ID of the result.
	ID string `json:"_id"`

	// Created timestamp of the result.
	Created time.Time `json:"created"`

	// Namespace of the installation.
	Namespace string `json:"namespace"`

	// Installation name that owns this result.
	Installation string `json:"installation"`

	// RunID of the run that generated this result.
	RunID string `json:"runId"`

	// Message communicates the outcome of the operation.
	Message string `json:"message,omitempty"`

	// Status of the operation, for example StatusSucceeded.
	Status string `json:"status"`

	// OutputMetadata generated by the operation, mapping from the output names to
	// metadata about the output.
	OutputMetadata cnab.OutputMetadata `json:"outputs"`

	// Custom extension data applicable to a given runtime.
	Custom interface{} `json:"custom,omitempty"`
}

func NewResult added in v1.0.1

func NewResult() Result

func (Result) DefaultDocumentFilter added in v1.0.1

func (r Result) DefaultDocumentFilter() map[string]interface{}

func (Result) NewOutput added in v1.0.1

func (r Result) NewOutput(name string, data []byte) Output

type Run added in v1.0.1

type Run struct {
	// SchemaVersion of the document.
	SchemaVersion cnab.SchemaVersion `json:"schemaVersion"`

	// ID of the Run.
	ID string `json:"_id"`

	// Created timestamp of the Run.
	Created time.Time `json:"created"`

	// Namespace of the installation.
	Namespace string `json:"namespace"`

	// Installation name.
	Installation string `json:"installation"`

	// Revision of the installation.
	Revision string `json:"revision"`

	// Action executed against the installation.
	Action string `json:"action"`

	// Bundle is the definition of the bundle.
	// Bundle has custom marshal logic in MarshalJson.
	Bundle bundle.Bundle `json:"-"`

	// BundleReference is the canonical reference to the bundle used in the action.
	BundleReference string `json:"bundleReference"`

	// BundleDigest is the digest of the bundle.
	// TODO(carolynvs): populate this
	BundleDigest string `json:"bundleDigest"`

	// ParameterOverrides are the key/value parameter overrides (taking precedence over
	// parameters specified in a parameter set) specified during the run.
	ParameterOverrides ParameterSet `json:"parameterOverrides,omitempty"`

	// CredentialSets is a list of the credential set names used during the run.
	CredentialSets []string `json:"credentialSets,omitempty"`

	// ParameterSets is the list of parameter set names used during the run.
	ParameterSets []string `json:"parameterSets,omitempty"`

	// Parameters is the full set of parameters that's being used during the
	// current run.
	// This includes internal parameters, parameter sources, values from parameter sets, etc.
	// Any sensitive data will be sannitized before saving to the database.
	Parameters ParameterSet `json:"parameters,omitempty"`

	// Custom extension data applicable to a given runtime.
	// TODO(carolynvs): remove custom and populate it in ToCNAB
	Custom interface{} `json:"custom"`
}

Run represents the execution of an installation's bundle.

func NewRun added in v1.0.1

func NewRun(namespace string, installation string) Run

NewRun creates a run with default values initialized.

func (Run) DefaultDocumentFilter added in v1.0.1

func (r Run) DefaultDocumentFilter() map[string]interface{}

func (Run) MarshalJSON added in v1.0.1

func (r Run) MarshalJSON() ([]byte, error)

MarshalJSON converts the run to its storage representation in mongo.

func (Run) NewResult added in v1.0.1

func (r Run) NewResult(status string) Result

NewRun creates a result for the current Run.

func (Run) NewResultFrom added in v1.0.1

func (r Run) NewResultFrom(cnabResult cnab.Result) Result

NewResultFrom creates a result from the output of a CNAB run.

func (Run) ShouldRecord added in v1.0.1

func (r Run) ShouldRecord() bool

ShouldRecord the current run in the Installation history. Runs are only recorded for actions that modify the bundle resources, or for stateful actions. Stateless actions do not require an existing installation or credentials, and are for actions such as documentation, dry-run, etc.

func (Run) ToCNAB added in v1.0.1

func (r Run) ToCNAB() cnab.Claim

ToCNAB associated with the Run.

func (Run) TypedParameterValues added in v1.0.1

func (r Run) TypedParameterValues() map[string]interface{}

TypedParameterValues returns parameters values that have been converted to its typed value based on its bundle definition.

func (*Run) UnmarshalJSON added in v1.0.1

func (r *Run) UnmarshalJSON(data []byte) error

UnmarshalJSON converts the run to its storage representation in mongo.

type Sanitizer added in v1.0.1

type Sanitizer struct {
	// contains filtered or unexported fields
}

Sanitizer identifies sensitive data in a database record, and replaces it with a reference to a secret created by the service in an external secret store.

func NewSanitizer added in v1.0.1

func NewSanitizer(parameterstore ParameterSetProvider, secretstore secrets.Store) *Sanitizer

NewSanitizer creates a new service for sanitizing sensitive data and save them to a secret store.

func (*Sanitizer) CleanOutput added in v1.0.1

func (s *Sanitizer) CleanOutput(ctx context.Context, output Output, bun cnab.ExtendedBundle) (Output, error)

CleanOutput clears data that's defined as sensitive on the bundle definition by storing the raw data into a secret store and store it's reference key onto the output record.

func (*Sanitizer) CleanParameters added in v1.0.1

func (s *Sanitizer) CleanParameters(ctx context.Context, dirtyParams []secrets.Strategy, bun cnab.ExtendedBundle, id string) ([]secrets.Strategy, error)

CleanParameters clears out sensitive data in strategized parameter data (overrides provided by the user on an Installation record) and return Sanitized value after saving sensitive data to secrets store. The id argument is used to associate the reference key with the corresponding run or installation record in porter's database.

func (*Sanitizer) CleanRawParameters added in v1.0.1

func (s *Sanitizer) CleanRawParameters(ctx context.Context, params map[string]interface{}, bun cnab.ExtendedBundle, id string) ([]secrets.Strategy, error)

CleanRawParameters clears out sensitive data in raw parameter values (resolved parameter values stored on a Run) before transform the raw value into secret strategies. The id argument is used to associate the reference key with the corresponding run or installation record in porter's database.

func (*Sanitizer) RestoreOutput added in v1.0.1

func (s *Sanitizer) RestoreOutput(ctx context.Context, output Output) (Output, error)

RestoreOutput retrieves the raw output value and return the restored output record.

func (*Sanitizer) RestoreOutputs added in v1.0.1

func (s *Sanitizer) RestoreOutputs(ctx context.Context, o Outputs) (Outputs, error)

RestoreOutputs retrieves all raw output value and return the restored outputs record.

func (*Sanitizer) RestoreParameterSet added in v1.0.1

func (s *Sanitizer) RestoreParameterSet(ctx context.Context, pset ParameterSet, bun cnab.ExtendedBundle) (map[string]interface{}, error)

RestoreParameterSet resolves the raw parameter data from a secrets store.

type Schema

type Schema struct {
	ID string `json:"_id"`

	// Installations is the schema for the installation documents.
	Installations cnab.SchemaVersion `json:"installations"`

	// Credentials is the schema for the credential spec documents.
	Credentials cnab.SchemaVersion `json:"credentials"`

	// Parameters is the schema for the parameter spec documents.
	Parameters cnab.SchemaVersion `json:"parameters"`
}

func NewSchema added in v1.0.1

func NewSchema() Schema

NewSchema creates a schema document with the currently supported version for all subsystems.

func (Schema) DefaultDocumentFilter added in v1.0.1

func (s Schema) DefaultDocumentFilter() map[string]interface{}

func (Schema) IsOutOfDate added in v1.0.1

func (s Schema) IsOutOfDate() bool

func (Schema) ShouldMigrateCredentialSets added in v1.0.1

func (s Schema) ShouldMigrateCredentialSets() bool

ShouldMigrateCredentialSets checks if the minimum version of the Credential set resources in the database is unsupported and requires a migration to work with this version of Porter. Since Porter can support a range of resource versions, this means that the db may have multiple representations of a resource in the database, and will migrate them to the latest support schema version on an as-needed basis.

func (Schema) ShouldMigrateInstallations added in v1.0.1

func (s Schema) ShouldMigrateInstallations() bool

ShouldMigrateInstallations checks if the minimum version of the installation resources in the database is unsupported and requires a migration to work with this version of Porter. Since Porter can support a range of resource versions, this means that the db may have multiple representations of a resource in the database, and will migrate them to the latest support schema version on an as-needed basis.

func (Schema) ShouldMigrateParameterSets added in v1.0.1

func (s Schema) ShouldMigrateParameterSets() bool

ShouldMigrateParameterSets checks if the minimum version of the parameter set resources in the database is unsupported and requires a migration to work with this version of Porter. Since Porter can support a range of resource versions, this means that the db may have multiple representations of a resource in the database, and will migrate them to the latest support schema version on an as-needed basis.

type Store added in v1.0.1

type Store interface {
	// Close the connection to the storage backend.
	Close() error

	// Aggregate executes a pipeline and returns the results.
	Aggregate(ctx context.Context, collection string, opts AggregateOptions, out interface{}) error

	// Count the number of results that match an optional query.
	// When the query is omitted, the entire collection is counted.
	Count(ctx context.Context, collection string, opts CountOptions) (int64, error)

	// EnsureIndex makes sure that the specified index exists as specified.
	// If it does exist with a different definition, the index is recreated.
	EnsureIndex(ctx context.Context, opts EnsureIndexOptions) error

	// Find queries a collection, optionally projecting a subset of fields, into
	// the specified out value.
	Find(ctx context.Context, collection string, opts FindOptions, out interface{}) error

	// FindOne queries a collection, optionally projecting a subset of fields,
	// returning the first result onto the specified out value.
	// Returns ErrNotFound when the query yields no results.
	FindOne(ctx context.Context, collection string, opts FindOptions, out interface{}) error

	// Get the document specified by its ID into the specified out value.
	// This is a convenience wrapper around FindOne for situations where you
	// are retrieving a well-known single document.
	Get(ctx context.Context, collection string, opts GetOptions, out interface{}) error

	// Insert a set of documents into a collection.
	Insert(ctx context.Context, collection string, opts InsertOptions) error

	// Patch applies a transformation to matching documents.
	Patch(ctx context.Context, collection string, opts PatchOptions) error

	// Remove matching documents from a collection.
	Remove(ctx context.Context, collection string, opts RemoveOptions) error

	// Update matching documents with the specified replacement document.
	Update(ctx context.Context, collection string, opts UpdateOptions) error
}

Store is an interface for managing Porter documents.

type TestCredentialSetProvider added in v1.0.1

type TestCredentialSetProvider struct {
	*CredentialStore

	T           *testing.T
	TestContext *portercontext.TestContext
	// TestSecrets allows you to set up secrets for unit testing
	TestSecrets secrets.TestSecretsProvider
	TestStorage Store
}

func NewTestCredentialProvider added in v1.0.1

func NewTestCredentialProvider(t *testing.T) *TestCredentialSetProvider

func NewTestCredentialProviderFor added in v1.0.1

func NewTestCredentialProviderFor(t *testing.T, testStore Store, testSecrets secrets.TestSecretsProvider) *TestCredentialSetProvider

func (TestCredentialSetProvider) AddSecret added in v1.0.1

func (p TestCredentialSetProvider) AddSecret(key string, value string)

func (TestCredentialSetProvider) AddTestCredentials added in v1.0.1

func (p TestCredentialSetProvider) AddTestCredentials(path string)

func (TestCredentialSetProvider) AddTestCredentialsDirectory added in v1.0.1

func (p TestCredentialSetProvider) AddTestCredentialsDirectory(dir string)

func (TestCredentialSetProvider) Close added in v1.0.1

func (p TestCredentialSetProvider) Close() error

func (TestCredentialSetProvider) Load added in v1.0.1

Load a CredentialSet from a test file at a given path.

It does not load the individual credentials.

type TestInstallationProvider added in v1.0.1

type TestInstallationProvider struct {
	InstallationStore
	TestStore
	// contains filtered or unexported fields
}

func NewTestInstallationProvider added in v1.0.1

func NewTestInstallationProvider(t *testing.T) *TestInstallationProvider

func NewTestInstallationProviderFor added in v1.0.1

func NewTestInstallationProviderFor(t *testing.T, testStore TestStore) *TestInstallationProvider

func (*TestInstallationProvider) Close added in v1.0.1

func (p *TestInstallationProvider) Close() error

func (*TestInstallationProvider) CreateInstallation added in v1.0.1

func (p *TestInstallationProvider) CreateInstallation(i Installation, transformations ...func(i *Installation)) Installation

CreateInstallation creates a new test installation and saves it.

func (*TestInstallationProvider) CreateOutput added in v1.0.1

func (p *TestInstallationProvider) CreateOutput(o Output, transformations ...func(o *Output)) Output

CreateOutput creates a new test output and saves it.

func (*TestInstallationProvider) CreateResult added in v1.0.1

func (p *TestInstallationProvider) CreateResult(r Result, transformations ...func(r *Result)) Result

CreateResult creates a new test result and saves it.

func (*TestInstallationProvider) CreateRun added in v1.0.1

func (p *TestInstallationProvider) CreateRun(r Run, transformations ...func(r *Run)) Run

CreateRun creates a new test run and saves it.

func (*TestInstallationProvider) SetMutableInstallationValues added in v1.0.1

func (p *TestInstallationProvider) SetMutableInstallationValues(i *Installation)

func (*TestInstallationProvider) SetMutableResultValues added in v1.0.1

func (p *TestInstallationProvider) SetMutableResultValues(r *Result)

func (*TestInstallationProvider) SetMutableRunValues added in v1.0.1

func (p *TestInstallationProvider) SetMutableRunValues(r *Run)

type TestParameterSetProvider added in v1.0.1

type TestParameterSetProvider struct {
	*ParameterStore

	T *testing.T
	// TestSecrets allows you to set up secrets for unit testing
	TestSecrets   secrets.TestSecretsProvider
	TestDocuments Store
}

func NewTestParameterProvider added in v1.0.1

func NewTestParameterProvider(t *testing.T) *TestParameterSetProvider

func NewTestParameterProviderFor added in v1.0.1

func NewTestParameterProviderFor(t *testing.T, testStore Store, testSecrets secrets.TestSecretsProvider) *TestParameterSetProvider

func (TestParameterSetProvider) AddSecret added in v1.0.1

func (p TestParameterSetProvider) AddSecret(key string, value string)

func (TestParameterSetProvider) AddTestParameters added in v1.0.1

func (p TestParameterSetProvider) AddTestParameters(path string)

func (TestParameterSetProvider) AddTestParametersDirectory added in v1.0.1

func (p TestParameterSetProvider) AddTestParametersDirectory(dir string)

func (TestParameterSetProvider) Close added in v1.0.1

func (p TestParameterSetProvider) Close() error

func (TestParameterSetProvider) Load added in v1.0.1

Load a ParameterSet from a test file at a given path.

It does not load the individual parameters.

type TestStore added in v1.0.1

type TestStore struct {
	PluginAdapter
	// contains filtered or unexported fields
}

func NewTestStore added in v1.0.1

func NewTestStore(tc *config.TestConfig) TestStore

func (TestStore) Close added in v1.0.1

func (s TestStore) Close() error

type UpdateOptions added in v1.0.1

type UpdateOptions struct {
	// Filter is a query filter document. Defaults to filtering by the document id.
	// See https://docs.mongodb.com/manual/core/document/#std-label-document-query-filter
	Filter bson.M

	// Upsert indicates that the document should be inserted if not found
	Upsert bool

	// Document is the replacement document.
	Document interface{}
}

UpdateOptions is the set of options for the StorageProtocol.Update operation.

func (UpdateOptions) ToPluginOptions added in v1.0.1

func (o UpdateOptions) ToPluginOptions(collection string) (plugins.UpdateOptions, error)

Directories

Path Synopsis
migrations package handles migrating Porter's stored documents when necessary.
migrations package handles migrating Porter's stored documents when necessary.
crudstore
Package crudstore supports reading data out of a legacy porter storage plugin
Package crudstore supports reading data out of a legacy porter storage plugin
testhelpers
Package testhelpers contains helper functions for testing the pkg/storage/migrations package.
Package testhelpers contains helper functions for testing the pkg/storage/migrations package.
plugin package contains interfaces for storage plugins.
plugin package contains interfaces for storage plugins.
mongodb_docker
Package mongodb_docker implements the plugins.StorageProtocol interface, storing data using an instance of mongodb running in a container, with the data stored in a docker volume.
Package mongodb_docker implements the plugins.StorageProtocol interface, storing data using an instance of mongodb running in a container, with the data stored in a docker volume.
proto
Package proto is the protobuf definition for the StorageProtocol
Package proto is the protobuf definition for the StorageProtocol
Package pluginstore is an internal Porter package that implements the plugins.StorageProtocol interface via the hashicorp/go-plugins library.
Package pluginstore is an internal Porter package that implements the plugins.StorageProtocol interface via the hashicorp/go-plugins library.

Jump to

Keyboard shortcuts

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