Documentation
¶
Overview ¶
Package store provides persistent storage implementations for the CLI Proxy API.
Index ¶
- type FileStore
- type GitTokenStore
- func (s *GitTokenStore) AuthDir() string
- func (s *GitTokenStore) ConfigPath() string
- func (s *GitTokenStore) Delete(_ context.Context, id string) error
- func (s *GitTokenStore) EnsureRepository() error
- func (s *GitTokenStore) List(_ context.Context) ([]*cliproxyauth.Auth, error)
- func (s *GitTokenStore) PersistAuthFiles(_ context.Context, message string, paths ...string) error
- func (s *GitTokenStore) PersistConfig(_ context.Context) error
- func (s *GitTokenStore) Save(_ context.Context, auth *cliproxyauth.Auth) (string, error)
- func (s *GitTokenStore) SetBaseDir(dir string)
- type ObjectStoreConfig
- type ObjectTokenStore
- func (s *ObjectTokenStore) AuthDir() string
- func (s *ObjectTokenStore) Bootstrap(ctx context.Context, exampleConfigPath string) error
- func (s *ObjectTokenStore) ConfigPath() string
- func (s *ObjectTokenStore) Delete(ctx context.Context, id string) error
- func (s *ObjectTokenStore) List(_ context.Context) ([]*cliproxyauth.Auth, error)
- func (s *ObjectTokenStore) PersistAuthFiles(ctx context.Context, _ string, paths ...string) error
- func (s *ObjectTokenStore) PersistConfig(ctx context.Context) error
- func (s *ObjectTokenStore) Save(ctx context.Context, auth *cliproxyauth.Auth) (string, error)
- func (s *ObjectTokenStore) SetBaseDir(string)
- type PostgresStore
- func (s *PostgresStore) AuthDir() string
- func (s *PostgresStore) Bootstrap(ctx context.Context, exampleConfigPath string) error
- func (s *PostgresStore) Close() error
- func (s *PostgresStore) ConfigPath() string
- func (s *PostgresStore) Delete(ctx context.Context, id string) error
- func (s *PostgresStore) EnsureSchema(ctx context.Context) error
- func (s *PostgresStore) List(ctx context.Context) ([]*cliproxyauth.Auth, error)
- func (s *PostgresStore) LoadUsageStatistics(ctx context.Context) ([]byte, error)
- func (s *PostgresStore) PersistAuthFiles(ctx context.Context, _ string, paths ...string) error
- func (s *PostgresStore) PersistConfig(ctx context.Context) error
- func (s *PostgresStore) Save(ctx context.Context, auth *cliproxyauth.Auth) (string, error)
- func (s *PostgresStore) SaveUsageStatistics(ctx context.Context, data []byte) error
- func (s *PostgresStore) SetBaseDir(string)
- func (s *PostgresStore) WorkDir() string
- type PostgresStoreConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
FileStore implements file-based persistent storage for usage statistics. It stores usage statistics as a JSON file in a configured directory, following the same pattern as OAuth credential storage.
func NewFileStore ¶
NewFileStore creates a new file-based storage instance. The baseDir parameter specifies the directory where the usage statistics file will be stored. If baseDir is empty or does not exist, an error is returned.
func (*FileStore) LoadUsageStatistics ¶
LoadUsageStatistics retrieves the usage statistics snapshot from the JSON file. If the file does not exist, it returns nil without error (indicating no previous statistics). If the file exists but cannot be read, an error is returned.
func (*FileStore) SaveUsageStatistics ¶
SaveUsageStatistics persists the usage statistics snapshot to a JSON file. The data parameter should be a JSON-encoded byte slice. The file is written atomically using a temporary file and rename.
type GitTokenStore ¶
type GitTokenStore struct {
// contains filtered or unexported fields
}
GitTokenStore persists token records and auth metadata using git as the backing storage.
func NewGitTokenStore ¶
func NewGitTokenStore(remote, username, password string) *GitTokenStore
NewGitTokenStore creates a token store that saves credentials to disk through the TokenStorage implementation embedded in the token record.
func (*GitTokenStore) AuthDir ¶
func (s *GitTokenStore) AuthDir() string
AuthDir returns the directory used for auth persistence.
func (*GitTokenStore) ConfigPath ¶
func (s *GitTokenStore) ConfigPath() string
ConfigPath returns the managed config file path.
func (*GitTokenStore) Delete ¶
func (s *GitTokenStore) Delete(_ context.Context, id string) error
Delete removes the auth file.
func (*GitTokenStore) EnsureRepository ¶
func (s *GitTokenStore) EnsureRepository() error
EnsureRepository prepares the local git working tree by cloning or opening the repository.
func (*GitTokenStore) List ¶
func (s *GitTokenStore) List(_ context.Context) ([]*cliproxyauth.Auth, error)
List enumerates all auth JSON files under the configured directory.
func (*GitTokenStore) PersistAuthFiles ¶
PersistAuthFiles commits and pushes the provided paths to the remote repository. It no-ops when the store is not fully configured or when there are no paths.
func (*GitTokenStore) PersistConfig ¶
func (s *GitTokenStore) PersistConfig(_ context.Context) error
PersistConfig commits and pushes configuration changes to git.
func (*GitTokenStore) Save ¶
func (s *GitTokenStore) Save(_ context.Context, auth *cliproxyauth.Auth) (string, error)
Save persists token storage and metadata to the resolved auth file path.
func (*GitTokenStore) SetBaseDir ¶
func (s *GitTokenStore) SetBaseDir(dir string)
SetBaseDir updates the default directory used for auth JSON persistence when no explicit path is provided.
type ObjectStoreConfig ¶
type ObjectStoreConfig struct {
Endpoint string
Bucket string
AccessKey string
SecretKey string
Region string
Prefix string
LocalRoot string
UseSSL bool
PathStyle bool
}
ObjectStoreConfig captures configuration for the object storage-backed token store.
type ObjectTokenStore ¶
type ObjectTokenStore struct {
// contains filtered or unexported fields
}
ObjectTokenStore persists configuration and authentication metadata using an S3-compatible object storage backend. Files are mirrored to a local workspace so existing file-based flows continue to operate.
func NewObjectTokenStore ¶
func NewObjectTokenStore(cfg ObjectStoreConfig) (*ObjectTokenStore, error)
NewObjectTokenStore initializes an object storage backed token store.
func (*ObjectTokenStore) AuthDir ¶
func (s *ObjectTokenStore) AuthDir() string
AuthDir returns the local directory containing mirrored auth files.
func (*ObjectTokenStore) Bootstrap ¶
func (s *ObjectTokenStore) Bootstrap(ctx context.Context, exampleConfigPath string) error
Bootstrap ensures the target bucket exists and synchronizes data from the object storage backend.
func (*ObjectTokenStore) ConfigPath ¶
func (s *ObjectTokenStore) ConfigPath() string
ConfigPath returns the managed configuration file path inside the spool directory.
func (*ObjectTokenStore) Delete ¶
func (s *ObjectTokenStore) Delete(ctx context.Context, id string) error
Delete removes an auth file locally and remotely.
func (*ObjectTokenStore) List ¶
func (s *ObjectTokenStore) List(_ context.Context) ([]*cliproxyauth.Auth, error)
List enumerates auth JSON files from the mirrored workspace.
func (*ObjectTokenStore) PersistAuthFiles ¶
PersistAuthFiles uploads the provided auth files to the object storage backend.
func (*ObjectTokenStore) PersistConfig ¶
func (s *ObjectTokenStore) PersistConfig(ctx context.Context) error
PersistConfig uploads the local configuration file to the object storage backend.
func (*ObjectTokenStore) Save ¶
func (s *ObjectTokenStore) Save(ctx context.Context, auth *cliproxyauth.Auth) (string, error)
Save persists authentication metadata to disk and uploads it to the object storage backend.
func (*ObjectTokenStore) SetBaseDir ¶
func (s *ObjectTokenStore) SetBaseDir(string)
SetBaseDir implements the optional interface used by authenticators; it is a no-op because the object store controls its own workspace.
type PostgresStore ¶
type PostgresStore struct {
// contains filtered or unexported fields
}
PostgresStore persists configuration and authentication metadata using PostgreSQL as backend while mirroring data to a local workspace so existing file-based workflows continue to operate.
func NewPostgresStore ¶
func NewPostgresStore(ctx context.Context, cfg PostgresStoreConfig) (*PostgresStore, error)
NewPostgresStore establishes a connection to PostgreSQL and prepares the local workspace.
func (*PostgresStore) AuthDir ¶
func (s *PostgresStore) AuthDir() string
AuthDir returns the local directory containing mirrored auth files.
func (*PostgresStore) Bootstrap ¶
func (s *PostgresStore) Bootstrap(ctx context.Context, exampleConfigPath string) error
Bootstrap synchronizes configuration and auth records between PostgreSQL and the local workspace.
func (*PostgresStore) Close ¶
func (s *PostgresStore) Close() error
Close releases the underlying database connection.
func (*PostgresStore) ConfigPath ¶
func (s *PostgresStore) ConfigPath() string
ConfigPath returns the managed configuration file path inside the spool directory.
func (*PostgresStore) Delete ¶
func (s *PostgresStore) Delete(ctx context.Context, id string) error
Delete removes an auth file and the corresponding database record.
func (*PostgresStore) EnsureSchema ¶
func (s *PostgresStore) EnsureSchema(ctx context.Context) error
EnsureSchema creates the required tables (and schema when provided).
func (*PostgresStore) List ¶
func (s *PostgresStore) List(ctx context.Context) ([]*cliproxyauth.Auth, error)
List enumerates all auth records stored in PostgreSQL.
func (*PostgresStore) LoadUsageStatistics ¶
func (s *PostgresStore) LoadUsageStatistics(ctx context.Context) ([]byte, error)
LoadUsageStatistics retrieves usage statistics snapshot from PostgreSQL.
func (*PostgresStore) PersistAuthFiles ¶
PersistAuthFiles stores the provided auth file changes in PostgreSQL.
func (*PostgresStore) PersistConfig ¶
func (s *PostgresStore) PersistConfig(ctx context.Context) error
PersistConfig mirrors the local configuration file to PostgreSQL.
func (*PostgresStore) Save ¶
func (s *PostgresStore) Save(ctx context.Context, auth *cliproxyauth.Auth) (string, error)
Save persists authentication metadata to disk and PostgreSQL.
func (*PostgresStore) SaveUsageStatistics ¶
func (s *PostgresStore) SaveUsageStatistics(ctx context.Context, data []byte) error
SaveUsageStatistics persists usage statistics snapshot to PostgreSQL.
func (*PostgresStore) SetBaseDir ¶
func (s *PostgresStore) SetBaseDir(string)
SetBaseDir implements the optional interface used by authenticators; it is a no-op because the Postgres-backed store controls its own workspace.
func (*PostgresStore) WorkDir ¶
func (s *PostgresStore) WorkDir() string
WorkDir exposes the root spool directory used for mirroring.