storage

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package storage contains the data storage interface in which Gofer stores all internal data.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEntityNotFound is returned when a certain entity could not be located.
	ErrEntityNotFound = errors.New("storage: entity not found")

	// ErrEntityExists is returned when a certain entity was located but not meant to be.
	ErrEntityExists = errors.New("storage: entity already exists")

	// ErrPreconditionFailure is returned when there was a validation error with the parameters passed.
	ErrPreconditionFailure = errors.New("storage: parameters did not pass validation")

	// ErrInternal is returned when there was an unknown internal DB error.
	ErrInternal = errors.New("storage: unknown db error")
)

Functions

func InsideTx added in v0.5.0

func InsideTx(db *sqlx.DB, fn func(*sqlx.Tx) error) error

InsideTx is a convenience function so that callers can run multiple queries inside a transaction.

Types

type DB added in v0.3.0

type DB struct {
	*sqlx.DB
	// contains filtered or unexported fields
}

DB is a representation of the datastore

func New added in v0.3.0

func New(path string, maxResultsLimit int) (DB, error)

New creates a new db with given settings

func (*DB) DeleteEvent added in v0.3.0

func (db *DB) DeleteEvent(conn Queryable, id int64) error

func (*DB) DeleteGlobalExtensionRegistration added in v0.5.0

func (db *DB) DeleteGlobalExtensionRegistration(conn Queryable, name string) error

func (*DB) DeleteNamespace added in v0.3.0

func (db *DB) DeleteNamespace(conn Queryable, id string) error

func (*DB) DeleteObjectStorePipelineKey added in v0.3.0

func (db *DB) DeleteObjectStorePipelineKey(conn Queryable, namespace, pipeline, key string) error

func (*DB) DeleteObjectStoreRunKey added in v0.3.0

func (db *DB) DeleteObjectStoreRunKey(conn Queryable, namespace, pipeline string, run int64, key string) error

func (*DB) DeletePipelineConfig added in v0.5.0

func (db *DB) DeletePipelineConfig(conn Queryable, namespace, pipeline string, version int64) error

func (*DB) DeletePipelineDeployment added in v0.5.0

func (db *DB) DeletePipelineDeployment(conn Queryable, namespace, pipeline string, id int64) error

func (*DB) DeletePipelineExtensionSubscription added in v0.5.0

func (db *DB) DeletePipelineExtensionSubscription(conn Queryable, namespace, pipeline, name, label string) error

func (*DB) DeletePipelineMetadata added in v0.5.0

func (db *DB) DeletePipelineMetadata(conn Queryable, namespace, id string) error

func (*DB) DeletePipelineRun added in v0.5.0

func (db *DB) DeletePipelineRun(conn Queryable, namespace, pipeline string, id int64) error

func (*DB) DeletePipelineTaskRun added in v0.5.0

func (db *DB) DeletePipelineTaskRun(conn Queryable, namespace, pipeline string, run int64, id string) error

func (*DB) DeleteSecretStoreGlobalKey added in v0.3.0

func (db *DB) DeleteSecretStoreGlobalKey(conn Queryable, key string) error

func (*DB) DeleteSecretStorePipelineKey added in v0.3.0

func (db *DB) DeleteSecretStorePipelineKey(conn Queryable, namespace, pipeline, key string) error

func (*DB) DeleteTokenByHash added in v0.5.0

func (db *DB) DeleteTokenByHash(conn Queryable, hash string) error

func (*DB) DeleteTokenByID added in v0.5.0

func (db *DB) DeleteTokenByID(conn Queryable, id int64) error

func (*DB) DisableToken added in v0.3.0

func (db *DB) DisableToken(conn Queryable, hashStr string) error

func (*DB) EnableToken added in v0.3.0

func (db *DB) EnableToken(conn Queryable, hashStr string) error

func (*DB) GetEvent added in v0.3.0

func (db *DB) GetEvent(conn Queryable, id int64) (Event, error)

func (*DB) GetGlobalExtensionRegistration added in v0.5.0

func (db *DB) GetGlobalExtensionRegistration(conn Queryable, name string) (GlobalExtensionRegistration, error)

func (*DB) GetLatestLivePipelineConfig added in v0.5.0

func (db *DB) GetLatestLivePipelineConfig(conn Queryable, namespace, pipeline string) (PipelineConfig, error)

func (*DB) GetLatestPipelineConfig added in v0.5.0

