Skip to content

Commit

Permalink
Merge pull request #318 from lawliet89/fix-backend-role
Browse files Browse the repository at this point in the history
Fix some issues with updating fields for several resources
  • Loading branch information
Becca Petrin authored Mar 5, 2019
2 parents 28aa17d + 95a1205 commit 17e897f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
9 changes: 6 additions & 3 deletions vault/resource_gcp_auth_backend_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func gcpAuthBackendRoleResource() *schema.Resource {
"add_group_aliases": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
"max_jwt_exp": {
Type: schema.TypeString,
Expand Down Expand Up @@ -165,15 +166,15 @@ func gcpRoleUpdateFields(d *schema.ResourceData, data map[string]interface{}) {
data["bound_service_accounts"] = v.(*schema.Set).List()
}

if v, ok := d.GetOk("add_group_aliases"); ok {
if v, ok := d.GetOkExists("add_group_aliases"); ok {
data["add_group_aliases"] = v.(bool)
}

if v, ok := d.GetOk("max_jwt_exp"); ok {
data["max_jwt_exp"] = v.(string)
}

if v, ok := d.GetOk("allow_gce_inference"); ok {
if v, ok := d.GetOkExists("allow_gce_inference"); ok {
data["allow_gce_inference"] = v.(bool)
}

Expand Down Expand Up @@ -253,7 +254,9 @@ func gcpAuthResourceRead(d *schema.ResourceData, meta interface{}) error {

for _, k := range []string{"ttl", "max_ttl", "project_id", "bound_projects", "period", "policies", "add_group_aliases", "max_jwt_exp", "bound_service_accounts", "bound_zones", "bound_regions", "bound_instance_groups", "bound_labels"} {
if v, ok := resp.Data[k]; ok {
d.Set(k, v)
if err := d.Set(k, v); err != nil {
return fmt.Errorf("error reading %s for GCP Auth Backend Role %q: %q", k, path, err)
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion vault/resource_identity_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ func identityGroupRead(d *schema.ResourceData, meta interface{}) error {
}

for _, k := range []string{"name", "type", "metadata", "policies", "member_entity_ids", "member_group_ids"} {
d.Set(k, resp.Data[k])
if v, ok := resp.Data[k]; ok {
if err := d.Set(k, v); err != nil {
return fmt.Errorf("error reading %s for Identity Group %q: %q", k, path, err)
}
}
}
return nil
}
Expand Down
6 changes: 5 additions & 1 deletion vault/resource_kubernetes_auth_backend_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,11 @@ func kubernetesAuthBackendRoleRead(d *schema.ResourceData, meta interface{}) err
d.Set("role_name", role)

for _, k := range []string{"bound_cidrs", "bound_service_account_names", "bound_service_account_namespaces", "num_uses", "policies", "ttl", "max_ttl", "period"} {
d.Set(k, resp.Data[k])
if v, ok := resp.Data[k]; ok {
if err := d.Set(k, v); err != nil {
return fmt.Errorf("error reading %s for Kubernetes Auth Backend Role %q: %q", k, path, err)
}
}
}

return nil
Expand Down

0 comments on commit 17e897f

Please sign in to comment.