datastore

package
v0.45.4-rc2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Operation to find the field is equal to the specified value.
	OperatorEqual = iota + 1
	// Operation to find the field isn't equal to the specified value.
	OperatorNotEqual
	// Operation to find ones that contain any one of the multiple values.
	OperatorIn
	// Operation to find ones that do not contain any of the specified multiple values.
	OperatorNotIn
	// Operation to find ones the field is greater than the specified value.
	OperatorGreaterThan
	// Operation to find ones the field is greater or equal than the specified value.
	OperatorGreaterThanOrEqual
	// Operation to find ones the field is less than the specified value.
	OperatorLessThan
	// Operation to find ones the field is less or equal than the specified value.
	OperatorLessThanOrEqual
	// Operation to find ones that have a specified value in its array.
	OperatorContains
)

Variables

View Source
var (
	ErrNotFound        = errors.New("not found")
	ErrInvalidArgument = errors.New("invalid argument")
	ErrAlreadyExists   = errors.New("already exists")
	ErrInvalidCursor   = errors.New("invalid cursor")
	ErrIteratorDone    = errors.New("iterator is done")
	ErrInternal        = errors.New("internal")
	ErrUnimplemented   = errors.New("unimplemented")
	ErrUnsupported     = errors.New("unsupported")
	ErrUserDefined     = errors.New("user defined error")
)

Functions

This section is empty.

Types

type APIKeyStore

type APIKeyStore interface {
	Add(ctx context.Context, k *model.APIKey) error
	Get(ctx context.Context, id string) (*model.APIKey, error)
	List(ctx context.Context, opts ListOptions) ([]*model.APIKey, error)
	Disable(ctx context.Context, id, projectID string) error
	UpdateLastUsedAt(ctx context.Context, id string, time int64) error
}

func NewAPIKeyStore

func NewAPIKeyStore(ds DataStore, c Commander) APIKeyStore

type ApplicationStore

type ApplicationStore interface {
	Add(ctx context.Context, app *model.Application) error
	Get(ctx context.Context, id string) (*model.Application, error)
	List(ctx context.Context, opts ListOptions) ([]*model.Application, string, error)
	Delete(ctx context.Context, id string) error
	Enable(ctx context.Context, id string) error
	Disable(ctx context.Context, id string) error
	UpdateSyncState(ctx context.Context, id string, syncState *model.ApplicationSyncState) error
	UpdateMostRecentDeployment(ctx context.Context, id string, status model.DeploymentStatus, deployment *model.ApplicationDeploymentReference) error
	UpdateConfigFilename(ctx context.Context, id, configFilename string) error
	UpdateDeployingStatus(ctx context.Context, id string, deploying bool) error
	UpdateBasicInfo(ctx context.Context, id, name, description string, labels map[string]string) error
	UpdateConfiguration(ctx context.Context, id, pipedID, platformProvider, configFilename string) error
	UpdatePlatformProvider(ctx context.Context, id string, provider string) error
}

func NewApplicationStore

func NewApplicationStore(ds DataStore, c Commander) ApplicationStore

type Collection added in v0.24.1

type Collection interface {
	Kind() string
	Factory() Factory
}

type CommandStore

type CommandStore interface {
	Add(ctx context.Context, cmd *model.Command) error
	Get(ctx context.Context, id string) (*model.Command, error)
	List(ctx context.Context, opts ListOptions) ([]*model.Command, error)
	UpdateStatus(ctx context.Context, id string, status model.CommandStatus, metadata map[string]string, handledAt int64) error
}

func NewCommandStore

func NewCommandStore(ds DataStore, c Commander) CommandStore

type Commander added in v0.26.0

type Commander string
const (
	// TestCommander indicates that the writer is test.
	// This writer is dedicated for testing.
	TestCommander Commander = "test"
	// WebCommander indicates that the writer is web.
	WebCommander Commander = "web"
	// PipectlCommander indicates that the writer is pipectl.
	PipectlCommander Commander = "pipectl"
	// PipedCommander indicates that the writer is piped.
	PipedCommander Commander = "piped"
	// OpsCommander indicates that the writer is ops component.
	OpsCommander Commander = "ops"
)

type DataStore

type DataStore interface {
	// Find finds the documents matched given criteria.
	Find(ctx context.Context, col Collection, opts ListOptions) (Iterator, error)
	// Get gets one document specified with ID, and unmarshal it to typed struct.
	// If the document can not be found in datastore, ErrNotFound will be returned.
	Get(ctx context.Context, col Collection, id string, entity interface{}) error
	// Create saves a new entity to the datastore.
	// If an entity with the same ID is already existing, ErrAlreadyExists will be returned.
	Create(ctx context.Context, col Collection, id string, entity interface{}) error
	// Update updates an existing entity in the datastore.
	// If updating entity was not found in the datastore, ErrNotFound will be returned.
	Update(ctx context.Context, col Collection, id string, updater Updater) error
	// Close closes datastore resources held by the client.
	Close() error
}

type DeploymentChainStore

