mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 11:37:01 -07:00
fix: secrets remove not updating local store and return error when not found
This commit is contained in:
parent
e38402edc3
commit
01a88beb97
1 changed files with 10 additions and 1 deletions
|
|
@ -203,13 +203,22 @@ var secretsRemoveCmd = &cobra.Command{
|
||||||
Short: "Remove secrets by IDs from secret store.",
|
Short: "Remove secrets by IDs from secret store.",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
for _, secretID := range args {
|
for _, secretID := range args {
|
||||||
|
// open secret store from file
|
||||||
store, err := secrets.OpenStore(secretsFile)
|
store, err := secrets.OpenStore(secretsFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
store.RemoveSecretByID(secretID)
|
// remove secret from store by it's ID
|
||||||
|
err = store.RemoveSecretByID(secretID)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("failed to remove secret: ", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// update store by saving to original file
|
||||||
|
secrets.SaveSecrets(secretsFile, store.(*secrets.LocalSecretStore).Secrets)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue