1
0
Fork 0
mirror of https://github.com/Luzifer/yaml-vault.git synced 2024-12-20 20:11:16 +00:00

Add state "absent" to delete keys

This commit is contained in:
Knut Ahlers 2016-10-05 13:21:14 +02:00
parent 471deae427
commit 142c3abea4
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

11
main.go
View file

@ -38,6 +38,7 @@ type importFile struct {
type importField struct {
Key string
State string
Values map[string]interface{}
}
@ -204,6 +205,15 @@ func importToVault(client *api.Client) error {
}
for _, field := range keys.Keys {
if field.State == "absent" {
if _, err := client.Logical().Delete(field.Key); err != nil {
if cfg.IgnoreErrors {
info("Error while deleting key '%s': %s", field.Key, err)
continue
}
return err
}
} else {
if _, err := client.Logical().Write(field.Key, field.Values); err != nil {
if cfg.IgnoreErrors {
info("Error while writing data to key '%s': %s", field.Key, err)
@ -213,6 +223,7 @@ func importToVault(client *api.Client) error {
}
debug("Successfully wrote data to key '%s'", field.Key)
}
}
return nil
}