From 3b66cac61795d8cdb3359ac6a5e1e69b1525e63a Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Thu, 13 Jun 2019 11:18:04 +0200 Subject: [PATCH] document HTTPConfig from struct --- common/http_config.go | 28 ++++++++++++++++--- website/source/docs/builders/qemu.html.md.erb | 23 ++++++--------- .../common/_HTTPConfig-not-required.html.md | 17 +++++++++++ .../partials/common/_HTTPConfig.html.md | 8 ++++++ 4 files changed, 57 insertions(+), 19 deletions(-) create mode 100644 website/source/partials/common/_HTTPConfig-not-required.html.md create mode 100644 website/source/partials/common/_HTTPConfig.html.md diff --git a/common/http_config.go b/common/http_config.go index 8a6809ac4..8e4c4845a 100644 --- a/common/http_config.go +++ b/common/http_config.go @@ -1,3 +1,5 @@ +//go:generate struct-markdown + package common import ( @@ -6,11 +8,29 @@ import ( "github.com/hashicorp/packer/template/interpolate" ) -// HTTPConfig contains configuration for the local HTTP Server +// Packer will create an http server serving `http_directory` when it is set, a +// random free port will be selected and the architecture of the directory +// referenced will be available in your builder. +// +// Example usage from a builder: +// +// `wget http://{{ .HTTPIP }}:{{ .HTTPPort }}/foo/bar/preseed.cfg` type HTTPConfig struct { - HTTPDir string `mapstructure:"http_directory"` - HTTPPortMin int `mapstructure:"http_port_min"` - HTTPPortMax int `mapstructure:"http_port_max"` + // Path to a directory to serve using an HTTP server. The files in this + // directory will be available over HTTP that will be requestable from the + // virtual machine. This is useful for hosting kickstart files and so on. + // By default this is an empty string, which means no HTTP server will be + // started. The address and port of the HTTP server will be available as + // variables in `boot_command`. This is covered in more detail below. + HTTPDir string `mapstructure:"http_directory"` + // These are the minimum and maximum port to use for the HTTP server + // started to serve the `http_directory`. Because Packer often runs in + // parallel, Packer will choose a randomly available port in this range to + // run the HTTP server. If you want to force the HTTP server to be on one + // port, make this minimum and maximum port the same. By default the values + // are `8000` and `9000`, respectively. + HTTPPortMin int `mapstructure:"http_port_min"` + HTTPPortMax int `mapstructure:"http_port_max"` } func (c *HTTPConfig) Prepare(ctx *interpolate.Context) []error { diff --git a/website/source/docs/builders/qemu.html.md.erb b/website/source/docs/builders/qemu.html.md.erb index 0dc543f1a..422965dde 100644 --- a/website/source/docs/builders/qemu.html.md.erb +++ b/website/source/docs/builders/qemu.html.md.erb @@ -90,7 +90,14 @@ Linux server and have not enabled X11 forwarding (`ssh -X`). <%= partial "partials/common/ISOConfig-not-required" %> -## Specific Configuration Reference +## Http directory configuration reference + +<%= partial "partials/common/HTTPConfig" %> +### Optional: + +<%= partial "partials/common/HTTPConfig-not-required" %> + +## Qemu Configuration Reference ### Optional: <%= partial "partials/builder/qemu/Config-not-required" %> @@ -129,20 +136,6 @@ DADA listed files must not exceed 1.44 MB. The supported ways to move large files into the OS are using `http_directory` or [the file provisioner](https://www.packer.io/docs/provisioners/file.html). -- `http_directory` (string) - Path to a directory to serve using an - HTTP server. The files in this directory will be available over HTTP that - will be requestable from the virtual machine. This is useful for hosting - kickstart files and so on. By default this is an empty string, which means - no HTTP server will be started. The address and port of the HTTP server will - be available as variables in `boot_command`. This is covered in more detail - below. - -- `http_port_min` and `http_port_max` (number) - These are the minimum and - maximum port to use for the HTTP server started to serve the - `http_directory`. Because Packer often runs in parallel, Packer will choose - a randomly available port in this range to run the HTTP server. If you want - to force the HTTP server to be on one port, make this minimum and maximum - port the same. By default the values are `8000` and `9000`, respectively. ## Boot Command diff --git a/website/source/partials/common/_HTTPConfig-not-required.html.md b/website/source/partials/common/_HTTPConfig-not-required.html.md new file mode 100644 index 000000000..7ad792afe --- /dev/null +++ b/website/source/partials/common/_HTTPConfig-not-required.html.md @@ -0,0 +1,17 @@ + + +- `http_directory` (string) - Path to a directory to serve using an HTTP server. The files in this + directory will be available over HTTP that will be requestable from the + virtual machine. This is useful for hosting kickstart files and so on. + By default this is an empty string, which means no HTTP server will be + started. The address and port of the HTTP server will be available as + variables in `boot_command`. This is covered in more detail below. + +- `http_port_min` (int) - These are the minimum and maximum port to use for the HTTP server + started to serve the `http_directory`. Because Packer often runs in + parallel, Packer will choose a randomly available port in this range to + run the HTTP server. If you want to force the HTTP server to be on one + port, make this minimum and maximum port the same. By default the values + are `8000` and `9000`, respectively. + +- `http_port_max` (int) - HTTP Port Max \ No newline at end of file diff --git a/website/source/partials/common/_HTTPConfig.html.md b/website/source/partials/common/_HTTPConfig.html.md new file mode 100644 index 000000000..225422086 --- /dev/null +++ b/website/source/partials/common/_HTTPConfig.html.md @@ -0,0 +1,8 @@ + +Packer will create an http server serving `http_directory` when it is set, a +random free port will be selected and the architecture of the directory +referenced will be available in your builder. + +Example usage from a builder: + + `wget http://{{ .HTTPIP }}:{{ .HTTPPort }}/foo/bar/preseed.cfg`