Documentation
¶
Index ¶
- Constants
- func GetStorageDescription() string
- func IsKeychainAvailable() bool
- func IsUsingSecureStorage() bool
- func ResetStorage()
- type BackendType
- type FileStorage
- func (s *FileStorage) DeleteClientCredentials(site string) error
- func (s *FileStorage) DeleteTokens(site string) error
- func (s *FileStorage) GetBackendType() BackendType
- func (s *FileStorage) GetStorageLocation() string
- func (s *FileStorage) LoadClientCredentials(site string) (*types.ClientCredentials, error)
- func (s *FileStorage) LoadTokens(site string) (*types.TokenSet, error)
- func (s *FileStorage) SaveClientCredentials(site string, creds *types.ClientCredentials) error
- func (s *FileStorage) SaveTokens(site string, tokens *types.TokenSet) error
- type KeychainStorage
- func (s *KeychainStorage) DeleteClientCredentials(site string) error
- func (s *KeychainStorage) DeleteTokens(site string) error
- func (s *KeychainStorage) GetBackendType() BackendType
- func (s *KeychainStorage) GetStorageLocation() string
- func (s *KeychainStorage) LoadClientCredentials(site string) (*types.ClientCredentials, error)
- func (s *KeychainStorage) LoadTokens(site string) (*types.TokenSet, error)
- func (s *KeychainStorage) SaveClientCredentials(site string, creds *types.ClientCredentials) error
- func (s *KeychainStorage) SaveTokens(site string, tokens *types.TokenSet) error
- type Storage
- type StorageOptions
Constants ¶
const ( // KeychainTokenService is the service name for token keychain entries // Matches TypeScript PR #84: "datadog-cli" KeychainTokenService = "datadog-cli" // KeychainClientService is the service name for client credential keychain entries // Matches TypeScript PR #84: "datadog-cli-dcr" KeychainClientService = "datadog-cli-dcr" // TokenPrefix is the prefix for token keychain account names // Matches TypeScript PR #84: "oauth:" TokenPrefix = "oauth:" // ClientPrefix is the prefix for client credential keychain account names // Matches TypeScript PR #84: "client:" ClientPrefix = "client:" )
const (
// StorageEnvVar is the environment variable to override storage backend
StorageEnvVar = "DD_TOKEN_STORAGE"
)
Variables ¶
This section is empty.
Functions ¶
func GetStorageDescription ¶
func GetStorageDescription() string
GetStorageDescription returns a human-readable description of current storage
func IsKeychainAvailable ¶
func IsKeychainAvailable() bool
IsKeychainAvailable checks if keychain storage is available on this system
func IsUsingSecureStorage ¶
func IsUsingSecureStorage() bool
IsUsingSecureStorage returns true if keychain storage is active
func ResetStorage ¶
func ResetStorage()
ResetStorage clears the cached storage instance (for testing)
Types ¶
type BackendType ¶
type BackendType string
BackendType represents the type of storage backend
const ( BackendKeychain BackendType = "keychain" BackendFile BackendType = "file" )
func GetActiveBackend ¶
func GetActiveBackend() BackendType
GetActiveBackend returns the currently active storage backend type
type FileStorage ¶
type FileStorage struct {
// contains filtered or unexported fields
}
FileStorage implements Storage using encrypted files
func NewFileStorage ¶
func NewFileStorage() (*FileStorage, error)
NewFileStorage creates a new file-based storage
func (*FileStorage) DeleteClientCredentials ¶
func (s *FileStorage) DeleteClientCredentials(site string) error
DeleteClientCredentials deletes DCR client credentials
func (*FileStorage) DeleteTokens ¶
func (s *FileStorage) DeleteTokens(site string) error
DeleteTokens deletes OAuth2 tokens
func (*FileStorage) GetBackendType ¶
func (s *FileStorage) GetBackendType() BackendType
GetBackendType returns the backend type
func (*FileStorage) GetStorageLocation ¶
func (s *FileStorage) GetStorageLocation() string
GetStorageLocation returns the storage directory path
func (*FileStorage) LoadClientCredentials ¶
func (s *FileStorage) LoadClientCredentials(site string) (*types.ClientCredentials, error)
LoadClientCredentials loads DCR client credentials
func (*FileStorage) LoadTokens ¶
func (s *FileStorage) LoadTokens(site string) (*types.TokenSet, error)
LoadTokens loads OAuth2 tokens from file
func (*FileStorage) SaveClientCredentials ¶
func (s *FileStorage) SaveClientCredentials(site string, creds *types.ClientCredentials) error
SaveClientCredentials saves DCR client credentials
func (*FileStorage) SaveTokens ¶
func (s *FileStorage) SaveTokens(site string, tokens *types.TokenSet) error
SaveTokens saves OAuth2 tokens to file
type KeychainStorage ¶
type KeychainStorage struct {
// contains filtered or unexported fields
}
KeychainStorage stores OAuth tokens and credentials in the OS keychain Uses separate keyring services to match TypeScript PR #84
func NewKeychainStorage ¶
func NewKeychainStorage() (*KeychainStorage, error)
NewKeychainStorage creates a new keychain storage instance Opens two separate keychains to match TypeScript PR #84 architecture
func (*KeychainStorage) DeleteClientCredentials ¶
func (s *KeychainStorage) DeleteClientCredentials(site string) error
DeleteClientCredentials deletes OAuth client credentials for a site
func (*KeychainStorage) DeleteTokens ¶
func (s *KeychainStorage) DeleteTokens(site string) error
DeleteTokens deletes OAuth tokens for a site
func (*KeychainStorage) GetBackendType ¶
func (s *KeychainStorage) GetBackendType() BackendType
GetBackendType returns the backend type
func (*KeychainStorage) GetStorageLocation ¶
func (s *KeychainStorage) GetStorageLocation() string
GetStorageLocation returns a human-readable description
func (*KeychainStorage) LoadClientCredentials ¶
func (s *KeychainStorage) LoadClientCredentials(site string) (*types.ClientCredentials, error)
LoadClientCredentials loads OAuth client credentials for a site
func (*KeychainStorage) LoadTokens ¶
func (s *KeychainStorage) LoadTokens(site string) (*types.TokenSet, error)
LoadTokens loads OAuth tokens for a site
func (*KeychainStorage) SaveClientCredentials ¶
func (s *KeychainStorage) SaveClientCredentials(site string, creds *types.ClientCredentials) error
SaveClientCredentials saves OAuth client credentials for a site
func (*KeychainStorage) SaveTokens ¶
func (s *KeychainStorage) SaveTokens(site string, tokens *types.TokenSet) error
SaveTokens saves OAuth tokens for a site
type Storage ¶
type Storage interface {
// GetBackendType returns the type of storage backend
GetBackendType() BackendType
// GetStorageLocation returns a human-readable description of storage location
GetStorageLocation() string
// SaveTokens saves OAuth2 tokens
SaveTokens(site string, tokens *types.TokenSet) error
// LoadTokens loads OAuth2 tokens
LoadTokens(site string) (*types.TokenSet, error)
// DeleteTokens deletes OAuth2 tokens
DeleteTokens(site string) error
// SaveClientCredentials saves DCR client credentials
SaveClientCredentials(site string, creds *types.ClientCredentials) error
// LoadClientCredentials loads DCR client credentials
LoadClientCredentials(site string) (*types.ClientCredentials, error)
// DeleteClientCredentials deletes DCR client credentials
DeleteClientCredentials(site string) error
}
Storage interface for token and credential storage
func GetStorage ¶
func GetStorage(opts *StorageOptions) (Storage, error)
GetStorage returns a storage instance, automatically detecting the best backend
Selection priority:
- DD_TOKEN_STORAGE=file → use file storage
- DD_TOKEN_STORAGE=keychain → use keychain (fail if unavailable)
- Auto-detect: try keychain, fall back to file with warning
Example:
storage := GetStorage() // Auto-detect
storage := GetStorage(&StorageOptions{ForceBackend: BackendKeychain}) // Force keychain
type StorageOptions ¶
type StorageOptions struct {
// ForceBackend forces a specific storage backend
ForceBackend BackendType
// StorageDir overrides the storage directory (file backend only)
StorageDir string
}
StorageOptions configures storage backend selection