Documentation ¶
Overview ¶
See an example of implementation: pkg/storage/plugins/mongodb package
Index ¶
- func CreateListFiler(namespace string, name string, labels map[string]string) bson.M
- type AggregateOptions
- type CountOptions
- type Document
- type EnsureIndexOptions
- type ErrNotFound
- type FindOptions
- type GetOptions
- type Index
- type InsertOptions
- type PatchOptions
- type PluginAdapter
- func (a PluginAdapter) Aggregate(collection string, opts AggregateOptions, out interface{}) error
- func (a PluginAdapter) Close() error
- func (a PluginAdapter) Connect() error
- func (a PluginAdapter) Count(collection string, opts CountOptions) (int64, error)
- func (a PluginAdapter) EnsureIndex(opts EnsureIndexOptions) error
- func (a PluginAdapter) Find(collection string, opts FindOptions, out interface{}) error
- func (a PluginAdapter) FindOne(collection string, opts FindOptions, out interface{}) error
- func (a PluginAdapter) Get(collection string, opts GetOptions, out interface{}) error
- func (a PluginAdapter) Insert(collection string, opts InsertOptions) error
- func (a PluginAdapter) Patch(collection string, opts PatchOptions) error
- func (a PluginAdapter) Remove(collection string, opts RemoveOptions) error
- func (a PluginAdapter) Update(collection string, opts UpdateOptions) error
- type Provider
- type RemoveOptions
- type Schema
- type Store
- type TestStore
- type UpdateOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 interface{} }
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 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 interface{} }
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 Document ¶ added in v1.0.1
type Document interface {
// DefaultDocumentFilter is the default filter to match the curent document.
DefaultDocumentFilter() interface{}
}
Document represents a stored Porter document with accessor methods to make persistence more straightforward.
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
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 interface{} // 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 interface{} }
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) ToPluginOptions ¶
func (o GetOptions) ToPluginOptions() FindOptions
ToPluginOptions 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 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 interface{} // Transformation is set of instructions to modify matching // documents. Transformation interface{} }
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.StoragePlugin) PluginAdapter
NewPluginAdapter wraps the specified storage plugin.
func (PluginAdapter) Aggregate ¶ added in v1.0.1
func (a PluginAdapter) Aggregate(collection string, opts AggregateOptions, out interface{}) error
func (PluginAdapter) Close ¶ added in v1.0.1
func (a PluginAdapter) Close() error
func (PluginAdapter) Connect ¶
func (a PluginAdapter) Connect() error
func (PluginAdapter) Count ¶ added in v1.0.1
func (a PluginAdapter) Count(collection string, opts CountOptions) (int64, error)
func (PluginAdapter) EnsureIndex ¶ added in v1.0.1
func (a PluginAdapter) EnsureIndex(opts EnsureIndexOptions) error
func (PluginAdapter) Find ¶ added in v1.0.1
func (a PluginAdapter) Find(collection string, opts FindOptions, out interface{}) error
func (PluginAdapter) FindOne ¶ added in v1.0.1
func (a PluginAdapter) FindOne(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(collection string, opts GetOptions, out interface{}) error
func (PluginAdapter) Insert ¶ added in v1.0.1
func (a PluginAdapter) Insert(collection string, opts InsertOptions) error
func (PluginAdapter) Patch ¶ added in v1.0.1
func (a PluginAdapter) Patch(collection string, opts PatchOptions) error
func (PluginAdapter) Remove ¶ added in v1.0.1
func (a PluginAdapter) Remove(collection string, opts RemoveOptions) error
func (PluginAdapter) Update ¶ added in v1.0.1
func (a PluginAdapter) Update(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() error // Migrate executes a migration on any/all of Porter's storage sub-systems. Migrate() (string, 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 interface{} // 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 Schema ¶
type Schema struct { ID string `json:"_id"` // Installations is the schema for the installation documents. Installations schema.Version `json:"installations"` // Claims is the schema for the old CNAB claim spec. DEPRECATED. Claims schema.Version `json:"claims,omitempty"` // Credentials is the schema for the credential spec documents. Credentials schema.Version `json:"credentials"` // Parameters is the schema for the parameter spec documents. Parameters schema.Version `json:"parameters"` }
func (Schema) DefaultDocumentFilter ¶ added in v1.0.1
func (s Schema) DefaultDocumentFilter() interface{}
type Store ¶ added in v1.0.1
type Store interface { // Connect establishes a connection to the storage backend. // Safe to call multiple times, the existing connection is reused. Connect() error // Close the connection to the storage backend. Close() error // Aggregate executes a pipeline and returns the results. Aggregate(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(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(opts EnsureIndexOptions) error // Find queries a collection, optionally projecting a subset of fields, into // the specified out value. Find(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(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(collection string, opts GetOptions, out interface{}) error // Insert a set of documents into a collection. Insert(collection string, opts InsertOptions) error // Patch applies a transformation to matching documents. Patch(collection string, opts PatchOptions) error // Remove matching documents from a collection. Remove(collection string, opts RemoveOptions) error // Update matching documents with the specified replacement document. Update(collection string, opts UpdateOptions) error }
Store is an interface for managing Porter documents.
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 *context.TestContext) TestStore
NewTestStore creates a store suitable for unit tests.
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 interface{} // 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)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
migrations package handles migrating Porter's stored documents when necessary.
|
migrations package handles migrating Porter's stored documents when necessary. |
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. |
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. |