Documentation
¶
Index ¶
- Variables
- func BackupDotfilesSecrets(opts DotfilesSecretsOptions) error
- func CheckBitwardenLoginStatus() (bool, error)
- func DoctorDotfilesSecrets(opts DotfilesSecretsOptions) error
- func EnsureBitwardenSession() (string, error)
- func ExtractSSHKeyFromItem(item *BitwardenItem) (string, error)
- func IsVerbose(cmd *cobra.Command) bool
- func RestoreDotfilesSecrets(opts DotfilesSecretsOptions) error
- func SaveOrUpdateBitwardenSecret(name, secret, notes string) (string, error)
- func StartChildProcess(c *exec.Cmd) error
- func SyncDirectory(srcDir, destDir string, isVerbose bool) error
- func UnlockBitwardenVault() error
- func VerifyBitwardenSession(sess string) error
- type BitwardenField
- type BitwardenItem
- type BitwardenLogin
- type BitwardenSSHKey
- type DotfilesSecretsEntry
- type DotfilesSecretsManifest
- type DotfilesSecretsOptions
- type Spinner
Constants ¶
This section is empty.
Variables ¶
var Out io.Writer = os.Stderr
Out is the writer used for spinner output. Tests may replace it.
Functions ¶
func BackupDotfilesSecrets ¶ added in v1.9.0
func BackupDotfilesSecrets(opts DotfilesSecretsOptions) error
BackupDotfilesSecrets reads configured env files and saves their managed keys to bws.
func CheckBitwardenLoginStatus ¶
CheckBitwardenLoginStatus checks if the user is logged into Bitwarden.
func DoctorDotfilesSecrets ¶ added in v1.9.0
func DoctorDotfilesSecrets(opts DotfilesSecretsOptions) error
DoctorDotfilesSecrets validates manifest-driven secret mappings and templates.
func EnsureBitwardenSession ¶
EnsureBitwardenSession ensures the Bitwarden vault is unlocked and returns a session key. It first checks BW_SESSION and status; if locked, it prompts for the master password using `bw unlock --raw` and returns the session token. If unauthenticated, it attempts `bw login`.
func ExtractSSHKeyFromItem ¶
func ExtractSSHKeyFromItem(item *BitwardenItem) (string, error)
ExtractSSHKeyFromItem extracts SSH private key from a Bitwarden item.
func IsVerbose ¶
IsVerbose checks if the "verbose" flag is set for the given Cobra command. It first checks if the verbose flag is explicitly set on the command. If not, it falls back to the config value using viper.
Parameters:
- cmd: A pointer to a Cobra command from which the "verbose" flag is retrieved.
Returns:
- bool: True if the "verbose" flag is set to true, otherwise false.
func RestoreDotfilesSecrets ¶ added in v1.9.0
func RestoreDotfilesSecrets(opts DotfilesSecretsOptions) error
RestoreDotfilesSecrets recreates managed env files from templates and bws values.
func SaveOrUpdateBitwardenSecret ¶
SaveOrUpdateBitwardenSecret saves a secret value into Bitwarden under the given item name. If the item exists, it will be updated; otherwise it is created. A custom field named "eng-cli" with value "true" is added to tag usage by this CLI.
func StartChildProcess ¶
StartChildProcess starts a child process with the given exec.Cmd configuration. It sets up the standard input, output, and error streams to be the same as the parent process. Additionally, it captures interrupt signals (ctl + c) and forwards them to the child process.
Parameters:
- c: A pointer to an exec.Cmd struct representing the command to be executed.
Returns:
- error: An error if the command fails to start or exits with a non-zero status. Returns nil if the command completes successfully.
The function starts the command and waits for it to finish.
func SyncDirectory ¶
SyncDirectory synchronizes the contents of the source directory (srcDir) with the destination directory (destDir). It copies files and recursively syncs subdirectories. If isVerbose is true, it logs the files being copied.
Parameters:
- srcDir: The source directory to sync from.
- destDir: The destination directory to sync to.
- isVerbose: A boolean flag to enable verbose logging.
Returns:
- error: An error if any occurs during the synchronization process., otherwise nil.
func UnlockBitwardenVault ¶
func UnlockBitwardenVault() error
UnlockBitwardenVault prompts the user to unlock their Bitwarden vault.
func VerifyBitwardenSession ¶ added in v1.10.0
VerifyBitwardenSession checks if the current Bitwarden session is still valid.
Types ¶
type BitwardenField ¶
type BitwardenField struct {
Name string `json:"name"`
Value string `json:"value"`
Type int `json:"type"`
}
BitwardenField represents a custom field in a Bitwarden item.
type BitwardenItem ¶
type BitwardenItem struct {
ID string `json:"id"`
Name string `json:"name"`
Type int `json:"type,omitempty"`
Fields []BitwardenField `json:"fields,omitempty"`
Login *BitwardenLogin `json:"login,omitempty"`
Notes string `json:"notes,omitempty"`
SSHKey *BitwardenSSHKey `json:"sshKey,omitempty"`
}
BitwardenItem represents a Bitwarden vault item.
func FindSSHKeysInVault ¶
func FindSSHKeysInVault() ([]BitwardenItem, error)
FindSSHKeysInVault searches for SSH key items in the Bitwarden vault.
func GetBitwardenItem ¶
func GetBitwardenItem(name string) (*BitwardenItem, error)
GetBitwardenItem retrieves an item from Bitwarden vault by name.
func ListBitwardenItems ¶
func ListBitwardenItems() ([]BitwardenItem, error)
ListBitwardenItems returns all items in the vault (filtered by type if specified).
type BitwardenLogin ¶
type BitwardenLogin struct {
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
}
BitwardenLogin represents login credentials.
type BitwardenSSHKey ¶ added in v1.9.0
type BitwardenSSHKey struct {
PrivateKey string `json:"privateKey,omitempty"`
PublicKey string `json:"publicKey,omitempty"`
Fingerprint string `json:"fingerprint,omitempty"`
}
BitwardenSSHKey represents native SSH key payloads in Bitwarden items.
type DotfilesSecretsEntry ¶ added in v1.9.0
DotfilesSecretsEntry maps one env file to a bws prefix and the keys that should be managed.
type DotfilesSecretsManifest ¶ added in v1.9.0
type DotfilesSecretsManifest struct {
ProjectID string
Entries []DotfilesSecretsEntry
}
DotfilesSecretsManifest defines the tracked secret mappings for dotfiles env files.
func LoadDotfilesSecretsManifest ¶ added in v1.9.0
func LoadDotfilesSecretsManifest(manifestPath string) (*DotfilesSecretsManifest, error)
LoadDotfilesSecretsManifest parses the tracked manifest used for dotfiles secrets backup and restore.
type DotfilesSecretsOptions ¶ added in v1.9.0
type DotfilesSecretsOptions struct {
ManifestPath string
RootPath string
ProjectID string
Verbose bool
UseSpinner bool
}
DotfilesSecretsOptions configures manifest-driven backup and restore operations.
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner wraps the mpb.Progress container and a single bar. It's designed to manage a single progress bar and allow logging messages above the bar without disrupting it.
func NewProgressSpinner ¶
NewProgressSpinner creates a spinner that displays progress as a bar.
func NewSpinner ¶
NewSpinner creates a new spinner with a default indeterminate style.
func (*Spinner) SetProgressBar ¶
SetProgressBar sets the progress of the bar. Progress should be from 0.0 to 1.0.
func (*Spinner) Start ¶
func (s *Spinner) Start()
Start does nothing in this implementation, as the bar is visible on creation.
func (*Spinner) Stop ¶
func (s *Spinner) Stop()
Stop marks the bar as completed and waits for the progress container to finish.
func (*Spinner) UpdateMessage ¶
UpdateMessage updates the message displayed next to the spinner/bar.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package config is a helper package to facilitate getting and setting config values using Viper.
|
Package config is a helper package to facilitate getting and setting config values using Viper. |
|
Package log is a wrapper around colorizing the log output.
|
Package log is a wrapper around colorizing the log output. |