func (db *DB) GetLatestPipelineConfig(conn Queryable, namespace, pipeline string) (PipelineConfig, error)

func (*DB) GetLatestPipelineRun added in v0.5.0

func (db *DB) GetLatestPipelineRun(conn Queryable, namespace, pipeline string) (PipelineRun, error)

func (*DB) GetNamespace added in v0.3.0

func (db *DB) GetNamespace(conn Queryable, id string) (Namespace, error)

func (*DB) GetPipelineConfig added in v0.5.0

func (db *DB) GetPipelineConfig(conn Queryable, namespace, pipeline string, version int64) (PipelineConfig, error)

func (*DB) GetPipelineDeployment added in v0.5.0

func (db *DB) GetPipelineDeployment(conn Queryable, namespace, pipeline string, id int64) (
	PipelineDeployment, error,
)

func (*DB) GetPipelineExtensionSubscription added in v0.5.0

func (db *DB) GetPipelineExtensionSubscription(conn Queryable, namespace, pipeline, name, label string) (
	PipelineExtensionSubscription, error,
)

func (*DB) GetPipelineMetadata added in v0.5.0

func (db *DB) GetPipelineMetadata(conn Queryable, namespace, id string) (PipelineMetadata, error)

func (*DB) GetPipelineRun added in v0.5.0

func (db *DB) GetPipelineRun(conn Queryable, namespace, pipeline string, id int64) (PipelineRun, error)

func (*DB) GetPipelineTask added in v0.5.0

func (db *DB) GetPipelineTask(conn Queryable, namespace, pipeline string, version int64, id string) (
	PipelineTask, error,
)

func (*DB) GetPipelineTaskRun added in v0.5.0

func (db *DB) GetPipelineTaskRun(conn Queryable, namespace, pipeline string, run int64, id string) (PipelineTaskRun, error)

func (*DB) GetSecretStoreGlobalKey added in v0.3.0

func (db *DB) GetSecretStoreGlobalKey(conn Queryable, key string) (SecretStoreGlobalKey, error)

func (*DB) GetSecretStorePipelineKey added in v0.3.0

func (db *DB) GetSecretStorePipelineKey(conn Queryable, namespace, pipeline, key string) (SecretStorePipelineKey, error)

func (*DB) GetTokenByHash added in v0.5.0

func (db *DB) GetTokenByHash(conn Queryable, hashStr string) (Token, error)

func (*DB) GetTokenByID added in v0.5.0

func (db *DB) GetTokenByID(conn Queryable, id int64) (Token, error)

func (*DB) InsertEvent added in v0.3.0

func (db *DB) InsertEvent(conn Queryable, event *Event) (int64, error)

func (*DB) InsertGlobalExtensionRegistration added in v0.5.0

func (db *DB) InsertGlobalExtensionRegistration(conn Queryable, tr *GlobalExtensionRegistration) error

func (*DB) InsertNamespace added in v0.3.0

func (db *DB) InsertNamespace(conn Queryable, namespace *Namespace) error

func (*DB) InsertObjectStorePipelineKey added in v0.3.0

func (db *DB) InsertObjectStorePipelineKey(conn Queryable, objectKey *ObjectStorePipelineKey) error

func (*DB) InsertObjectStoreRunKey added in v0.3.0

func (db *DB) InsertObjectStoreRunKey(conn Queryable, objectKey *ObjectStoreRunKey) error

func (*DB) InsertPipelineConfig added in v0.5.0

func (db *DB) InsertPipelineConfig(conn Queryable, config *PipelineConfig) error

func (*DB) InsertPipelineDeployment added in v0.5.0

func (db *DB) InsertPipelineDeployment(conn Queryable, deployment *PipelineDeployment) error

func (*DB) InsertPipelineExtensionSubscription added in v0.5.0

func (db *DB) InsertPipelineExtensionSubscription(conn Queryable, sub *PipelineExtensionSubscription) error

func (*DB) InsertPipelineMetadata added in v0.5.0

func (db *DB) InsertPipelineMetadata(conn Queryable, metadata *PipelineMetadata) error

func (*DB) InsertPipelineRun added in v0.5.0

func (db *DB) InsertPipelineRun(conn Queryable, run *PipelineRun) error

func (*DB) InsertPipelineTask added in v0.5.0

func (db *DB) InsertPipelineTask(conn Queryable, task *PipelineTask) error

