Add comprehensive test coverage and fix empty branch issue
This commit is contained in:
@@ -27,9 +27,9 @@ func isValidVaultName(name string) bool {
|
||||
return matched
|
||||
}
|
||||
|
||||
// resolveVaultSymlink resolves the currentvault symlink by reading either the symlink target or file contents
|
||||
// ResolveVaultSymlink resolves the currentvault symlink by reading either the symlink target or file contents
|
||||
// This function is designed to work on both Unix and Windows systems, as well as with in-memory filesystems
|
||||
func resolveVaultSymlink(fs afero.Fs, symlinkPath string) (string, error) {
|
||||
func ResolveVaultSymlink(fs afero.Fs, symlinkPath string) (string, error) {
|
||||
secret.Debug("resolveVaultSymlink starting", "symlink_path", symlinkPath)
|
||||
|
||||
// First try to handle the path as a real symlink (works on Unix systems)
|
||||
@@ -121,7 +121,7 @@ func GetCurrentVault(fs afero.Fs, stateDir string) (*Vault, error) {
|
||||
|
||||
// Resolve the symlink to get the actual vault directory
|
||||
secret.Debug("Resolving vault symlink")
|
||||
targetPath, err := resolveVaultSymlink(fs, currentVaultPath)
|
||||
targetPath, err := ResolveVaultSymlink(fs, currentVaultPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -240,10 +240,9 @@ func SelectVault(fs afero.Fs, stateDir string, name string) error {
|
||||
// First try to remove existing symlink if it exists
|
||||
if _, err := fs.Stat(currentVaultPath); err == nil {
|
||||
secret.Debug("Removing existing current vault symlink", "path", currentVaultPath)
|
||||
if err := fs.Remove(currentVaultPath); err != nil {
|
||||
// On some systems, removing a symlink may fail
|
||||
// Just ignore and try to create/update it anyway
|
||||
}
|
||||
// Ignore errors from Remove as we'll try to create/update it anyway.
|
||||
// On some systems, removing a symlink may fail but the subsequent create may still succeed.
|
||||
_ = fs.Remove(currentVaultPath)
|
||||
}
|
||||
|
||||
// Try to create a real symlink first (works on Unix systems)
|
||||
|
||||
Reference in New Issue
Block a user