configstore

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrProfileNotFound = errors.New("profile not found")
	ErrNoActiveProfile = errors.New("no active profile")
	ErrDeleteActive    = errors.New("cannot delete the active profile")
)

Sentinel errors for configstore operations.

Functions

func MigrateFromJSON

func MigrateFromJSON(ctx context.Context, store *Store, jsonPath, profileName string) error

MigrateFromJSON reads a JSON config file and imports it as an encrypted profile. The imported profile is set as the active profile.

Types

type ProfileInfo

type ProfileInfo struct {
	Name      string
	Active    bool
	Version   int
	CreatedAt time.Time
	UpdatedAt time.Time
}

ProfileInfo holds metadata about a configuration profile.

type Store

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

Store manages encrypted configuration profiles.

func NewStore

func NewStore(client *ent.Client, crypto security.CryptoProvider) *Store

NewStore creates a new configuration store.

func (*Store) Delete

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

Delete removes a profile by name. Returns an error if the profile is currently active.

func (*Store) Exists

func (s *Store) Exists(ctx context.Context, name string) (bool, error)

Exists checks if a profile with the given name exists.

func (*Store) List

func (s *Store) List(ctx context.Context) ([]ProfileInfo, error)

List returns metadata for all profiles (no decryption needed).

func (*Store) Load

func (s *Store) Load(ctx context.Context, name string) (*config.Config, error)

Load decrypts and deserializes a named profile's configuration.

func (*Store) LoadActive

func (s *Store) LoadActive(ctx context.Context) (string, *config.Config, error)

LoadActive loads the currently active profile's configuration. Returns the profile name, config, and any error.

func (*Store) Save

func (s *Store) Save(ctx context.Context, name string, cfg *config.Config) error

Save serializes the config to JSON, encrypts it, and stores it as a profile. If a profile with the given name already exists, it is updated.

func (*Store) SetActive

func (s *Store) SetActive(ctx context.Context, name string) error

SetActive deactivates all profiles and activates the named profile.

Jump to

Keyboard shortcuts

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