storage

package
v0.0.0-...-f7d1ac2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DbUser            = "admin"
	DbPass            = "nimda"
	DbName            = "broker"
	DbPort            = "5432"
	DockerUserNetwork = "test_network"
	EnvPipelineBuild  = "PIPELINE_BUILD"
)

Variables

This section is empty.

Functions

func CloseDatabase

func CloseDatabase(t *testing.T, connection *dbr.Connection)

func EnsureTestNetworkForDB

func EnsureTestNetworkForDB(t *testing.T, ctx context.Context) (func(), error)

func InitTestDBTables

func InitTestDBTables(t *testing.T, connectionURL string) (func(), error)

func NewInMemoryEvents

func NewInMemoryEvents() *inMemoryEvents

func SetupTestDBTables

func SetupTestDBTables(connectionURL string) (cleanupFunc func(), err error)

func SetupTestNetworkForDB

func SetupTestNetworkForDB(ctx context.Context) (cleanupFunc func(), err error)

Types

type BrokerStorage

type BrokerStorage interface {
	Instances() Instances
	Operations() Operations
	Provisioning() Provisioning
	Deprovisioning() Deprovisioning
	Orchestrations() Orchestrations
	RuntimeStates() RuntimeStates
	Events() Events
}

func NewFromConfig

func NewFromConfig(cfg Config, evcfg events.Config, cipher postgres.Cipher, log logrus.FieldLogger) (BrokerStorage, *dbr.Connection, error)

func NewMemoryStorage

func NewMemoryStorage() BrokerStorage

type Config

type Config struct {
	User        string `envconfig:"default=postgres"`
	Password    string `envconfig:"default=password"`
	Host        string `envconfig:"default=localhost"`
	Port        string `envconfig:"default=5432"`
	Name        string `envconfig:"default=broker"`
	SSLMode     string `envconfig:"default=disable"`
	SSLRootCert string `envconfig:"optional"`

	SecretKey string `envconfig:"optional"`

	MaxOpenConns    int           `envconfig:"default=8"`
	MaxIdleConns    int           `envconfig:"default=2"`
	ConnMaxLifetime time.Duration `envconfig:"default=30m"`
}

func InitTestDBContainer

func InitTestDBContainer(log func(format string, args ...interface{}), ctx context.Context, hostname string) (func(), Config, error)

func (*Config) ConnectionURL

func (cfg *Config) ConnectionURL() string

type Deprovisioning

type Deprovisioning interface {
	InsertDeprovisioningOperation(operation internal.DeprovisioningOperation) error
	GetDeprovisioningOperationByID(operationID string) (*internal.DeprovisioningOperation, error)
	GetDeprovisioningOperationByInstanceID(instanceID string) (*internal.DeprovisioningOperation, error)
	UpdateDeprovisioningOperation(operation internal.DeprovisioningOperation) (*internal.DeprovisioningOperation, error)
	ListDeprovisioningOperationsByInstanceID(instanceID string) ([]internal.DeprovisioningOperation, error)
	ListDeprovisioningOperations() ([]internal.DeprovisioningOperation, error)
}

type Encrypter

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

func NewEncrypter

func NewEncrypter(secretKey string) *Encrypter

func (*Encrypter) Decrypt

func (e *Encrypter) Decrypt(obj []byte) ([]byte, error)

func (*Encrypter) DecryptKubeconfig

func (e *Encrypter) DecryptKubeconfig(provisioningParameters *internal.ProvisioningParameters) error

func (*Encrypter) DecryptSMCreds

func (e *Encrypter) DecryptSMCreds(provisioningParameters *internal.ProvisioningParameters) error

func (*Encrypter) Encrypt

func (e *Encrypter) Encrypt(obj []byte) ([]byte, error)

func (*Encrypter) EncryptKubeconfig

func (e *Encrypter) EncryptKubeconfig(provisioningParameters *internal.ProvisioningParameters) error

func (*Encrypter) EncryptSMCreds

func (e *Encrypter) EncryptSMCreds(provisioningParameters *internal.ProvisioningParameters) error

type Events

type Events interface {
	InsertEvent(level events.EventLevel, message, instanceID, operationID string)
	ListEvents(filter events.EventFilter) ([]events.EventDTO, error)
}

type Instances

type Instances interface {
	FindAllJoinedWithOperations(prct ...predicate.Predicate) ([]internal.InstanceWithOperation, error)
	FindAllInstancesForRuntimes(runtimeIdList []string) ([]internal.Instance, error)
	FindAllInstancesForSubAccounts(subAccountslist []string) ([]internal.Instance, error)
	GetByID(instanceID string) (*internal.Instance, error)
	Insert(instance internal.Instance) error
	Update(instance internal.Instance) (*internal.Instance, error)
	Delete(instanceID string) error
	GetInstanceStats() (internal.InstanceStats, error)
	GetERSContextStats() (internal.ERSContextStats, error)
	GetNumberOfInstancesForGlobalAccountID(globalAccountID string) (int, error)
	List(dbmodel.InstanceFilter) ([]internal.Instance, int, int, error)

	// todo: remove after instances parameters migration is done
	InsertWithoutEncryption(instance internal.Instance) error
	UpdateWithoutEncryption(instance internal.Instance) (*internal.Instance, error)
	ListWithoutDecryption(dbmodel.InstanceFilter) ([]internal.Instance, int, int, error)
}