func (*DB) InsertPipelineTaskRun added in v0.5.0

func (db *DB) InsertPipelineTaskRun(conn Queryable, taskRun *PipelineTaskRun) error

func (*DB) InsertSecretStoreGlobalKey added in v0.3.0

func (db *DB) InsertSecretStoreGlobalKey(conn Queryable, secretKey *SecretStoreGlobalKey, force bool) error

func (*DB) InsertSecretStorePipelineKey added in v0.3.0

func (db *DB) InsertSecretStorePipelineKey(conn Queryable, secretKey *SecretStorePipelineKey, force bool,
) error

func (*DB) InsertToken added in v0.3.0

func (db *DB) InsertToken(conn Queryable, tr *Token) (int64, error)

func (*DB) ListEvents added in v0.3.0

func (db *DB) ListEvents(conn Queryable, offset, limit int, reverse bool) ([]Event, error)

Return all events. The reverse parameter allows the sorting the events in reverse chronological order (newest event first).

func (*DB) ListGlobalExtensionRegistrations added in v0.5.0

func (db *DB) ListGlobalExtensionRegistrations(conn Queryable, offset, limit int) ([]GlobalExtensionRegistration, error)

func (*DB) ListNamespaces added in v0.3.0

func (db *DB) ListNamespaces(conn Queryable, offset, limit int) ([]Namespace, error)

func (*DB) ListObjectStorePipelineKeys added in v0.3.0

func (db *DB) ListObjectStorePipelineKeys(conn Queryable, namespace, pipeline string) ([]ObjectStorePipelineKey, error)

func (*DB) ListObjectStoreRunKeys added in v0.3.0

func (db *DB) ListObjectStoreRunKeys(conn Queryable, namespace, pipeline string, run int64) ([]ObjectStoreRunKey, error)

func (*DB) ListPipelineConfigs added in v0.5.0

func (db *DB) ListPipelineConfigs(conn Queryable, offset, limit int, namespace, pipeline string) ([]PipelineConfig, error)

func (*DB) ListPipelineDeployments added in v0.5.0

func (db *DB) ListPipelineDeployments(conn Queryable, offset, limit int, namespace, pipeline string) (
	[]PipelineDeployment, error,
)

func (*DB) ListPipelineExtensionSubscriptions added in v0.5.0

func (db *DB) ListPipelineExtensionSubscriptions(conn Queryable, namespace, pipeline string) ([]PipelineExtensionSubscription, error)

func (*DB) ListPipelineMetadata added in v0.5.0

func (db *DB) ListPipelineMetadata(conn Queryable, offset, limit int, namespace string) ([]PipelineMetadata, error)

Returns pipelines ordered by id.

func (*DB) ListPipelineRuns added in v0.5.0

func (db *DB) ListPipelineRuns(conn Queryable, offset, limit int, namespace, pipeline string) ([]PipelineRun, error)

func (*DB) ListPipelineTaskRuns added in v0.5.0

func (db *DB) ListPipelineTaskRuns(conn Queryable, offset, limit int, namespace, pipeline string, run int64) (
	[]PipelineTaskRun, error,
)

func (*DB) ListPipelineTasks added in v0.5.0

func (db *DB) ListPipelineTasks(conn Queryable, namespace, pipeline string, version int64) ([]PipelineTask, error)

func (*DB) ListRunningPipelineDeployments added in v0.5.0

func (db *DB) ListRunningPipelineDeployments(conn Queryable, offset, limit int, namespace, pipeline string) (
	[]PipelineDeployment, error,
)

func (*DB) ListSecretStoreGlobalKeys added in v0.3.0

func (db *DB) ListSecretStoreGlobalKeys(conn Queryable) ([]SecretStoreGlobalKey, error)

func (*DB) ListSecretStorePipelineKeys added in v0.3.0

func (db *DB) ListSecretStorePipelineKeys(conn Queryable, namespace, pipeline string) ([]SecretStorePipelineKey, error)

func (*DB) ListTokens added in v0.3.0

func (db *DB) ListTokens(conn Queryable, offset, limit int) ([]Token, error)

func (*DB) UpdateGlobalExtensionRegistration added in v0.5.0

func (db *DB) UpdateGlobalExtensionRegistration(conn Queryable, name string, fields UpdatableGlobalExtensionRegistrationFields) error

