{"action":"created","issue":{"url":"https://api.github.com/repos/mevansam/terraform-provider-cf/issues/17","repository_url":"https://api.github.com/repos/mevansam/terraform-provider-cf","labels_url":"https://api.github.com/repos/mevansam/terraform-provider-cf/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/mevansam/terraform-provider-cf/issues/17/comments","events_url":"https://api.github.com/repos/mevansam/terraform-provider-cf/issues/17/events","html_url":"https://github.com/mevansam/terraform-provider-cf/pull/17","id":290258809,"number":17,"title":"[WIP] Allow complex objects in service credentials","user":{"login":"psycofdj","id":1496191,"avatar_url":"https://avatars1.githubusercontent.com/u/1496191?v=4","gravatar_id":"","url":"https://api.github.com/users/psycofdj","html_url":"https://github.com/psycofdj","followers_url":"https://api.github.com/users/psycofdj/followers","following_url":"https://api.github.com/users/psycofdj/following{/other_user}","gists_url":"https://api.github.com/users/psycofdj/gists{/gist_id}","starred_url":"https://api.github.com/users/psycofdj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/psycofdj/subscriptions","organizations_url":"https://api.github.com/users/psycofdj/orgs","repos_url":"https://api.github.com/users/psycofdj/repos","events_url":"https://api.github.com/users/psycofdj/events{/privacy}","received_events_url":"https://api.github.com/users/psycofdj/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-01-21T09:21:15Z","updated_at":"2018-02-01T14:00:33Z","closed_at":"2018-02-01T14:00:33Z","author_association":"COLLABORATOR","pull_request":{"url":"https://api.github.com/repos/mevansam/terraform-provider-cf/pulls/17","html_url":"https://github.com/mevansam/terraform-provider-cf/pull/17","diff_url":"https://github.com/mevansam/terraform-provider-cf/pull/17.diff","patch_url":"https://github.com/mevansam/terraform-provider-cf/pull/17.patch"},"body":"### Initial problem\r\n\r\nIn the present state of the provider, users are limited to flat key/value data in ```credentials``` of ```cf_user_provided_service``` resource while cloud foundry API allows any in-depth structures.\r\n\r\nThis limit is imposed by the type ```schema.TypeMap``` used in the ```credentials``` attribute that forces ```string``` elements in the map.\r\n\r\n### Considered approaches\r\n\r\n1. Change ```credentials``` attribute type to ```schema.TypeString``` and parse its JSON content\r\n    - (+) approach used in ```cf_service_instance.json_params```\r\n\r\n    - (-) would break backward-compatibility. \r\n       - Implementing a new attribute and setting the old map as deprecated would eventually force users to an unnecessary migration.\r\n\r\n    - (-) would arguably lead to less readable terraform files\r\n       - old style:\r\n         ```\r\n         credentials  {\r\n           host = \"localhost\"\r\n           port = \"8080\"\r\n         }\r\n         ```\r\n       - new style:\r\n         ```\r\n         credentials  = <<JSON\r\n           {\r\n             \"host\" : \"localhost\",\r\n             \"port\" : 8080\r\n           }\r\n         JSON\r\n         ```\r\n\r\n2. Keep ```schema.TypeMap``` and try a JSON parse on each string elements\r\n    - (+) backward compatible\r\n\r\n    - (-) error-prone behaviour\r\n       - the system relies on json validity to tell apart plain strings and json-object\r\n       - when user accidentally gives and invalid json string, the provider can't detect the error\r\n\r\n    - (+) a good compromise for terraform file readability\r\n       - sample:\r\n         ```\r\n         credentials  {\r\n           host = \"localhost\"\r\n           port = \"8080\"\r\n           extra = <<JSON\r\n           {\r\n              \"use_ssl\"  : false\r\n           }\r\n           JSON\r\n         }\r\n         ``` \r\n\r\n### The PR\r\n\r\nThis PR a working proof of concept that implements the second approach. Its purpose is to **initiate the discussions** about the problem more than be merged as it is.\r\n\r\nThe described problem is present in few existing resources, this PR modifies:\r\n- ```cf_user_provided_service.credentials```\r\n- ```cf_service_key.params```\r\n- ```cf_app.service_bindings.params```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/mevansam/terraform-provider-cf/issues/comments/362273947","html_url":"https://github.com/mevansam/terraform-provider-cf/pull/17#issuecomment-362273947","issue_url":"https://api.github.com/repos/mevansam/terraform-provider-cf/issues/17","id":362273947,"user":{"login":"psycofdj","id":1496191,"avatar_url":"https://avatars1.githubusercontent.com/u/1496191?v=4","gravatar_id":"","url":"https://api.github.com/users/psycofdj","html_url":"https://github.com/psycofdj","followers_url":"https://api.github.com/users/psycofdj/followers","following_url":"https://api.github.com/users/psycofdj/following{/other_user}","gists_url":"https://api.github.com/users/psycofdj/gists{/gist_id}","starred_url":"https://api.github.com/users/psycofdj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/psycofdj/subscriptions","organizations_url":"https://api.github.com/users/psycofdj/orgs","repos_url":"https://api.github.com/users/psycofdj/repos","events_url":"https://api.github.com/users/psycofdj/events{/privacy}","received_events_url":"https://api.github.com/users/psycofdj/received_events","type":"User","site_admin":false},"created_at":"2018-02-01T14:00:32Z","updated_at":"2018-02-01T14:00:32Z","author_association":"COLLABORATOR","body":"closed in favor to #24 "}}
{"actor":{"display_login":"psycofdj"}}