document HTTPConfig from struct

This commit is contained in:
Adrien Delorme 2019-06-13 11:18:04 +02:00
parent 76f50619b1
commit 3b66cac617
4 changed files with 57 additions and 19 deletions

View File

@ -1,3 +1,5 @@
//go:generate struct-markdown
package common package common
import ( import (
@ -6,9 +8,27 @@ import (
"github.com/hashicorp/packer/template/interpolate" "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 { type HTTPConfig struct {
// 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"` 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"` HTTPPortMin int `mapstructure:"http_port_min"`
HTTPPortMax int `mapstructure:"http_port_max"` HTTPPortMax int `mapstructure:"http_port_max"`
} }

View File

@ -90,7 +90,14 @@ Linux server and have not enabled X11 forwarding (`ssh -X`).
<%= partial "partials/common/ISOConfig-not-required" %> <%= 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: ### Optional:
<%= partial "partials/builder/qemu/Config-not-required" %> <%= 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 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). 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 ## Boot Command

View File

@ -0,0 +1,17 @@
<!-- Code generated from the comments of the HTTPConfig struct in common/http_config.go; DO NOT EDIT MANUALLY -->
- `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

View File

@ -0,0 +1,8 @@
<!-- Code generated from the comments of the HTTPConfig struct in common/http_config.go; DO NOT EDIT MANUALLY -->
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`