type DeploymentChainStore interface {
	Add(ctx context.Context, d *model.DeploymentChain) error
	Get(ctx context.Context, id string) (*model.DeploymentChain, error)
	List(ctx context.Context, opts ListOptions) ([]*model.DeploymentChain, string, error)
	AddNodeDeployment(ctx context.Context, chainID string, deployment *model.Deployment) error
	UpdateNodeDeploymentStatus(ctx context.Context, chainID string, blockIndex uint32, deploymentID string, status model.DeploymentStatus, reason string) error
}

func NewDeploymentChainStore

func NewDeploymentChainStore(ds DataStore, c Commander) DeploymentChainStore

type DeploymentStore

type DeploymentStore interface {
	Add(ctx context.Context, d *model.Deployment) error
	Get(ctx context.Context, id string) (*model.Deployment, error)
	List(ctx context.Context, opts ListOptions) ([]*model.Deployment, string, error)
	UpdateToPlanned(ctx context.Context, id, summary, reason, runningCommitHash, runningConfigFilename, version string, versions []*model.ArtifactVersion, stages []*model.PipelineStage) error
	UpdateToCompleted(ctx context.Context, id string, status model.DeploymentStatus, stageStatuses map[string]model.StageStatus, reason string, completedAt int64) error
	UpdateStatus(ctx context.Context, id string, status model.DeploymentStatus, reason string) error
	UpdateStageStatus(ctx context.Context, id, stageID string, status model.StageStatus, reason string, requires []string, visible bool, retriedCount int32, completedAt int64) error
	UpdateMetadata(ctx context.Context, id string, metadata map[string]string) error
	UpdateStageMetadata(ctx context.Context, deploymentID, stageID string, metadata map[string]string) error
}

func NewDeploymentStore

func NewDeploymentStore(ds DataStore, c Commander) DeploymentStore

type EventStore

type EventStore interface {
	Add(ctx context.Context, e model.Event) error
	List(ctx context.Context, opts ListOptions) ([]*model.Event, string, error)
	UpdateStatus(ctx context.Context, eventID string, status model.EventStatus, statusDescription string) error
}

func NewEventStore

func NewEventStore(ds DataStore, c Commander) EventStore

type Factory

type Factory func() interface{}

type Iterator

type Iterator interface {
	Next(dst interface{}) error
	Cursor() (string, error)
}

type ListFilter

type ListFilter struct {
	Field    string
	Operator Operator
	Value    interface{}
}

type ListOptions

type ListOptions struct {
	Limit   int
	Filters []ListFilter
	Orders  []Order
	Cursor  string
}

type MockCollection added in v0.24.1

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

MockCollection is a mock of Collection interface.

func NewMockCollection added in v0.24.1

func NewMockCollection(ctrl *gomock.Controller) *MockCollection

NewMockCollection creates a new mock instance.

func (*MockCollection) EXPECT added in v0.24.1

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockCollection) Factory added in v0.24.1

func (m *MockCollection) Factory() Factory

Factory mocks base method.

func (*MockCollection) Kind added in v0.24.1

func (m *MockCollection) Kind() string

Kind mocks base method.

type MockCollectionMockRecorder added in v0.24.1

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

MockCollectionMockRecorder is the mock recorder for MockCollection.

func (*MockCollectionMockRecorder) Factory added in v0.24.1

func (mr *MockCollectionMockRecorder) Factory() *gomock.Call

Factory indicates an expected call of Factory.

func (*MockCollectionMockRecorder) Kind added in v0.24.1

Kind indicates an expected call of Kind.

type MockDataStore

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

MockDataStore is a mock of DataStore interface.

func NewMockDataStore

func NewMockDataStore(ctrl *gomock.Controller) *MockDataStore

NewMockDataStore creates a new mock instance.

func (*MockDataStore) Close

func (m *MockDataStore) Close() error

Close mocks base method.

func (*MockDataStore) Create

func (m *MockDataStore) Create(ctx context.Context, col Collection, id string, entity interface{}) error

Create mocks base method.

func (*MockDataStore) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockDataStore) Find

func (m *MockDataStore) Find(ctx context.Context, col Collection, opts ListOptions) (Iterator, error)

Find mocks base method.

func (*MockDataStore) Get

func (m *MockDataStore) Get(ctx context.Context, col Collection, id string, entity interface{}) error

Get mocks base method.

func (*MockDataStore) Update

func (m *MockDataStore) Update(ctx context.Context, col Collection, id string, updater Updater) error

Update mocks base method.

type MockDataStoreMockRecorder

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

MockDataStoreMockRecorder is the mock recorder for MockDataStore.

func (*MockDataStoreMockRecorder) Close

func (mr *MockDataStoreMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close.

func (*MockDataStoreMockRecorder) Create

func (mr *MockDataStoreMockRecorder) Create(ctx, col, id, entity interface{}) *gomock.Call

Create indicates an expected call of Create.

func (*MockDataStoreMockRecorder) Find

func (mr *MockDataStoreMockRecorder) Find(ctx, col, opts interface{}) *gomock.Call

Find indicates an expected call of Find.

func (*MockDataStoreMockRecorder) Get

func (mr *MockDataStoreMockRecorder) Get(ctx, col, id, entity interface{}) *gomock.Call

Get indicates an expected call of Get.

func (*MockDataStoreMockRecorder) Update

func (mr *MockDataStoreMockRecorder) Update(ctx, col, id, updater interface{}) *gomock.Call

Update indicates an expected call of Update.

type MockIterator

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

MockIterator is a mock of Iterator interface.

func NewMockIterator

func NewMockIterator(ctrl *gomock.Controller) *MockIterator

NewMockIterator creates a new mock instance.

func (*MockIterator) Cursor

func (m *MockIterator) Cursor() (string, error)

Cursor mocks base method.

func (*MockIterator) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockIterator) Next