type Operations

type Operations interface {
	Provisioning
	Deprovisioning
	UpgradeKyma
	UpgradeCluster
	Updating

	GetLastOperation(instanceID string) (*internal.Operation, error)
	GetOperationByID(operationID string) (*internal.Operation, error)
	GetNotFinishedOperationsByType(operationType internal.OperationType) ([]internal.Operation, error)
	GetOperationStatsByPlan() (map[string]internal.OperationStats, error)
	GetOperationsForIDs(operationIDList []string) ([]internal.Operation, error)
	GetOperationStatsForOrchestration(orchestrationID string) (map[string]int, error)
	ListOperations(filter dbmodel.OperationFilter) ([]internal.Operation, int, int, error)

	InsertOperation(operation internal.Operation) error
	GetOperationByInstanceID(instanceID string) (*internal.Operation, error)
	UpdateOperation(operation internal.Operation) (*internal.Operation, error)
	ListOperationsByInstanceID(instanceID string) ([]internal.Operation, error)
	ListOperationsByOrchestrationID(orchestrationID string, filter dbmodel.OperationFilter) ([]internal.Operation, int, int, error)
	ListOperationsInTimeRange(from, to time.Time) ([]internal.Operation, error)
}

type Orchestrations

type Orchestrations interface {
	Insert(orchestration internal.Orchestration) error
	Update(orchestration internal.Orchestration) error
	GetByID(orchestrationID string) (*internal.Orchestration, error)
	List(filter dbmodel.OrchestrationFilter) ([]internal.Orchestration, int, int, error)
}

type Provisioning

type Provisioning interface {
	InsertProvisioningOperation(operation internal.ProvisioningOperation) error
	GetProvisioningOperationByID(operationID string) (*internal.ProvisioningOperation, error)
	GetProvisioningOperationByInstanceID(instanceID string) (*internal.ProvisioningOperation, error)
	UpdateProvisioningOperation(operation internal.ProvisioningOperation) (*internal.ProvisioningOperation, error)
	ListProvisioningOperationsByInstanceID(instanceID string) ([]internal.ProvisioningOperation, error)
}

type RuntimeStates

type RuntimeStates interface {
	Insert(runtimeState internal.RuntimeState) error
	GetByOperationID(operationID string) (internal.RuntimeState, error)
	ListByRuntimeID(runtimeID string) ([]internal.RuntimeState, error)
	GetLatestByRuntimeID(runtimeID string) (internal.RuntimeState, error)
	GetLatestWithReconcilerInputByRuntimeID(runtimeID string) (internal.RuntimeState, error)
	GetLatestWithKymaVersionByRuntimeID(runtimeID string) (internal.RuntimeState, error)
	GetLatestWithOIDCConfigByRuntimeID(runtimeID string) (internal.RuntimeState, error)
}

type Updating

type Updating interface {
	InsertUpdatingOperation(operation internal.UpdatingOperation) error
	GetUpdatingOperationByID(operationID string) (*internal.UpdatingOperation, error)
	ListUpdatingOperationsByInstanceID(instanceID string) ([]internal.UpdatingOperation, error)
	UpdateUpdatingOperation(operation internal.UpdatingOperation) (*internal.UpdatingOperation, error)
}

type UpgradeCluster

type UpgradeCluster interface {
	InsertUpgradeClusterOperation(operation internal.UpgradeClusterOperation) error
	UpdateUpgradeClusterOperation(operation internal.UpgradeClusterOperation) (*internal.UpgradeClusterOperation, error)
	GetUpgradeClusterOperationByID(operationID string) (*internal.UpgradeClusterOperation, error)
	ListUpgradeClusterOperationsByInstanceID(instanceID string) ([]internal.UpgradeClusterOperation, error)
	ListUpgradeClusterOperationsByOrchestrationID(orchestrationID string, filter dbmodel.OperationFilter) ([]internal.UpgradeClusterOperation, int, int, error)
}

type UpgradeKyma

type UpgradeKyma interface {
	InsertUpgradeKymaOperation(operation internal.UpgradeKymaOperation) error
	UpdateUpgradeKymaOperation(operation internal.UpgradeKymaOperation) (*internal.UpgradeKymaOperation, error)
	GetUpgradeKymaOperationByID(operationID string) (*internal.UpgradeKymaOperation, error)
	GetUpgradeKymaOperationByInstanceID(instanceID string) (*internal.UpgradeKymaOperation, error)
	ListUpgradeKymaOperations() ([]internal.UpgradeKymaOperation, error)
	ListUpgradeKymaOperationsByInstanceID(instanceID string) ([]internal.UpgradeKymaOperation, error)
	ListUpgradeKymaOperationsByOrchestrationID(orchestrationID string, filter dbmodel.OperationFilter) ([]internal.UpgradeKymaOperation, int, int, error)
}

Directories

Path Synopsis
driver

Jump to

Keyboard shortcuts

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