func (*DB) UpdateNamespace added in v0.3.0

func (db *DB) UpdateNamespace(conn Queryable, id string, fields UpdatableNamespaceFields) error

func (*DB) UpdatePipelineConfig added in v0.5.0

func (db *DB) UpdatePipelineConfig(conn Queryable, namespace, pipeline string, version int64,
	fields UpdatablePipelineConfigFields,
) error

func (*DB) UpdatePipelineDeployment added in v0.5.0

func (db *DB) UpdatePipelineDeployment(conn Queryable, namespace, pipeline string, id int64,
	fields UpdatablePipelineDeploymentFields,
) error

func (*DB) UpdatePipelineExtensionSubscription added in v0.5.0

func (db *DB) UpdatePipelineExtensionSubscription(conn Queryable, namespace, pipeline, name, label string, fields UpdateablePipelineExtensionSubscriptionFields) error

func (*DB) UpdatePipelineMetadata added in v0.5.0

func (db *DB) UpdatePipelineMetadata(conn Queryable, namespace, id string, fields UpdatablePipelineMetadataFields) error

func (*DB) UpdatePipelineRun added in v0.5.0

func (db *DB) UpdatePipelineRun(conn Queryable, namespace, pipeline string, id int64, fields UpdatablePipelineRunFields) error

func (*DB) UpdatePipelineTaskRun added in v0.5.0

func (db *DB) UpdatePipelineTaskRun(conn Queryable, namespace, pipeline string, run int64, id string, fields UpdatablePipelineTaskRunFields) error

func (*DB) UpdateSecretStoreGlobalKey added in v0.5.0

func (db *DB) UpdateSecretStoreGlobalKey(conn Queryable, key string, fields UpdatableSecretStoreGlobalKeyFields) error

type Event added in v0.5.0

type Event struct {
	ID      int64
	Type    string
	Details string
	Emitted int64
}

type GlobalExtensionRegistration added in v0.5.0

type GlobalExtensionRegistration struct {
	Name         string
	Image        string
	RegistryAuth string `db:"registry_auth"`
	Variables    string
	Created      int64
	Status       string
	KeyID        int64 `db:"key_id"`
}

type Namespace added in v0.5.0

type Namespace struct {
	ID          string
	Name        string
	Description string
	Created     int64
	Modified    int64
}

type ObjectStorePipelineKey added in v0.5.0

type ObjectStorePipelineKey struct {
	Namespace string
	Pipeline  string
	Key       string
	Created   int64
}

type ObjectStoreRunKey added in v0.5.0

type ObjectStoreRunKey struct {
	Namespace string
	Pipeline  string
	Run       int64
	Key       string
	Created   int64
}

type PipelineConfig added in v0.5.0

type PipelineConfig struct {
	Namespace   string
	Pipeline    string
	Version     int64
	Parallelism int64
	Name        string
	Description string
	Registered  int64
	Deprecated  int64
	State       string
}

type PipelineDeployment added in v0.5.0

type PipelineDeployment struct {
	Namespace    string
	Pipeline     string
	ID           int64
	StartVersion int64 `db:"start_version"`
	EndVersion   int64 `db:"end_version"`
	Started      int64
	Ended        int64
	State        string
	Status       string
	StatusReason string `db:"status_reason"`
	Logs         string
}

type PipelineExtensionSubscription added in v0.5.0

type PipelineExtensionSubscription struct {
	Namespace    string
	Pipeline     string
	Name         string
	Label        string
	Settings     string
	Status       string
	StatusReason string `db:"status_reason"`
}

type PipelineMetadata added in v0.5.0

type PipelineMetadata struct {
	Namespace string
	ID        string
	Created   int64
	Modified  int64
	State     string
}

type PipelineRun added in v0.5.0

type PipelineRun struct {
	Namespace             string
	Pipeline              string
	PipelineConfigVersion int64 `db:"pipeline_config_version"`
	ID                    int64
	Started               int64
	Ended                 int64
	State                 string
	Status                string
	StatusReason          string `db:"status_reason"`
	Initiator             string
	Variables             string
	StoreObjectsExpired   bool `db:"store_objects_expired"`
}

type PipelineTask added in v0.5.0

