Refuse an existing vault before asking for the mnemonic (closes #151)
check / check (push) Waiting to run
check / check (push) Waiting to run
`secret init` and `secret vault create` asked for the mnemonic and the unlocker passphrase, and `secret init` printed "Initialized secrets manager at", before refusing a vault that already exists. The check `vault.CreateVault` made before writing is now `vault.CheckNewVaultName`, which both commands call while holding the state directory lock, before the first prompt; `CreateVault` still calls it. `secret init` prints the "Initialized" line only once the vault is created, so `TestMnemonicNotReadNamesOnlyMnemonic` no longer expects it. Judgement call: the same check validates the name, so `secret vault create` with an invalid name also fails before the prompts. Model: opus-5-5
This commit is contained in:
@@ -267,6 +267,12 @@ func (cli *Instance) CreateVault(cmd *cobra.Command, name string) error {
|
||||
}
|
||||
defer release()
|
||||
|
||||
// Refuse an invalid name or an existing vault before asking for anything
|
||||
err = vault.CheckNewVaultName(cli.fs, cli.stateDir, name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mnemonic, cleanupMnemonic, err := cli.promptMnemonic()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user