Skip to content

Commit

Permalink
No hard break on allow_read.
Browse files Browse the repository at this point in the history
Deprecate allow_read instead of removing it outright.
  • Loading branch information
paddycarver committed Sep 11, 2017
1 parent e3fdce1 commit 9451ae6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 13 additions & 0 deletions vault/resource_generic_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ func genericSecretResource() *schema.Resource {
ValidateFunc: ValidateDataJSON,
},

"allow_read": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Description: "Attempt to read the token from Vault if true; if false, drift won't be detected.",
Deprecated: "Please use disable_read instead.",
},

"disable_read": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -124,6 +131,12 @@ func genericSecretResourceDelete(d *schema.ResourceData, meta interface{}) error

func genericSecretResourceRead(d *schema.ResourceData, meta interface{}) error {
shouldRead := !d.Get("disable_read").(bool)
if !shouldRead {
// if disable_read is set to false or unset (we can't know which)
// and allow_read is set to true, go with allow_read.
shouldRead = d.Get("allow_read").(bool)
}

path := d.Id()

if shouldRead {
Expand Down
1 change: 0 additions & 1 deletion vault/resource_generic_secret_migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func migrateGenericSecretStateV0toV1(s *terraform.InstanceState) (*terraform.Ins
if disabledRead {
s.Attributes["disable_read"] = "true"
}
delete(s.Attributes, "allow_read")

log.Printf("[DEBUG] Attributes after migration: %#v:", s.Attributes)
return s, nil
Expand Down

0 comments on commit 9451ae6

Please sign in to comment.