migrations

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

migrations package handles migrating Porter's stored documents when necessary.

Index

Constants

View Source
const (
	// CollectionConfig is the collection that stores Porter configuration documents
	// such as the storage schema.
	CollectionConfig = "config"
)

Variables

This section is empty.

Functions

func WriteSchema

func WriteSchema(ctx context.Context, store storage.Store) (storage.Schema, error)

WriteSchema updates the database to indicate that it conforms with the current database schema.

Types

type LegacyPluginAdapter

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

LegacyPluginAdapter can connect to a legacy Porter v0.38 storage plugin to retrieve data to migrate to the current version of Porter.

func NewLegacyPluginAdapter

func NewLegacyPluginAdapter(c *config.Config, oldPorterHome string, storageName string) *LegacyPluginAdapter

func (*LegacyPluginAdapter) Close

func (m *LegacyPluginAdapter) Close() error

func (*LegacyPluginAdapter) Connect

func (m *LegacyPluginAdapter) Connect(ctx context.Context) error

Connect loads the legacy plugin specified by the source storage account.

func (*LegacyPluginAdapter) List

func (m *LegacyPluginAdapter) List(ctx context.Context, itemType string, group string) ([]string, error)

func (*LegacyPluginAdapter) Read

func (m *LegacyPluginAdapter) Read(ctx context.Context, itemType string, name string) ([]byte, error)

type Manager

type Manager struct {
	*config.Config
	// contains filtered or unexported fields
}

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

func NewManager

func NewManager(c *config.Config, storage storage.Store) *Manager

NewManager creates a storage manager for a backing datastore.

func (*Manager) Aggregate

func (m *Manager) Aggregate(ctx context.Context, collection string, opts storage.AggregateOptions, out interface{}) error

func (*Manager) Close

func (m *Manager) Close() error

func (*Manager) Connect

func (m *Manager) Connect(ctx context.Context) error

Connect initializes storage manager for use. The manager itself is responsible for ensuring it was called. Close is called automatically when the manager is used by Porter.

func (*Manager) Count

func (m *Manager) Count(ctx context.Context, collection string, opts storage.CountOptions) (int64, error)

func (*Manager) EnsureIndex

func (m *Manager) EnsureIndex(ctx context.Context, opts storage.EnsureIndexOptions) error

func (*Manager) Find

func (m *Manager) Find(ctx context.Context, collection string, opts storage.FindOptions, out interface{}) error

func (*Manager) FindOne

func (m *Manager) FindOne(ctx context.Context, collection string, opts storage.FindOptions, out interface{}) error

func (*Manager) Get

func (m *Manager) Get(ctx context.Context, collection string, opts storage.GetOptions, out interface{}) error

func (*Manager) Initialize

func (m *Manager) Initialize(sanitizer *storage.Sanitizer)

Initialize configures the storage manager with additional configuration that wasn't available when the manager instance was created.

func (*Manager) Insert

func (m *Manager) Insert(ctx context.Context, collection string, opts storage.InsertOptions) error

func (*Manager) Migrate

func (m *Manager) Migrate(ctx context.Context, opts storage.MigrateOptions) error

Migrate executes a migration on any/all of Porter's storage sub-systems. You must call Initialize before calling Migrate.

func (*Manager) Patch

func (m *Manager) Patch(ctx context.Context, collection string, opts storage.PatchOptions) error

func (*Manager) Remove

func (m *Manager) Remove(ctx context.Context, collection string, opts storage.RemoveOptions) error

func (*Manager) Update

func (m *Manager) Update(ctx context.Context, collection string, opts storage.UpdateOptions) error

func (*Manager) WriteSchema

func (m *Manager) WriteSchema(ctx context.Context) error

WriteSchema updates the database to indicate that it conforms with the current database schema.

type Migration

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

Migration can connect to a legacy Porter v0.38 storage plugin migrate the data in the specified account into a target account compatible with the current version of Porter.

func NewMigration

func NewMigration(c *config.Config, opts storage.MigrateOptions, destStore storage.Store, sanitizer *storage.Sanitizer) *Migration

func (*Migration) Close

func (m *Migration) Close() error

func (*Migration) Connect

func (m *Migration) Connect(ctx context.Context) error

Connect loads the legacy plugin specified by the source storage account.

func (*Migration) Migrate

func (m *Migration) Migrate(ctx context.Context) (storage.Schema, error)

type SourceClaim

type SourceClaim struct {
	// SchemaVersion is the version of the claim schema.
	SchemaVersion cnab.SchemaVersion `json:"schemaVersion"`

	// ID of the claim.
	ID string `json:"id"`

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

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

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

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

	// Bundle is the definition of the bundle.
	Bundle bundle.Bundle `json:"bundle"`

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

	// Parameters are the key/value pairs that were passed in during the operation.
	Parameters map[string]interface{} `json:"parameters,omitempty"`

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

SourceClaim represents the file format of claim documents from v0.38

type SourceCredentialSet

type SourceCredentialSet struct {
	// SchemaVersion is the version of the credential-set schema.
	SchemaVersion cnab.SchemaVersion `json:"schemaVersion" yaml:"schemaVersion"`

	// Name is the name of the credentialset.
	Name string `json:"name" yaml:"name"`

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

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

	// Credentials is a list of credential specs.
	Credentials []valuesource.Strategy `json:"credentials" yaml:"credentials"`
}

SourceCredentialSet represents the file format of credential set documents from v0.38

type SourceParameterSet

type SourceParameterSet struct {
	// SchemaVersion is the version of the parameter-set schema.
	SchemaVersion cnab.SchemaVersion `json:"schemaVersion" yaml:"schemaVersion"`

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

	// Created timestamp of the parameter set.
	Created time.Time `json:"created" yaml:"created"`

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

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

SourceParameterSet represents the file format of credential set documents from v0.38

type SourceResult

type SourceResult struct {
	// Id of the result.
	ID string `json:"id"`

	// ClaimId associated with the claim that generated the result.
	ClaimID string `json:"claimId"`

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

	// 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,omitempty"`

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

SourceResult represents the file format of result documents from v0.38

type SourceSchema

type SourceSchema struct {
	Claims      cnab.SchemaVersion `json:"claims"`
	Credentials cnab.SchemaVersion `json:"credentials"`
	Parameters  cnab.SchemaVersion `json:"parameters"`
}

SourceSchema represents the file format of Porter's v0.38 schema document

type TestManager

type TestManager struct {
	*Manager
	// contains filtered or unexported fields
}

func NewTestManager

func NewTestManager(c *config.TestConfig) *TestManager

func (*TestManager) Close

func (m *TestManager) Close() error

func (*TestManager) SetSchema

func (m *TestManager) SetSchema(schema storage.Schema)

SetSchema allows tests to pre-emptively set the schema document.

Directories

Path Synopsis
Package crudstore supports reading data out of a legacy porter storage plugin
Package crudstore supports reading data out of a legacy porter storage plugin
Package testhelpers contains helper functions for testing the pkg/storage/migrations package.
Package testhelpers contains helper functions for testing the pkg/storage/migrations package.

Jump to

Keyboard shortcuts

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