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

Queue: Add json_arguments parameter #6

Merged
merged 2 commits into from
Sep 26, 2017

Conversation

jtopjian
Copy link
Contributor

This commit adds the json_arguments parameter to the
rabbitmq_queue resource. This can accept a JSON string
which is useful for argument values which are not strings.

For #1

@dmportella
Copy link

nice!!!

This commit adds the json_arguments parameter to the
rabbitmq_queue resource. This can accept a JSON string
which is useful for argument values which are not strings.
@jtopjian jtopjian force-pushed the queue-json_arguments branch from ff9366d to f78b0cd Compare September 20, 2017 15:10
@@ -75,6 +84,19 @@ func CreateQueue(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Unable to parse settings")
}

// If json_arguments is used, unmarshal it into a generic interface
// and use it as the "arguments" key for the queue.
if v, ok := settingsMap["json_arguments"].(string); ok && v != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as mentioned on Slack, would this make more sense as an interpolation function passed into arguments? i.e.

arguments = "${json_to_map("{ "hello": "world" })"

@jtopjian
Copy link
Contributor Author

@tombuildsstuff Per our discussion in Slack, updated with arguments_json as the parameter name.

Also, for posterity, summary of today's discussion:

Having an interpolation function is the best method, but due to the way the Terraform schema handles maps, all values would still be converted to a string. There are plans to fix this in the future. For now, the method that arguments_json implements is the de-facto solution. Down the road, it should be possible to move back to the original arguments parameter and have values correctly parsed as their native type.

@dmportella
Copy link

nice one glad it all got sorted out

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

@jtopjian
Copy link
Contributor Author

Thanks, @tombuildsstuff!

@jtopjian jtopjian merged commit 550a357 into hashicorp:master Sep 26, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants