storage

package
v0.0.0-...-95abdeb Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const HATEMPPATH = "/hab/var/automate-ha"

Variables

This section is empty.

Functions

func Transact

func Transact(pg *PGBackend, txFunc func(*DBTrans) error) error

Transact wraps your calls in a transaction. If the call should fail with an error it will perform a rollback. Otherwise the transaction will be committed.

Types

type CurrentBackend

type CurrentBackend interface {
	// Init prepares the backend and migrates data from any known
	// Upgradeable Backends. Must be called before GetLicense and
	// SetLicense.
	Init(context.Context, *keys.LicenseParser) error
	// GetLicense returns the currently configured automate
	// license. If no license is configured, NoLicense is
	// returned.
	GetLicense(context.Context) (string, keys.LicenseMetadata, error)
	// SetLicense stores the given license in the backend.
	SetLicense(context.Context, string) error
	// StoreDeployment stores the deployment info in the backend
	StoreDeployment(context.Context, string) error
	// GetDeployment returns the deployment info from backend
	GetDeployment(context.Context) (Deployment, error)
}

A CurrentBackend can be used as a storage backend for the license-control-service.

func NewCurrentBackend

func NewCurrentBackend(pgURL, migrationPath, legacyFilePath string) CurrentBackend

type DBTrans

type DBTrans struct {
	*sql.Tx
}

type Deployment

type Deployment struct {
	ID        string
	CreatedAt time.Time
	UpdatedAt time.Time
	Type      string
}

type FileBackend

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

The FileBackend is a UpgradeableBackend for the previous file-based license storage.

func NewFileBackend

func NewFileBackend(path string) *FileBackend

func (*FileBackend) Cleanup

func (f *FileBackend) Cleanup(context.Context) error

func (*FileBackend) GetLicense

func (f *FileBackend) GetLicense(context.Context) (string, error)

type MemBackend

type MemBackend struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

MemBackend is a CurrentBackend for testing purposes only.

func (*MemBackend) GetDeployment

func (m *MemBackend) GetDeployment(context.Context) (Deployment, error)

func (*MemBackend) GetLicense

func (*MemBackend) Init

func (*MemBackend) SetLicense

func (m *MemBackend) SetLicense(ctx context.Context, s string) error

func (*MemBackend) StoreDeployment

func (m *MemBackend) StoreDeployment(context.Context, string) error

type NoLicenseError

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

NoLicenseError is the error returned by a backend when it does not have a configured License.

func (*NoLicenseError) Error

func (n *NoLicenseError) Error() string

type PGBackend

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

PgBackend is the CurrentBackend used in production. It stores the raw key data in PostgreSQL.

func (*PGBackend) GetDeployment

func (p *PGBackend) GetDeployment(ctx context.Context) (Deployment, error)

GetDeployment: fetches the deployment data

func (*PGBackend) GetLicense

func (p *PGBackend) GetLicense(ctx context.Context) (string, keys.LicenseMetadata, error)

func (*PGBackend) Init

func (p *PGBackend) Init(ctx context.Context, l *keys.LicenseParser) error

func (*PGBackend) SetLicense

func (p *PGBackend) SetLicense(ctx context.Context, data string) error

func (*PGBackend) StoreDeployment

func (p *PGBackend) StoreDeployment(ctx context.Context, id string) error

StoreDeployment stores the deployment info in the DB

type RetriableBackendError

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

RetriableBackendError is the error returned by a backend when an update has failed but may work if retried.

func (*RetriableBackendError) Error

func (r *RetriableBackendError) Error() string

type UpgradeableBackend

type UpgradeableBackend interface {
	// GetLicense returns the currently configured automate
	// license. If no license is configured, ErrNoLicense is
	// returned.
	GetLicense(context.Context) (string, error)
	// Cleanup removes the state kept by this backend. After
	// Cleanup is called, GetLicense should return a
	// NoLicenseError.
	Cleanup(context.Context) error
}

An UpgradeableBackend is an old backend that can no longer be used as a backend for the license-control-service but which might have data that needs to be migrated into the CurrentBackend.

Jump to

Keyboard shortcuts

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