feat(vault-tui): implement KV client and service for managing secrets
- Added internal/vault/client.go for creating a Vault client with configuration settings. - Introduced internal/vault/errors.go to classify Vault API errors for better UI handling. - Created internal/vault/kv.go to manage KV secrets, including listing, reading, writing, and deleting operations. - Implemented internal/vault/mounts.go to list and describe secret engine mounts. - Developed internal/vault/service.go to provide a unified entry point for Vault operations. - Added internal/vault/kv_test.go for comprehensive testing of KV operations. - Introduced internal/ui/toast.go for transient notifications in the UI. - Added renovate.json for dependency management and updates.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
const (
|
||||
appDirName = "vault-tui"
|
||||
fileName = "config.yaml"
|
||||
configEnv = "VAULT_TUI_CONFIG"
|
||||
profileEnv = "VAULT_TUI_PROFILE"
|
||||
noEnvEnv = "VAULT_TUI_NO_ENV"
|
||||
readOnlyEnv = "VAULT_TUI_READ_ONLY"
|
||||
)
|
||||
|
||||
// DefaultPath returns the config file location used when neither --config
|
||||
// nor VAULT_TUI_CONFIG is set: $XDG_CONFIG_HOME/vault-tui/config.yaml,
|
||||
// falling back to ~/.config/vault-tui/config.yaml.
|
||||
func DefaultPath() (string, error) {
|
||||
dir, err := os.UserConfigDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return filepath.Join(dir, appDirName, fileName), nil
|
||||
}
|
||||
|
||||
// ResolvePath applies the discovery order: --config flag > VAULT_TUI_CONFIG
|
||||
// env > default XDG location.
|
||||
func ResolvePath(flag string) (string, error) {
|
||||
if flag != "" {
|
||||
return flag, nil
|
||||
}
|
||||
if v := os.Getenv(configEnv); v != "" {
|
||||
return v, nil
|
||||
}
|
||||
return DefaultPath()
|
||||
}
|
||||
|
||||
// StateDir returns the directory vault-tui uses for its own per-profile
|
||||
// token cache (internal/token/store_profile.go): $XDG_STATE_HOME/vault-tui,
|
||||
// falling back to ~/.local/state/vault-tui.
|
||||
func StateDir() (string, error) {
|
||||
if v := os.Getenv("XDG_STATE_HOME"); v != "" {
|
||||
return filepath.Join(v, appDirName), nil
|
||||
}
|
||||
home, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return filepath.Join(home, ".local", "state", appDirName), nil
|
||||
}
|
||||
Reference in New Issue
Block a user