{"action":"created","issue":{"url":"https://api.github.com/repos/lxc/lxd/issues/2566","repository_url":"https://api.github.com/repos/lxc/lxd","labels_url":"https://api.github.com/repos/lxc/lxd/issues/2566/labels{/name}","comments_url":"https://api.github.com/repos/lxc/lxd/issues/2566/comments","events_url":"https://api.github.com/repos/lxc/lxd/issues/2566/events","html_url":"https://github.com/lxc/lxd/pull/2566","id":185380579,"number":2566,"title":"[RFC] lxd: add SetExportProperties()","user":{"login":"brauner","id":7353573,"avatar_url":"https://avatars.githubusercontent.com/u/7353573?v=3","gravatar_id":"","url":"https://api.github.com/users/brauner","html_url":"https://github.com/brauner","followers_url":"https://api.github.com/users/brauner/followers","following_url":"https://api.github.com/users/brauner/following{/other_user}","gists_url":"https://api.github.com/users/brauner/gists{/gist_id}","starred_url":"https://api.github.com/users/brauner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brauner/subscriptions","organizations_url":"https://api.github.com/users/brauner/orgs","repos_url":"https://api.github.com/users/brauner/repos","events_url":"https://api.github.com/users/brauner/events{/privacy}","received_events_url":"https://api.github.com/users/brauner/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-10-26T12:34:14Z","updated_at":"2016-10-26T18:56:32Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/lxc/lxd/pulls/2566","html_url":"https://github.com/lxc/lxd/pull/2566","diff_url":"https://github.com/lxc/lxd/pull/2566.diff","patch_url":"https://github.com/lxc/lxd/pull/2566.patch"},"body":"lxc publish c --alias=test description=test age=32\r\n\r\nleads to the following calls\r\n- client.go:ImageFromContainer()\r\n- lxd/images.go:imagesPost()\r\n- lxd/images.go:imgPostContInfo()\r\n\r\nimgPostContInfo() in turn will call Export() and Export() takes care of actually\r\npublishing the image. After Export() returns it will have created the img\r\ntarfile. If we want to change the properties after that we would have to\r\nrecreate the tar archive just to update the metadata.yaml file which is wildly\r\ninefficient. And I'm not aware of an easy way to replace existing files in a tar\r\narchive. My proposal is thus to have a new function SetExportProperties() that\r\nallows users to specifiy properties that an image created from a container is\r\nsupposed to receive. In lxd/images.go:imgPostContInfo() we can then do:\r\n\r\n\t// Set properties the user wants the exported image to have.\r\n\tif len(req.Properties) != 0 {\r\n\t\tc.SetExportProperties(req.Properties)\r\n\t}\r\n\r\nprior to\r\n\r\n\tif err := c.Export(tarfile); err != nil {\r\n\t\ttarfile.Close()\r\n\t\treturn info, err\r\n\t}\r\n\ttarfile.Close()\r\n\r\nwhich means that the published image will have the requested properties at the\r\ntime of the publish operation. So when you export the image you will receive an\r\nupdated metadata.yaml file containing the properties requested.\r\n\r\nSigned-off-by: Christian Brauner <christian.brauner@canonical.com>\r\n\r\nCloses #2560."},"comment":{"url":"https://api.github.com/repos/lxc/lxd/issues/comments/256444062","html_url":"https://github.com/lxc/lxd/pull/2566#issuecomment-256444062","issue_url":"https://api.github.com/repos/lxc/lxd/issues/2566","id":256444062,"user":{"login":"stgraber","id":2230599,"avatar_url":"https://avatars.githubusercontent.com/u/2230599?v=3","gravatar_id":"","url":"https://api.github.com/users/stgraber","html_url":"https://github.com/stgraber","followers_url":"https://api.github.com/users/stgraber/followers","following_url":"https://api.github.com/users/stgraber/following{/other_user}","gists_url":"https://api.github.com/users/stgraber/gists{/gist_id}","starred_url":"https://api.github.com/users/stgraber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stgraber/subscriptions","organizations_url":"https://api.github.com/users/stgraber/orgs","repos_url":"https://api.github.com/users/stgraber/repos","events_url":"https://api.github.com/users/stgraber/events{/privacy}","received_events_url":"https://api.github.com/users/stgraber/received_events","type":"User","site_admin":false},"created_at":"2016-10-26T18:56:32Z","updated_at":"2016-10-26T18:56:32Z","body":"@brauner nah, that's internal API we can change that as needed."}}
{"actor":{"display_login":"stgraber"}}