database

package
v0.0.0-...-7c152a1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = fmt.Errorf("database row not found")

Functions

func IsErrForeignKeyViolation

func IsErrForeignKeyViolation(err error) bool

Returns true if the error message is a foreign key constraint violation

func IsErrNotFound

func IsErrNotFound(err error) bool

Types

type ApiKey

type ApiKey struct {
	Team    string     `json:"team"`
	Key     api_v1.Key `json:"key"`
	Expires time.Time  `json:"expires"`
	Created time.Time  `json:"created"`
}

type ApiKeyStore

type ApiKeyStore interface {
	ApiKeys(ctx context.Context, id string) (ApiKeys, error)
	RotateApiKey(ctx context.Context, team string, key api_v1.Key) error
}

type ApiKeys

type ApiKeys []ApiKey

func (ApiKeys) Keys

func (apikeys ApiKeys) Keys() []api_v1.Key

func (ApiKeys) Valid

func (apikeys ApiKeys) Valid() ApiKeys

func (ApiKeys) ValidKeys

func (apikeys ApiKeys) ValidKeys() []api_v1.Key

type Database

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

func New

func New(ctx context.Context, dsn string, encryptionKey []byte) (*Database, error)

func (*Database) ApiKeys

func (db *Database) ApiKeys(ctx context.Context, team string) (ApiKeys, error)

Read all API keys matching the provided team

func (*Database) Deployment

func (db *Database) Deployment(ctx context.Context, id string) (*Deployment, error)

func (*Database) DeploymentResources

func (db *Database) DeploymentResources(ctx context.Context, deploymentID string) ([]DeploymentResource, error)

func (*Database) DeploymentStatus

func (db *Database) DeploymentStatus(ctx context.Context, deploymentID string) ([]DeploymentStatus, error)

func (*Database) Deployments

func (db *Database) Deployments(ctx context.Context, teams, clusters, ignoreTeams []string, limit int) ([]*Deployment, error)

func (*Database) HistoricDeployments

func (db *Database) HistoricDeployments(ctx context.Context, cluster string, timestamp time.Time) ([]*Deployment, error)

func (*Database) Migrate

func (db *Database) Migrate(ctx context.Context) error

func (*Database) ReadRepositoryTeams

func (db *Database) ReadRepositoryTeams(ctx context.Context, repository string) ([]string, error)

func (*Database) RotateApiKey

func (db *Database) RotateApiKey(ctx context.Context, team string, key api_v1.Key) error

func (*Database) WriteDeployment

func (db *Database) WriteDeployment(ctx context.Context, deployment Deployment) error

func (*Database) WriteDeploymentResource

func (db *Database) WriteDeploymentResource(ctx context.Context, resource DeploymentResource) error

func (*Database) WriteDeploymentStatus

func (db *Database) WriteDeploymentStatus(ctx context.Context, status DeploymentStatus) error

func (*Database) WriteRepositoryTeams

func (db *Database) WriteRepositoryTeams(ctx context.Context, repository string, teams []string) error

type Deployment

type Deployment struct {
	ID               string    `json:"id"`
	Team             string    `json:"team"`
	Created          time.Time `json:"created"`
	GitHubID         *int      `json:"githubID"`
	GitHubRepository *string   `json:"githubRepository"`
	Cluster          *string   `json:"cluster"`
	State            *string   `json:"state"`
}

type DeploymentResource

type DeploymentResource struct {
	ID           string `json:"id"`
	DeploymentID string `json:"deploymentID"`
	Index        int    `json:"index"`
	Group        string `json:"group"`
	Version      string `json:"version"`
	Kind         string `json:"kind"`
	Name         string `json:"name"`
	Namespace    string `json:"namespace"`
}

type DeploymentStatus

type DeploymentStatus struct {
	ID           string    `json:"id"`
	DeploymentID string    `json:"deploymentID"`
	Status       string    `json:"status"`
	Message      string    `json:"message"`
	Created      time.Time `json:"created"`
}

type DeploymentStore

type DeploymentStore interface {
	Deployments(ctx context.Context, teams, clusters, ignoreTeams []string, limit int) ([]*Deployment, error)
	Deployment(ctx context.Context, id string) (*Deployment, error)
	HistoricDeployments(ctx context.Context, cluster string, timestamp time.Time) ([]*Deployment, error)
	WriteDeployment(ctx context.Context, deployment Deployment) error
	DeploymentStatus(ctx context.Context, deploymentID string) ([]DeploymentStatus, error)
	WriteDeploymentStatus(ctx context.Context, status DeploymentStatus) error
	DeploymentResources(ctx context.Context, deploymentID string) ([]DeploymentResource, error)
	WriteDeploymentResource(ctx context.Context, resource DeploymentResource) error
}

