db

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCannotFindContributor = errors.New("cannot find requested contributor")
View Source
var ErrCannotFindPolicy = errors.New("cannot find requested policy")
View Source
var ErrCannotFindProject = errors.New("cannot find requested project")
View Source
var ErrCannotFindRole = errors.New("cannot find requested role")
View Source
var ErrCannotFindSecret = errors.New("cannot find requested secret")
View Source
var ErrCannotFindSuggestion = errors.New("cannot find requested suggestion")
View Source
var ErrCannotFindUser = errors.New("cannot find requested user")
View Source
var ErrDuplicateKey = errors.New("duplicate key")
View Source
var ErrNoRows = errors.New("no rows")

Functions

This section is empty.

Types

type AuditLogDB added in v0.0.2

type AuditLogDB interface {
	Add(context.Context, auditModels.Event) error
	Query(context.Context, QueryAuditLogOptions) ([]auditModels.Event, error)
}

type ConfigDB

type ConfigDB interface {
	Create(context.Context, models.Config) error
	Get(context.Context) (*models.Config, error)
}

type DeleteStatus

type DeleteStatus string
const (
	DeleteStatusDeleted      DeleteStatus = "deleted"
	DeleteStatusDoesNotExist DeleteStatus = "does_not_exist"
	DeleteStatusError        DeleteStatus = "error"
)

type GetSuggestionsOptions added in v0.0.2

type GetSuggestionsOptions struct {
	Options *struct {
		Offset uint64
		Limit  uint64
	}

	FilterProjectLabel string
}

type Interface

type Interface interface {
	Roles() RoleDB
	Users() UserDB
	Projects() ProjectsDB
	Suggestions() SuggestionsDB
	Contributors() ContributorDB
	Config() ConfigDB
	Secrets() SecretDB
	Tokens() TokensDB
	Session() SessionDB
	Recoveries() RecoveryDB
	OrgPolicyDB() OrgPolicyDB
	AuditLog() AuditLogDB
}

type ListPolicyOptions

type ListPolicyOptions struct {
	Options *struct {
		Offset uint64
		Limit  uint64
	}

	FilterIDs []string
}

type ListRoleOptions

type ListRoleOptions struct {
	Offset uint64
	Limit  uint64
}

type ListUserOptions

type ListUserOptions struct {
	Options *struct {
		Offset uint64
		Limit  uint64
	}

	FilterIDs []string
}

type Migrator added in v0.0.2

type Migrator interface {
	Up(context.Context) error
	Down(context.Context) error
}

Migrator represents backend/database migrations See a concrete implementation of this interface (e.g. PostgresMigrator) for more details.

func NewMigrator added in v0.0.2

func NewMigrator(dbURL *url.URL, migrations ...string) (Migrator, error)

NewMigrator returns a new migrator for the given db type (based off of the provided URL)

func NewPostgresMigrator added in v0.0.2

func NewPostgresMigrator(dbURL *url.URL, migrations ...string) (Migrator, error)

NewPostgresMigrator returns a postgres migrator that adheres to the Migrator interface

type NewMigratorFunc added in v0.0.2

type NewMigratorFunc func(dbURL *url.URL, migrations ...string) (Migrator, error)

NewMigratorFunc represents a constructor of a Migrator implementation

type OrgPolicyDB added in v0.0.2

type OrgPolicyDB interface {
	Get(context.Context) ([]models.Policy, error)
	AddPolicy(context.Context, string) error
	RemovePolicy(context.Context, string) error
}

type PostgresMigrator added in v0.0.2

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

PostgresMigrator implements the Migrator interface for a postgres backend.

func (*PostgresMigrator) Down added in v0.0.2

func (p *PostgresMigrator) Down(ctx context.Context) error

Down rolls the db back to initial state (ie undoes all of the migrations)

func (*PostgresMigrator) Up added in v0.0.2

Up runs all of the provided migrations

type QueryAuditLogOptions added in v0.0.2

type QueryAuditLogOptions struct {
	Offset     int
	Limit      int
	EventName  string
	GrepString string
}

type RecoveryDB added in v0.0.2

type RecoveryDB interface {
	Get(context.Context, string) (*models.Recovery, error)
	Create(context.Context, models.Recovery) error
	Delete(context.Context, string) error
}

type SecretDB added in v0.0.2

type SecretDB interface {
	Create(context.Context, models.SecretArg) error
	Delete(context.Context, string) (DeleteStatus, error)
	Get(context.Context, string) (*models.SecretArg, error)
}

type SessionDB added in v0.0.2

type SessionDB interface {
	Get(context.Context, string) (*models.Session, error)
	Create(context.Context, models.Session) error
	Delete(context.Context, string) error
}

type SuggestionsDB added in v0.0.2

type SuggestionsDB interface {
	CreateSuggestion(context.Context, models.Suggestion) error
	GetSuggestions(context.Context, GetSuggestionsOptions) ([]models.Suggestion, error)
	GetSuggestion(context.Context, string) (*models.Suggestion, error)
	UpdateSuggestion(context.Context, models.Suggestion) error
}

type TokensDB added in v0.0.2

type TokensDB interface {
	Get(context.Context, string) (*models.Token, error)
	Create(context.Context, models.Token) error
	Delete(context.Context, string) error
	ListByUserID(context.Context, string) ([]models.Token, error)
}

Directories

Path Synopsis
dbtest contains functionality for writing tests
dbtest contains functionality for writing tests

Jump to

Keyboard shortcuts

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