backend

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConfigFieldAccessTokenMaxTTL = 7 * 24 * time.Hour
	DefaultConfigFieldAccessTokenRotate = config.DefaultAutoRotateBeforeMinTTL
	DefaultRoleFieldAccessTokenMaxTTL   = 24 * time.Hour
	DefaultAccessTokenMinTTL            = 24 * time.Hour
	DefaultAccessTokenMaxPossibleTTL    = 365 * 24 * time.Hour
	DefaultConfigName                   = "default"

	// PathConfigStorage is the storage key prefix for config entries.
	PathConfigStorage = "config"

	// PathRoleStorage is the storage key prefix for role entries.
	PathRoleStorage = "roles"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientDeleter

type ClientDeleter interface {
	DeleteClient(name string)
}

ClientDeleter removes a client from the cache.

type ClientGetter

type ClientGetter interface {
	GetClient(name string) gitlab.Client
}

ClientGetter provides direct cache access to a stored client.

type ClientReader

type ClientReader interface {
	GetClientByName(ctx context.Context, s logical.Storage, name string) (gitlab.Client, error)
}

ClientReader provides read-only client access by config name.

type ClientSetter

type ClientSetter interface {
	SetClient(client gitlab.Client, name string)
}

ClientSetter stores a client in the cache.

type ConfigStore

type ConfigStore interface {
	GetConfig(ctx context.Context, s logical.Storage, name string) (*config.EntryConfig, error)
	SaveConfig(ctx context.Context, s logical.Storage, cfg *config.EntryConfig) error
}

ConfigStore provides config CRUD operations.

type EventSender

type EventSender interface {
	SendEvent(ctx context.Context, eventType event.EventType, metadata map[string]string) error
}

EventSender abstracts sending audit/events from the backend.

type FlagsProvider

type FlagsProvider interface {
	Flags() flags.Flags
	UpdateFlags(fn func(*flags.Flags))
}

FlagsProvider provides read and update access to runtime flags.

type Impl

type Impl struct {
	*framework.Backend
	// contains filtered or unexported fields
}

Impl is the concrete implementation of the Backend interface.

func New

func New(f flags.Flags) *Impl

New creates a new BackendImpl with the given flags. Call Init to complete setup.

func (*Impl) DeleteClient

func (b *Impl) DeleteClient(name string)

func (*Impl) Flags

func (b *Impl) Flags() flags.Flags

func (*Impl) GetClient

func (b *Impl) GetClient(name string) g.Client

func (*Impl) GetClientByName

func (b *Impl) GetClientByName(ctx context.Context, s logical.Storage, name string) (client g.Client, err error)

func (*Impl) GetConfig

func (b *Impl) GetConfig(ctx context.Context, s logical.Storage, name string) (*modelConfig.EntryConfig, error)

func (*Impl) GetRole

func (b *Impl) GetRole(ctx context.Context, s logical.Storage, name string) (*role.Role, error)

func (*Impl) Init

func (b *Impl) Init(ctx context.Context, conf *logical.BackendConfig, opts ...InitOption) error

Init wires up the framework.Backend with paths from the registered providers, secrets, special paths, and periodic/invalidate dispatchers.

func (*Impl) LockForKey

func (b *Impl) LockForKey(path, key string) *locksutil.LockEntry

func (*Impl) SaveConfig

func (b *Impl) SaveConfig(ctx context.Context, s logical.Storage, config *modelConfig.EntryConfig) error

func (*Impl) SendEvent

func (b *Impl) SendEvent(ctx context.Context, eventType event.EventType, metadata map[string]string) error

func (*Impl) SetClient

func (b *Impl) SetClient(client g.Client, name string)

func (*Impl) UpdateFlags

func (b *Impl) UpdateFlags(fn func(*flags.Flags))

type InitOption

type InitOption func(*initConfig)

InitOption is a functional option for configuring backend initialization.

func WithHelp

func WithHelp(h string) InitOption

WithHelp sets the help text for the backend.

func WithLocalStorage

func WithLocalStorage(paths ...string) InitOption

WithLocalStorage specifies storage paths that should be stored locally.

func WithProviders

func WithProviders(p ...PathProvider) InitOption

WithProviders registers path providers with the backend.

func WithSealWrapStorage

func WithSealWrapStorage(paths ...string) InitOption

WithSealWrapStorage specifies storage paths that should be seal-wrapped.

func WithSecrets

func WithSecrets(s ...*framework.Secret) InitOption

WithSecrets registers framework secrets with the backend.

func WithVersion

func WithVersion(v string) InitOption

WithVersion sets the running version of the backend.

type InvalidateHandler

type InvalidateHandler interface {
	Invalidate(ctx context.Context, key string)
}

InvalidateHandler is optionally implemented by PathProviders that need to react to storage key invalidation events.

type Locker

type Locker interface {
	LockForKey(path, key string) *locksutil.LockEntry
}

Locker provides per-key locking scoped by a path prefix.

type Logging

type Logging interface {
	Logger() hclog.Logger
}

Logging provides access to the backend logger.

type PathProvider

type PathProvider interface {
	Name() string
	Paths() []*framework.Path
}

PathProvider provides framework paths to register with the backend.

type PeriodicHandler

type PeriodicHandler interface {
	PeriodicFunc(ctx context.Context, req *logical.Request) error
}

PeriodicHandler is optionally implemented by PathProviders that need periodic work. The backend checks WriteSafeReplicationState() centrally before dispatching — handlers are only called when writes are safe.

type RoleStore

type RoleStore interface {
	GetRole(ctx context.Context, s logical.Storage, name string) (*role.Role, error)
}

RoleStore provides role read operations.

type WriteSafeReplicationState

type WriteSafeReplicationState interface {
	WriteSafeReplicationState() bool
}

Jump to

Keyboard shortcuts

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