datastore

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package datastore is a generated GoMock package.

Index

Constants

This section is empty.

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")
)
View Source
var (
	DeploymentToPlannedUpdater = func(summary, statusReason, runningCommitHash, version string, stages []*model.PipelineStage) func(*model.Deployment) error {
		return func(d *model.Deployment) error {
			d.Status = model.DeploymentStatus_DEPLOYMENT_PLANNED
			d.Summary = summary
			d.StatusReason = statusReason
			d.RunningCommitHash = runningCommitHash
			d.Version = version
			d.Stages = stages
			return nil
		}
	}

	DeploymentStatusUpdater = func(status model.DeploymentStatus, statusReason string) func(*model.Deployment) error {
		return func(d *model.Deployment) error {
			d.Status = status
			d.StatusReason = statusReason
			return nil
		}
	}

	DeploymentToCompletedUpdater = func(status model.DeploymentStatus, statuses map[string]model.StageStatus, statusReason string, completedAt int64) func(*model.Deployment) error {
		return func(d *model.Deployment) error {
			if !model.IsCompletedDeployment(status) {
				return fmt.Errorf("deployment status %s is not completed value: %w", status, ErrInvalidArgument)
			}

			d.Status = status
			d.StatusReason = statusReason
			d.CompletedAt = completedAt
			for i := range d.Stages {
				stageID := d.Stages[i].Id
				if status, ok := statuses[stageID]; ok {
					d.Stages[i].Status = status
				}
			}
			return nil
		}
	}

	StageStatusChangedUpdater = func(stageID string, status model.StageStatus, statusReason string, requires []string, visible bool, retriedCount int32, completedAt int64) func(*model.Deployment) error {
		return func(d *model.Deployment) error {
			for _, s := range d.Stages {
				if s.Id == stageID {
					s.Status = status
					s.StatusReason = statusReason
					if len(requires) > 0 {
						s.Requires = requires
					}
					s.Visible = visible
					s.RetriedCount = retriedCount
					s.CompletedAt = completedAt
					return nil
				}
			}
			return fmt.Errorf("stage id %s not found: %w", stageID, ErrInvalidArgument)
		}
	}
)
View Source
var (
	CommandHandledUpdater = func(status model.CommandStatus, metadata map[string]string, handledAt int64) func(*model.Command) error {
		return func(cmd *model.Command) error {
			cmd.Status = status
			cmd.Metadata = metadata
			cmd.HandledAt = handledAt
			return nil
		}
	}
)
View Source
var (
	PipedMetadataUpdater = func(
		cloudProviders []*model.Piped_CloudProvider,
		repos []*model.ApplicationGitRepository,
		status model.Piped_ConnectionStatus,
		sse *model.Piped_SealedSecretEncryption,
		version string,
		startedAt int64,
	) func(piped *model.Piped) error {

		return func(piped *model.Piped) error {
			piped.CloudProviders = cloudProviders
			piped.Repositories = repos
			piped.Status = status
			if sse != nil {
				piped.SealedSecretEncryption = sse
			}
			piped.Version = version
			piped.StartedAt = startedAt
			return nil
		}
	}
)

Functions

This section is empty.

Types

type ApplicationStore

type ApplicationStore interface {
	AddApplication(ctx context.Context, app *model.Application) error
	EnableApplication(ctx context.Context, id string) error
	DisableApplication(ctx context.Context, id string) error
	GetApplication(ctx context.Context, id string) (*model.Application, error)
	ListApplications(ctx context.Context, opts ListOptions) ([]*model.Application, error)
	UpdateApplication(ctx context.Context, id string, updater func(*model.Application) error) error
	PutApplicationSyncState(ctx context.Context, id string, syncState *model.ApplicationSyncState) error
	PutApplicationMostRecentDeployment(ctx context.Context, id string, status model.DeploymentStatus, deployment *model.ApplicationDeploymentReference) error
}

func NewApplicationStore

func NewApplicationStore(ds DataStore) ApplicationStore

type CommandStore

type CommandStore interface {
	AddCommand(ctx context.Context, cmd *model.Command) error
	UpdateCommand(ctx context.Context, id string, updater func(piped *model.Command) error) error
	ListCommands(ctx context.Context, opts ListOptions) ([]*model.Command, error)
	GetCommand(ctx context.Context, id string) (*model.Command, error)
}

