mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-04 01:26:09 +00:00
Patch CLI auto select file vault
# Description 📣
When we auto select file vault, we also need to set it's type. When we set the type, we don't need to fall back to file vault in the `GetValueInKeyring` and `DeleteValueInKeyring` because `currentVaultBackend` will be `file`.
Also rephrased the text asking the user to eneter a passphrase.
This commit is contained in:
@@ -32,9 +32,8 @@ func SetValueInKeyring(key, value string) error {
|
|||||||
configFile, _ := GetConfigFile()
|
configFile, _ := GetConfigFile()
|
||||||
|
|
||||||
if configFile.VaultBackendPassphrase == "" {
|
if configFile.VaultBackendPassphrase == "" {
|
||||||
PrintWarning("System keyring could not be used, falling back to `file` vault for sensitive data storage.")
|
|
||||||
passphrasePrompt := promptui.Prompt{
|
passphrasePrompt := promptui.Prompt{
|
||||||
Label: "Enter the passphrase to use for keyring encryption",
|
Label: "Enter a passphrase to protect your local backup secrets & login access token",
|
||||||
}
|
}
|
||||||
passphrase, err := passphrasePrompt.Run()
|
passphrase, err := passphrasePrompt.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -43,6 +42,7 @@ func SetValueInKeyring(key, value string) error {
|
|||||||
|
|
||||||
encodedPassphrase := base64.StdEncoding.EncodeToString([]byte(passphrase))
|
encodedPassphrase := base64.StdEncoding.EncodeToString([]byte(passphrase))
|
||||||
configFile.VaultBackendPassphrase = encodedPassphrase
|
configFile.VaultBackendPassphrase = encodedPassphrase
|
||||||
|
configFile.VaultBackendType = VAULT_BACKEND_FILE_MODE
|
||||||
err = WriteConfigFile(&configFile)
|
err = WriteConfigFile(&configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -65,12 +65,7 @@ func GetValueInKeyring(key string) (string, error) {
|
|||||||
PrintErrorAndExit(1, err, "Unable to get current vault. Tip: run [infisical reset] then try again")
|
PrintErrorAndExit(1, err, "Unable to get current vault. Tip: run [infisical reset] then try again")
|
||||||
}
|
}
|
||||||
|
|
||||||
value, err := keyring.Get(currentVaultBackend, MAIN_KEYRING_SERVICE, key)
|
return keyring.Get(currentVaultBackend, MAIN_KEYRING_SERVICE, key)
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
value, err = keyring.Get(VAULT_BACKEND_FILE_MODE, MAIN_KEYRING_SERVICE, key)
|
|
||||||
}
|
|
||||||
return value, err
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,11 +75,6 @@ func DeleteValueInKeyring(key string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = keyring.Delete(currentVaultBackend, MAIN_KEYRING_SERVICE, key)
|
return keyring.Delete(currentVaultBackend, MAIN_KEYRING_SERVICE, key)
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
err = keyring.Delete(VAULT_BACKEND_FILE_MODE, MAIN_KEYRING_SERVICE, key)
|
|
||||||
}
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user