type PipelineTask struct {
	Namespace             string
	Pipeline              string
	PipelineConfigVersion int64 `db:"pipeline_config_version"`
	ID                    string
	Description           string
	Image                 string
	RegistryAuth          string `db:"registry_auth"`
	DependsOn             string `db:"depends_on"`
	Variables             string
	Entrypoint            string
	Command               string
	InjectAPIToken        bool `db:"inject_api_token"`
}

type PipelineTaskRun added in v0.5.0

type PipelineTaskRun struct {
	Namespace    string
	Pipeline     string
	Run          int64
	ID           string
	TaskKind     string `db:"task_kind"`
	Task         string
	Created      int64
	Started      int64
	Ended        int64
	ExitCode     int64 `db:"exit_code"`
	LogsExpired  bool  `db:"logs_expired"`
	LogsRemoved  bool  `db:"logs_removed"`
	State        string
	Status       string
	StatusReason string `db:"status_reason"`
	Variables    string
}

type Queryable added in v0.5.0

type Queryable interface {
	sqlx.Queryer
	sqlx.Execer
	GetContext(context.Context, interface{}, string, ...interface{}) error
	SelectContext(context.Context, interface{}, string, ...interface{}) error
	Get(interface{}, string, ...interface{}) error
	MustExecContext(context.Context, string, ...interface{}) sql.Result
	PreparexContext(context.Context, string) (*sqlx.Stmt, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
	Select(interface{}, string, ...interface{}) error
	QueryRow(string, ...interface{}) *sql.Row
	PrepareNamedContext(context.Context, string) (*sqlx.NamedStmt, error)
	PrepareNamed(string) (*sqlx.NamedStmt, error)
	Preparex(string) (*sqlx.Stmt, error)
	NamedExec(string, interface{}) (sql.Result, error)
	NamedExecContext(context.Context, string, interface{}) (sql.Result, error)
	MustExec(string, ...interface{}) sql.Result
	NamedQuery(string, interface{}) (*sqlx.Rows, error)
}

Queryable includes methods shared by sqlx.Tx and sqlx.DB so they can be used interchangeably.

type SecretStoreGlobalKey added in v0.5.0

type SecretStoreGlobalKey struct {
	Key        string
	Namespaces string
	Created    int64
}

type SecretStorePipelineKey added in v0.5.0

type SecretStorePipelineKey struct {
	Namespace string
	Pipeline  string
	Key       string
	Created   int64
}

type Token added in v0.5.0

type Token struct {
	ID         int64
	Hash       string
	Created    int64
	Kind       string
	Namespaces string
	Metadata   string
	Expires    int64
	Disabled   bool
}

type UpdatableGlobalExtensionRegistrationFields added in v0.5.0

type UpdatableGlobalExtensionRegistrationFields struct {
	Image        *string
	RegistryAuth *string
	Variables    *string
	Status       *string
	KeyID        *int64
}

type UpdatableNamespaceFields added in v0.3.0

type UpdatableNamespaceFields struct {
	Name        *string
	Description *string
	Modified    *int64
}

type UpdatablePipelineConfigFields added in v0.5.0

type UpdatablePipelineConfigFields struct {
	Deprecated *int64
	State      *string
}

type UpdatablePipelineDeploymentFields added in v0.5.0

type UpdatablePipelineDeploymentFields struct {
	Ended        *int64
	State        *string
	Status       *string
	StatusReason *string
	Logs         *string
}

type UpdatablePipelineMetadataFields added in v0.5.0

type UpdatablePipelineMetadataFields struct {
	Modified *int64
	State    *string
}

type UpdatablePipelineRunFields added in v0.5.0

type UpdatablePipelineRunFields struct {
	Ended               *int64
	State               *string
	Status              *string
	StatusReason        *string
	Variables           *string
	StoreObjectsExpired *bool
}

type UpdatablePipelineTaskRunFields added in v0.5.0

type UpdatablePipelineTaskRunFields struct {
	Started      *int64
	Ended        *int64
	ExitCode     *int64
	State        *string
	Status       *string
	StatusReason *string
	LogsExpired  *bool
	LogsRemoved  *bool
	Variables    *string
}

type UpdatableSecretStoreGlobalKeyFields added in v0.5.0

type UpdatableSecretStoreGlobalKeyFields struct {
	Namespaces *string
}

type UpdateablePipelineExtensionSubscriptionFields added in v0.5.0

type UpdateablePipelineExtensionSubscriptionFields struct {
	Settings     *string
	Status       *string
	StatusReason *string
}

Jump to

Keyboard shortcuts

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