personastore

package
v1.169.2 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package personastore persists database-managed persona definitions, independent of the platform assembly. It holds the persona_definitions storage model (Definition), its Store interface, and the PostgreSQL and no-op implementations. Extracted from pkg/platform so the persona storage layer can be reasoned about (and size-budgeted) on its own.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("persona not found")

ErrNotFound is returned when a persona definition does not exist in the database.

Functions

This section is empty.

Types

type Definition

type Definition struct {
	Name        string   `json:"name"`
	DisplayName string   `json:"display_name"`
	Description string   `json:"description,omitempty"`
	Roles       []string `json:"roles"`
	ToolsAllow  []string `json:"tools_allow"`
	ToolsDeny   []string `json:"tools_deny"`
	ConnsAllow  []string `json:"connections_allow,omitempty"`
	ConnsDeny   []string `json:"connections_deny,omitempty"`
	// APIRoutes are the per-(connection, method, path) rules for api-kind
	// connections. Persisted so a persona edited in the portal expresses
	// everything a file persona can; before it was stored, saving a
	// persona through the admin API dropped the rules its file config
	// gave it (issue #1479).
	APIRoutes []persona.APIRouteRule   `json:"api_routes,omitempty"`
	Context   persona.ContextOverrides `json:"context"`
	Priority  int                      `json:"priority"`
	// ServiceAccount marks the persona an automated caller signs in under:
	// its calls are audited but not cataloged (#1980).
	ServiceAccount bool `json:"service_account"`
	// Portal is what the persona's people may do in the portal (#2225); a
	// field it leaves unset resolves from the persona's tools at load.
	Portal persona.PortalAccess `json:"portal"`
	// External marks the persona for people outside the organization (#2092).
	External bool `json:"external"`
	// AllowSharing lets the persona's people share what they own (#2241).
	// The column defaults true, which is what every persona stored before it
	// could do.
	AllowSharing bool      `json:"allow_sharing"`
	CreatedBy    string    `json:"created_by"`
	UpdatedAt    time.Time `json:"updated_at"`
}

Definition represents a database-managed persona.

func DefinitionFromPersona

func DefinitionFromPersona(p *persona.Persona, author string) Definition

DefinitionFromPersona converts a persona.Persona to a Definition.

func (*Definition) ToPersona

func (d *Definition) ToPersona() *persona.Persona

ToPersona converts a Definition to a persona.Persona.

type NoopStore

type NoopStore struct{}

NoopStore is a no-op implementation for when no database is available.

func (*NoopStore) Delete

func (*NoopStore) Delete(_ context.Context, _ string) error

Delete always returns ErrNotFound (no database available).

func (*NoopStore) Get

Get always returns ErrNotFound (no database available).

func (*NoopStore) List

func (*NoopStore) List(_ context.Context) ([]Definition, error)

List returns an empty list (no database available).

func (*NoopStore) Set

Set is a no-op (no database available).

type PostgresStore

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

PostgresStore implements Store backed by PostgreSQL.

func NewPostgresStore

func NewPostgresStore(db *sql.DB) *PostgresStore

NewPostgresStore creates a new PostgreSQL-backed persona store.

func (*PostgresStore) Delete

func (s *PostgresStore) Delete(ctx context.Context, name string) error

Delete removes a persona definition by name.

func (*PostgresStore) Get

func (s *PostgresStore) Get(ctx context.Context, name string) (*Definition, error)

Get returns a single persona definition by name.

func (*PostgresStore) List

func (s *PostgresStore) List(ctx context.Context) ([]Definition, error)

List returns all persona definitions.

func (*PostgresStore) Set

func (s *PostgresStore) Set(ctx context.Context, def Definition) error

Set creates or updates a persona definition.

type Store

type Store interface {
	List(ctx context.Context) ([]Definition, error)
	Get(ctx context.Context, name string) (*Definition, error)
	Set(ctx context.Context, def Definition) error
	Delete(ctx context.Context, name string) error
}

Store manages persona definition persistence.

Jump to

Keyboard shortcuts

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