A cross-vault secret mv that cannot remove the source fails (closes #159)
check / check (push) Waiting to run
check / check (push) Waiting to run
When `secret mv` copied a secret into another vault but could not remove the source, it printed a warning and the usual "Moved" line and exited 0, so a script could not tell that the secret was now in both vaults. It now prints no "Moved" line and fails with an error saying that the copy holds all versions and the source remains. The test is in package cli and calls moveSecret, because the state directory lock refuses the wrapped filesystem that makes the removal fail. Judgement call: if the source is moved aside but the temporary directory holding it cannot then be deleted, the error still says the source remains. Model: opus-5-5
This commit is contained in:
@@ -1097,12 +1097,10 @@ func (cli *Instance) moveSecretCrossVault(
|
||||
// Delete source secret
|
||||
err = secret.RemoveDirAtomic(cli.fs, srcSecretDir)
|
||||
if err != nil {
|
||||
// Copy succeeded but delete failed - warn but don't fail
|
||||
cmd.Printf("Warning: copied secret but failed to remove source: %v\n", err)
|
||||
cmd.Printf("Moved secret '%s:%s' to '%s:%s' (%d version(s))\n",
|
||||
srcVault.Name, srcSecretName, destVault.Name, destSecretName, versionCount)
|
||||
|
||||
return nil
|
||||
return fmt.Errorf("secret '%s:%s' is copied with all %d version(s) "+
|
||||
"to '%s:%s', but the source remains: %w",
|
||||
srcVault.Name, srcSecretName, versionCount,
|
||||
destVault.Name, destSecretName, err)
|
||||
}
|
||||
|
||||
cmd.Printf("Moved secret '%s:%s' to '%s:%s' (%d version(s))\n",
|
||||
|
||||
Reference in New Issue
Block a user