profile

package
v2.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package profile contains runtime profile domain models.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyExists = errors.New("profile already exists")
	ErrDisabled      = errors.New("profile is disabled")
	ErrDuplicateKey  = errors.New("profile key already exists")
	ErrInvalidKey    = errors.New("invalid profile key")
	ErrInvalidName   = errors.New("invalid profile name")
	ErrInvalidStatus = errors.New("invalid profile status")
	ErrNotFound      = errors.New("profile not found")
	ErrReservedKey   = errors.New("profile key is reserved")
)

Functions

func IsInheritedStorageName

func IsInheritedStorageName(name string) bool

func IsWorkspaceInheritedStorageName

func IsWorkspaceInheritedStorageName(name string) bool

func SecretRef

func SecretRef(profileName, key string) string

SecretRef returns the deterministic managed-secret reference for a profile entry. The format is "runtime-profiles/<profileName>/key-<hexEncodedKey>".

func SecretRefForProfileName

func SecretRefForProfileName(profileName, key string) string

func ValidateKey

func ValidateKey(key string) error

func ValidateName

func ValidateName(name string) error

Types

type CreateInput

type CreateInput struct {
	Name        string
	Description string
	Protected   bool
	CreatedBy   string
}

type Entry

type Entry struct {
	Key       string
	Kind      EntryKind
	Value     string
	SecretID  string
	CreatedBy string
	CreatedAt time.Time
	UpdatedBy string
	UpdatedAt time.Time
}

type EntryKind

type EntryKind string
const (
	EntryKindVariable EntryKind = "variable"
	EntryKindSecret   EntryKind = "secret"
)

type InheritedCreateInput

type InheritedCreateInput struct {
	Description string
	CreatedBy   string
}

type InheritedRef

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

InheritedRef identifies a non-selectable profile layer inherited by a run.

func GlobalInheritedRef

func GlobalInheritedRef() InheritedRef

func WorkspaceInheritedRef

func WorkspaceInheritedRef(name string) (InheritedRef, error)

func (InheritedRef) PublicName

func (r InheritedRef) PublicName() string

func (InheritedRef) SecretRef

func (r InheritedRef) SecretRef(key string) string

func (InheritedRef) StorageName

func (r InheritedRef) StorageName() string

func (InheritedRef) Valid

func (r InheritedRef) Valid() bool

type Manager

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

Manager coordinates profile mutations that span the profile and secret stores.

func NewManager

func NewManager(profileStore Store, secretStore secret.Store) *Manager

func (*Manager) DeleteEntry

func (m *Manager) DeleteEntry(ctx context.Context, p *Profile, key, actor string) error

func (*Manager) EnsureRunnable

func (m *Manager) EnsureRunnable(ctx context.Context, name string) (*Profile, error)

func (*Manager) Resolve

func (m *Manager) Resolve(ctx context.Context, name string) (*Resolved, error)

func (*Manager) SetSecret

func (m *Manager) SetSecret(ctx context.Context, p *Profile, key, value, actor string) (*Profile, error)

func (*Manager) SetVariable

func (m *Manager) SetVariable(ctx context.Context, p *Profile, key, value, actor string) (*Profile, error)

type Profile

type Profile struct {
	ID             string
	Name           string
	Description    string
	Status         Status
	Protected      bool
	DefaultProfile string `json:"defaultProfile,omitempty"`
	Entries        []Entry
	CreatedBy      string
	CreatedAt      time.Time
	UpdatedBy      string
	UpdatedAt      time.Time
}

func New

func New(input CreateInput, now time.Time) (*Profile, error)

func NewInherited

func NewInherited(ref InheritedRef, input InheritedCreateInput, now time.Time) (*Profile, error)

func (*Profile) ApplyUpdate

func (p *Profile) ApplyUpdate(input UpdateInput, now time.Time)

func (*Profile) Clone

func (p *Profile) Clone() *Profile

func (*Profile) DeleteEntry

func (p *Profile) DeleteEntry(key, actor string, now time.Time) error

func (*Profile) SetSecret

func (p *Profile) SetSecret(key, secretID, actor string, now time.Time) error

func (*Profile) SetStatus

func (p *Profile) SetStatus(status Status, actor string, now time.Time) error

func (*Profile) SetVariable

func (p *Profile) SetVariable(key, value, actor string, now time.Time) error

type Resolved

type Resolved struct {
	Name      string
	Variables map[string]string
	Secrets   map[string]string
	Entries   []ResolvedEntry
}

func MergeResolved

func MergeResolved(name string, layers ...*Resolved) *Resolved

func (*Resolved) EnvVars

func (r *Resolved) EnvVars(kind EntryKind) []string

type ResolvedEntry

type ResolvedEntry struct {
	Key  string
	Kind EntryKind
}

type Resolver

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

func NewResolver

func NewResolver(profileStore Store, secretStore secret.Store) *Resolver

func (*Resolver) Resolve

func (r *Resolver) Resolve(ctx context.Context, name string) (*Resolved, error)

func (*Resolver) ResolveInherited

func (r *Resolver) ResolveInherited(ctx context.Context, ref InheritedRef) (*Resolved, error)

type Status

type Status string
const (
	StatusActive   Status = "active"
	StatusDisabled Status = "disabled"
)

type Store

type Store interface {
	// Create persists a new Profile and returns ErrAlreadyExists when the name is already used.
	Create(ctx context.Context, profile *Profile) error
	// GetByName returns the Profile with the given name or ErrNotFound.
	GetByName(ctx context.Context, name string) (*Profile, error)
	// GetInherited returns the inherited profile layer identified by ref or ErrNotFound.
	GetInherited(ctx context.Context, ref InheritedRef) (*Profile, error)
	// List returns all stored profiles.
	List(ctx context.Context) ([]*Profile, error)
	// Update replaces an existing Profile and returns ErrNotFound when it does not exist.
	Update(ctx context.Context, profile *Profile) error
	// Delete removes the named Profile and returns ErrNotFound when it does not exist.
	Delete(ctx context.Context, name string) error
}

Store persists runtime profiles by name. Implementations must be safe for concurrent use and enforce profile name uniqueness. GetByName and Delete return ErrNotFound when the named profile does not exist. Create and Update validate stored profile data before persisting it.

type UpdateInput

type UpdateInput struct {
	Description *string
	Protected   *bool
	UpdatedBy   string
}

Jump to

Keyboard shortcuts

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