Skip to content
This repository has been archived by the owner on Nov 14, 2020. It is now read-only.

Commit

Permalink
resource_binding: Fix read with argument_json.
Browse files Browse the repository at this point in the history
If user filled the arguments with the json fields, we need to compare with it to avoid non empty plan.
  • Loading branch information
cyrilgdn committed Jul 17, 2020
1 parent ebe79b0 commit a87cddc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion rabbitmq/resource_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,16 @@ func ReadBinding(d *schema.ResourceData, meta interface{}) error {
d.Set("destination_type", binding.DestinationType)
d.Set("routing_key", binding.RoutingKey)
d.Set("properties_key", binding.PropertiesKey)
d.Set("arguments", binding.Arguments)

if v, ok := d.Get("arguments_json").(string); ok && v != "" {
bytes, err := json.Marshal(binding.Arguments)
if err != nil {
return fmt.Errorf("could not encode arguments as JSON: %w", err)
}
d.Set("arguments_json", string(bytes))
} else {
d.Set("arguments", binding.Arguments)
}
}
}

Expand Down

0 comments on commit a87cddc

Please sign in to comment.