{"action":"created","issue":{"url":"https://api.github.com/repos/gophercloud/gophercloud/issues/86","repository_url":"https://api.github.com/repos/gophercloud/gophercloud","labels_url":"https://api.github.com/repos/gophercloud/gophercloud/issues/86/labels{/name}","comments_url":"https://api.github.com/repos/gophercloud/gophercloud/issues/86/comments","events_url":"https://api.github.com/repos/gophercloud/gophercloud/issues/86/events","html_url":"https://github.com/gophercloud/gophercloud/issues/86","id":174964143,"number":86,"title":"Issue creating server with metadata","user":{"login":"jtopjian","id":46959,"avatar_url":"https://avatars.githubusercontent.com/u/46959?v=3","gravatar_id":"","url":"https://api.github.com/users/jtopjian","html_url":"https://github.com/jtopjian","followers_url":"https://api.github.com/users/jtopjian/followers","following_url":"https://api.github.com/users/jtopjian/following{/other_user}","gists_url":"https://api.github.com/users/jtopjian/gists{/gist_id}","starred_url":"https://api.github.com/users/jtopjian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtopjian/subscriptions","organizations_url":"https://api.github.com/users/jtopjian/orgs","repos_url":"https://api.github.com/users/jtopjian/repos","events_url":"https://api.github.com/users/jtopjian/events{/privacy}","received_events_url":"https://api.github.com/users/jtopjian/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-09-04T18:59:13Z","updated_at":"2016-09-06T16:13:36Z","closed_at":null,"body":"When creating a server with metadata in the Create request, the metadata is not being recognized.\r\n\r\nUpon digging into why, I've found a few metadata inconsistencies but am not sure what the best overall fix would be:\r\n\r\n1. `Metadata` is defined in the [request](https://github.com/gophercloud/gophercloud/blob/a4d4930ed40c27a2c51486d2de6880f36fe74bd4/openstack/compute/v2/servers/requests.go#L159) as a `map[string]string` but is a `map[string]interface{}` in the [result](https://github.com/gophercloud/gophercloud/blob/a4d4930ed40c27a2c51486d2de6880f36fe74bd4/openstack/compute/v2/servers/results.go#L157). This has not changed from the Rackspace code, but should either one or the other be used in both places? \r\n\r\n2. The JSON tag in the request is declaring to omit the `metadata` field. This is used in some other areas of the request, but I believe that is so those fields can be given extra attention in the [ToServerCreateMap](https://github.com/gophercloud/gophercloud/blob/a4d4930ed40c27a2c51486d2de6880f36fe74bd4/openstack/compute/v2/servers/requests.go#L184).\r\n\r\nI believe it is the addition of this JSON tag that is ultimately causing the metadata to not be recognized during the creation. But should the `CreateOpts` be changed to:\r\n\r\n```go\r\nMetadata map[string]string `json:\"metadata,omitempty\"`\r\n```\r\n\r\nOr should something like the following be added to `ToServerCreateMap`:\r\n\r\n```go\r\nif len(opts.Metadata) > 0 {\r\n  metadata := make(map[string]string, len(opts.Metadata))\r\n  for k, v := range opts.Metadata {\r\n    metadata[k] = v\r\n  }\r\n  b[\"metadata\"] = metadata\r\n}\r\n```\r\n\r\nI'm inclined to go with just the JSON tag, but wanted to ask in case there's a reason for the latter."},"comment":{"url":"https://api.github.com/repos/gophercloud/gophercloud/issues/comments/245003443","html_url":"https://github.com/gophercloud/gophercloud/issues/86#issuecomment-245003443","issue_url":"https://api.github.com/repos/gophercloud/gophercloud/issues/86","id":245003443,"user":{"login":"jrperritt","id":1733222,"avatar_url":"https://avatars.githubusercontent.com/u/1733222?v=3","gravatar_id":"","url":"https://api.github.com/users/jrperritt","html_url":"https://github.com/jrperritt","followers_url":"https://api.github.com/users/jrperritt/followers","following_url":"https://api.github.com/users/jrperritt/following{/other_user}","gists_url":"https://api.github.com/users/jrperritt/gists{/gist_id}","starred_url":"https://api.github.com/users/jrperritt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrperritt/subscriptions","organizations_url":"https://api.github.com/users/jrperritt/orgs","repos_url":"https://api.github.com/users/jrperritt/repos","events_url":"https://api.github.com/users/jrperritt/events{/privacy}","received_events_url":"https://api.github.com/users/jrperritt/received_events","type":"User","site_admin":false},"created_at":"2016-09-06T16:13:36Z","updated_at":"2016-09-06T16:13:36Z","body":"The `metadata` in the result should be changed to `map[string]string` as well."}}
{"actor":{"display_login":"jrperritt"}}