Documentation
¶
Index ¶
- Variables
- func MigrateFromJSON(ctx context.Context, store *Store, jsonPath, profileName string) error
- type ProfileInfo
- type Store
- func (s *Store) Delete(ctx context.Context, name string) error
- func (s *Store) Exists(ctx context.Context, name string) (bool, error)
- func (s *Store) List(ctx context.Context) ([]ProfileInfo, error)
- func (s *Store) Load(ctx context.Context, name string) (*config.Config, map[string]bool, error)
- func (s *Store) LoadActive(ctx context.Context) (string, *config.Config, map[string]bool, error)
- func (s *Store) Save(ctx context.Context, name string, cfg *config.Config, ...) error
- func (s *Store) SetActive(ctx context.Context, name string) error
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
Delete removes a profile by name. Returns an error if the profile is currently active.
func (*Store) List ¶
func (s *Store) List(ctx context.Context) ([]ProfileInfo, error)
List returns metadata for all profiles (no decryption needed).
func (*Store) Load ¶
Load decrypts and deserializes a named profile's configuration. Returns the config and explicitKeys (nil for legacy profiles).
func (*Store) LoadActive ¶
LoadActive loads the currently active profile's configuration. Returns the profile name, config, explicitKeys, and any error. explicitKeys may be nil for legacy profiles saved before Step 8.
func (*Store) Save ¶
func (s *Store) Save(ctx context.Context, name string, cfg *config.Config, explicitKeys map[string]bool) 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. PostLoad normalizes paths and validates the config in-place before persisting, so the stored form is always canonical. explicitKeys tracks which context-related keys the user explicitly set (may be nil).