From c1a7b3845a33090ef62b24c76e071326736dfb95 Mon Sep 17 00:00:00 2001 From: Chris Lundquist Date: Wed, 18 Oct 2017 04:57:13 +0000 Subject: [PATCH 1/2] [lxd] allow passing of publish properties --- builder/lxd/config.go | 9 +++++---- builder/lxd/step_publish.go | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/builder/lxd/config.go b/builder/lxd/config.go index 73de7212e..6a4745510 100644 --- a/builder/lxd/config.go +++ b/builder/lxd/config.go @@ -12,10 +12,11 @@ import ( type Config struct { common.PackerConfig `mapstructure:",squash"` - OutputImage string `mapstructure:"output_image"` - ContainerName string `mapstructure:"container_name"` - CommandWrapper string `mapstructure:"command_wrapper"` - Image string `mapstructure:"image"` + OutputImage string `mapstructure:"output_image"` + ContainerName string `mapstructure:"container_name"` + CommandWrapper string `mapstructure:"command_wrapper"` + Image string `mapstructure:"image"` + PublishProperties map[string]string `mapstructure:"publish_properties"` InitTimeout time.Duration ctx interpolate.Context diff --git a/builder/lxd/step_publish.go b/builder/lxd/step_publish.go index 0c0aabd3f..31e2d638b 100644 --- a/builder/lxd/step_publish.go +++ b/builder/lxd/step_publish.go @@ -32,6 +32,10 @@ func (s *stepPublish) Run(state multistep.StateBag) multistep.StepAction { "publish", name, "--alias", config.OutputImage, } + for k, v := range config.PublishProperties { + publish_args = append(publish_args, fmt.Sprintf("%s=%s", k, v)) + } + ui.Say("Publishing container...") stdoutString, err := LXDCommand(publish_args...) if err != nil { From 76f0176f5e39a85d26e3a1870a921237e09215ed Mon Sep 17 00:00:00 2001 From: Chris Lundquist Date: Wed, 18 Oct 2017 05:05:46 +0000 Subject: [PATCH 2/2] [lxd] add docs on publish properties --- website/source/docs/builders/lxd.html.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/website/source/docs/builders/lxd.html.md b/website/source/docs/builders/lxd.html.md index 56dca60c2..4915e1e28 100644 --- a/website/source/docs/builders/lxd.html.md +++ b/website/source/docs/builders/lxd.html.md @@ -31,11 +31,15 @@ Below is a fully functioning example. "name": "lxd-xenial", "image": "ubuntu-daily:xenial", "output_image": "ubuntu-xenial" + "publish_properties": { + "description": "Trivial repackage with Packer" + } } ] } ``` + ## Configuration Reference ### Required: @@ -56,5 +60,11 @@ Below is a fully functioning example. - `output_image` (string) - The name of the output artifact. Defaults to `name`. -- `command_wrapper` (string) - lets you prefix all builder commands, such as +- `command_wrapper` (string) - Lets you prefix all builder commands, such as with `ssh` for a remote build host. Defaults to `""`. + +- `publish_properties` (map[string]string) - Pass key values to the publish + step to be set as properties on the output image. This is most helpful to + set the description, but can be used to set anything needed. + See https://stgraber.org/2016/03/30/lxd-2-0-image-management-512/ + for more properties.