type MockApiKeyStore

type MockApiKeyStore struct {
	mock.Mock
}

MockApiKeyStore is an autogenerated mock type for the ApiKeyStore type

func NewMockApiKeyStore

func NewMockApiKeyStore(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockApiKeyStore

NewMockApiKeyStore creates a new instance of MockApiKeyStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockApiKeyStore) ApiKeys

func (_m *MockApiKeyStore) ApiKeys(ctx context.Context, id string) (ApiKeys, error)

ApiKeys provides a mock function with given fields: ctx, id

func (*MockApiKeyStore) RotateApiKey

func (_m *MockApiKeyStore) RotateApiKey(ctx context.Context, team string, key api_v1.Key) error

RotateApiKey provides a mock function with given fields: ctx, team, key

type MockDeploymentStore

type MockDeploymentStore struct {
	mock.Mock
}

MockDeploymentStore is an autogenerated mock type for the DeploymentStore type

func NewMockDeploymentStore

func NewMockDeploymentStore(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockDeploymentStore

NewMockDeploymentStore creates a new instance of MockDeploymentStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockDeploymentStore) Deployment

func (_m *MockDeploymentStore) Deployment(ctx context.Context, id string) (*Deployment, error)

Deployment provides a mock function with given fields: ctx, id

func (*MockDeploymentStore) DeploymentResources

func (_m *MockDeploymentStore) DeploymentResources(ctx context.Context, deploymentID string) ([]DeploymentResource, error)

DeploymentResources provides a mock function with given fields: ctx, deploymentID

func (*MockDeploymentStore) DeploymentStatus

func (_m *MockDeploymentStore) DeploymentStatus(ctx context.Context, deploymentID string) ([]DeploymentStatus, error)

DeploymentStatus provides a mock function with given fields: ctx, deploymentID

func (*MockDeploymentStore) Deployments

func (_m *MockDeploymentStore) Deployments(ctx context.Context, teams []string, clusters []string, ignoreTeams []string, limit int) ([]*Deployment, error)

Deployments provides a mock function with given fields: ctx, teams, clusters, ignoreTeams, limit

func (*MockDeploymentStore) HistoricDeployments

func (_m *MockDeploymentStore) HistoricDeployments(ctx context.Context, cluster string, timestamp time.Time) ([]*Deployment, error)

HistoricDeployments provides a mock function with given fields: ctx, cluster, timestamp

func (*MockDeploymentStore) WriteDeployment

func (_m *MockDeploymentStore) WriteDeployment(ctx context.Context, deployment Deployment) error

WriteDeployment provides a mock function with given fields: ctx, deployment

func (*MockDeploymentStore) WriteDeploymentResource

func (_m *MockDeploymentStore) WriteDeploymentResource(ctx context.Context, resource DeploymentResource) error

WriteDeploymentResource provides a mock function with given fields: ctx, resource

func (*MockDeploymentStore) WriteDeploymentStatus

func (_m *MockDeploymentStore) WriteDeploymentStatus(ctx context.Context, status DeploymentStatus) error

WriteDeploymentStatus provides a mock function with given fields: ctx, status

type MockRepositoryTeamStore

type MockRepositoryTeamStore struct {
	mock.Mock
}

MockRepositoryTeamStore is an autogenerated mock type for the RepositoryTeamStore type

func NewMockRepositoryTeamStore

func NewMockRepositoryTeamStore(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockRepositoryTeamStore

NewMockRepositoryTeamStore creates a new instance of MockRepositoryTeamStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockRepositoryTeamStore) ReadRepositoryTeams

func (_m *MockRepositoryTeamStore) ReadRepositoryTeams(ctx context.Context, repository string) ([]string, error)

ReadRepositoryTeams provides a mock function with given fields: ctx, repository

func (*MockRepositoryTeamStore) WriteRepositoryTeams

func (_m *MockRepositoryTeamStore) WriteRepositoryTeams(ctx context.Context, repository string, teams []string) error

WriteRepositoryTeams provides a mock function with given fields: ctx, repository, teams

type RepositoryTeamStore

type RepositoryTeamStore interface {
	ReadRepositoryTeams(ctx context.Context, repository string) ([]string, error)
	WriteRepositoryTeams(ctx context.Context, repository string, teams []string) error
}

legacy layer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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