func NewCommandStore

func NewCommandStore(ds DataStore) CommandStore

type DataStore

type DataStore interface {
	// Find finds the documents matched given criteria.
	Find(ctx context.Context, kind string, 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, kind, 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, kind, id string, entity interface{}) error
	// Put saves the entity into the datastore with a given id and kind.
	// Put does not check the existence of the entity with same ID.
	Put(ctx context.Context, kind, 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, kind, id string, factory Factory, updater Updater) error
	// Close closes datastore resources held by the client.
	Close() error
}

type DeploymentStore

type DeploymentStore interface {
	AddDeployment(ctx context.Context, d *model.Deployment) error
	UpdateDeployment(ctx context.Context, id string, updater func(*model.Deployment) error) error
	PutDeploymentMetadata(ctx context.Context, id string, metadata map[string]string) error
	PutDeploymentStageMetadata(ctx context.Context, deploymentID, stageID string, metadata map[string]string) error
	ListDeployments(ctx context.Context, opts ListOptions) ([]*model.Deployment, error)
	GetDeployment(ctx context.Context, id string) (*model.Deployment, error)
}

func NewDeploymentStore

func NewDeploymentStore(ds DataStore) DeploymentStore

type EnvironmentStore

type EnvironmentStore interface {
	AddEnvironment(ctx context.Context, env *model.Environment) error
	GetEnvironment(ctx context.Context, id string) (*model.Environment, error)
	ListEnvironments(ctx context.Context, opts ListOptions) ([]*model.Environment, error)
}

func NewEnvironmentStore

func NewEnvironmentStore(ds DataStore) EnvironmentStore

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 string
	Value    interface{}
}

type ListOptions

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

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, kind, 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, kind string, opts ListOptions) (Iterator, error)

Find mocks base method

func (*MockDataStore) Get

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

Get mocks base method

func (*MockDataStore) Put

func (m *MockDataStore) Put(ctx context.Context, kind, id string, entity interface{}) error

Put mocks base method

func (*MockDataStore) Update

func (m *MockDataStore) Update(ctx context.Context, kind, id string, factory Factory, 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, kind, id, entity interface{}) *gomock.Call

Create indicates an expected call of Create

func (*MockDataStoreMockRecorder) Find

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

Find indicates an expected call of Find

func (*MockDataStoreMockRecorder) Get

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

Get indicates an expected call of Get

func (*MockDataStoreMockRecorder) Put

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

Put indicates an expected call of Put

func (*MockDataStoreMockRecorder) Update

func (mr *MockDataStoreMockRecorder) Update(ctx, kind, id, factory, 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 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 PipedStatsStore

type PipedStatsStore interface {
	AddPipedStats(ctx context.Context, ps *model.PipedStats) error
	ListPipedStatss(ctx context.Context, opts ListOptions) ([]model.PipedStats, error)
}

func NewPipedStatsStore

func NewPipedStatsStore(ds DataStore) PipedStatsStore

type PipedStore

type PipedStore interface {
	AddPiped(ctx context.Context, piped *model.Piped) error
	GetPiped(ctx context.Context, id string) (*model.Piped, error)
	ListPipeds(ctx context.Context, opts ListOptions) ([]*model.Piped, error)
	UpdatePiped(ctx context.Context, id string, updater func(piped *model.Piped) error) error
	EnablePiped(ctx context.Context, id string) error
	DisablePiped(ctx context.Context, id string) error
	AddKey(ctx context.Context, id, keyHash, creator string, createdAt time.Time) error
}

func NewPipedStore

func NewPipedStore(ds DataStore) PipedStore

type ProjectStore

type ProjectStore interface {
	AddProject(ctx context.Context, proj *model.Project) error
	UpdateProject(ctx context.Context, id string, updater func(project *model.Project) error) 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, sso *model.ProjectRBACConfig) error
	GetProject(ctx context.Context, id string) (*model.Project, error)
	ListProjects(ctx context.Context, opts ListOptions) ([]model.Project, error)
}

func NewProjectStore

func NewProjectStore(ds DataStore) ProjectStore

type Updater

type Updater func(interface{}) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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