func (m *MockIterator) Next(dst interface{}) error

Next mocks base method.

type MockIteratorMockRecorder

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

MockIteratorMockRecorder is the mock recorder for MockIterator.

func (*MockIteratorMockRecorder) Cursor

func (mr *MockIteratorMockRecorder) Cursor() *gomock.Call

Cursor indicates an expected call of Cursor.

func (*MockIteratorMockRecorder) Next

func (mr *MockIteratorMockRecorder) Next(dst interface{}) *gomock.Call

Next indicates an expected call of Next.

type Operator

type Operator int

func (Operator) IsNumericOperator added in v0.27.0

func (o Operator) IsNumericOperator() bool

type Order

type Order struct {
	Field     string
	Direction OrderDirection
}

type OrderDirection

type OrderDirection int
const (
	// Asc sorts results from smallest to largest.
	Asc OrderDirection = iota + 1
	// Desc sorts results from largest to smallest.
	Desc
)

type PipedStore

type PipedStore interface {
	Add(ctx context.Context, piped *model.Piped) error
	Get(ctx context.Context, id string) (*model.Piped, error)
	List(ctx context.Context, opts ListOptions) ([]*model.Piped, error)
	UpdateInfo(ctx context.Context, id, name, desc string) error
	EnablePiped(ctx context.Context, id string) error
	DisablePiped(ctx context.Context, id string) error
	UpdateDesiredVersion(ctx context.Context, id, version string) error
	UpdateMetadata(ctx context.Context, id, version, config string, pps []*model.Piped_PlatformProvider, repos []*model.ApplicationGitRepository, se *model.Piped_SecretEncryption, startedAt int64) error
	AddKey(ctx context.Context, id, keyHash, creator string, createdAt time.Time) error
	DeleteOldKeys(ctx context.Context, id string) error
}

func NewPipedStore

func NewPipedStore(ds DataStore, c Commander) PipedStore

type ProjectStore

type ProjectStore interface {
	Add(ctx context.Context, proj *model.Project) error
	Get(ctx context.Context, id string) (*model.Project, error)
	List(ctx context.Context, opts ListOptions) ([]model.Project, error)
	UpdateProjectStaticAdmin(ctx context.Context, id, username, password string) error
	EnableStaticAdmin(ctx context.Context, id string) error
	DisableStaticAdmin(ctx context.Context, id string) error
	UpdateProjectSSOConfig(ctx context.Context, id string, sso *model.ProjectSSOConfig) error
	UpdateProjectRBACConfig(ctx context.Context, id string, rbac *model.ProjectRBACConfig) error
	AddProjectRBACRole(ctx context.Context, id, name string, policies []*model.ProjectRBACPolicy) error
	UpdateProjectRBACRole(ctx context.Context, id, name string, policies []*model.ProjectRBACPolicy) error
	DeleteProjectRBACRole(ctx context.Context, id, name string) error
	AddProjectUserGroup(ctx context.Context, id, sso, role string) error
	DeleteProjectUserGroup(ctx context.Context, id, sso string) error
}

func NewProjectStore

func NewProjectStore(ds DataStore, c Commander) ProjectStore

type Shard added in v0.26.0

type Shard string
const (
	// ClientShard indicates that object will be stored in client (web or pipectl) used shard.
	ClientShard Shard = "client"
	// AgentShard indicates that object will be stored in agent (piped) used shard.
	AgentShard Shard = "agent"
	// OpsShard indicates that object will be stored in ops used shard.
	OpsShard Shard = "ops"
)

type ShardDecoder added in v0.27.0

type ShardDecoder interface {
	// Decode unmarshals all given raw data parts to a given entity e.
	Decode(e interface{}, parts map[Shard][]byte) error
}

type ShardEncoder added in v0.27.0

type ShardEncoder interface {
	// Encode accepts an object as its input and returns a map which key is the shard and
	// value is the raw data which should be stored under the key shard.
	Encode(e interface{}) (map[Shard][]byte, error)
}

type ShardStorable added in v0.26.0

type ShardStorable interface {
	// ListInUsedShards returns a list of shard which be used to store object of current collection.
	ListInUsedShards() []Shard
	// GetUpdatableShard returns shard which should be referred to on Updating object of current collection.
	// datastore.ErrUnsupported will be returned if there is no such file name exist.
	GetUpdatableShard() (Shard, error)
}

type Updater

type Updater func(interface{}) error

Directories

Path Synopsis
Package datastoretest is a generated GoMock package.
Package datastoretest is a generated GoMock package.

Jump to

Keyboard shortcuts

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