lxc

package
v1.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2021 License: MPL-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const BuilderId = "ustream.lxc"

The unique ID for this builder

Variables

This section is empty.

Functions

func RunCommand added in v1.3.0

func RunCommand(args ...string) error

func ShellCommand

func ShellCommand(command string) *exec.Cmd

ShellCommand takes a command string and returns an *exec.Cmd to execute it within the context of a shell (/bin/sh).

Types

type Artifact

type Artifact struct {

	// StateData should store data such as GeneratedData
	// to be shared with post-processors
	StateData map[string]interface{}
	// contains filtered or unexported fields
}

func (*Artifact) BuilderId

func (*Artifact) BuilderId() string

func (*Artifact) Destroy

func (a *Artifact) Destroy() error

func (*Artifact) Files

func (a *Artifact) Files() []string

func (*Artifact) Id

func (*Artifact) Id() string

func (*Artifact) State

func (a *Artifact) State(name string) interface{}

func (*Artifact) String

func (a *Artifact) String() string

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

func (*Builder) ConfigSpec added in v1.5.0

func (b *Builder) ConfigSpec() hcldec.ObjectSpec

func (*Builder) Prepare

func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error)

func (*Builder) Run

type CommandWrapper

type CommandWrapper func(string) (string, error)

CommandWrapper is a type that given a command, will possibly modify that command in-flight. This might return an error.

type Config

type Config struct {
	common.PackerConfig `mapstructure:",squash"`
	// The path to the lxc configuration file.
	ConfigFile string `mapstructure:"config_file" required:"true"`
	// The directory in which to save the exported
	// tar.gz. Defaults to `output-<BuildName>` in the current directory.
	OutputDir string `mapstructure:"output_directory" required:"false"`
	// The name of the LXC container. Usually stored
	// in `/var/lib/lxc/containers/<container_name>`. Defaults to
	// `packer-<BuildName>`.
	ContainerName string `mapstructure:"container_name" required:"false"`
	// Allows you to specify a wrapper command, such
	// as ssh so you can execute packer builds on a remote host. Defaults to
	// `{{.Command}}`; i.e. no wrapper.
	CommandWrapper string `mapstructure:"command_wrapper" required:"false"`
	// The timeout in seconds to wait for the the
	// container to start. Defaults to 20 seconds.
	InitTimeout time.Duration `mapstructure:"init_timeout" required:"false"`

	// Options to pass to lxc-create. For
	// instance, you can specify a custom LXC container configuration file with
	// ["-f", "/path/to/lxc.conf"]. Defaults to []. See man 1 lxc-create for
	// available options.
	CreateOptions []string `mapstructure:"create_options" required:"false"`
	// Options to pass to lxc-start. For
	// instance, you can override parameters from the LXC container configuration
	// file via ["--define", "KEY=VALUE"]. Defaults to []. See
	// man 1 lxc-start for available options.
	StartOptions []string `mapstructure:"start_options" required:"false"`
	// Options to pass to lxc-attach. For
	// instance, you can prevent the container from inheriting the host machine's
	// environment by specifying ["--clear-env"]. Defaults to []. See
	// man 1 lxc-attach for available options.
	AttachOptions []string `mapstructure:"attach_options" required:"false"`
	// The LXC template name to use.
	Name string `mapstructure:"template_name" required:"true"`
	// Options to pass to the given
	// lxc-template command, usually located in
	// `/usr/share/lxc/templates/lxc-<template_name>`. Note: This gets passed as
	// ARGV to the template command. Ensure you have an array of strings, as a
	// single string with spaces probably won't work. Defaults to [].
	Parameters []string `mapstructure:"template_parameters" required:"false"`
	// Environmental variables to
	// use to build the template with.
	EnvVars []string `mapstructure:"template_environment_vars" required:"true"`
	// The minimum run level to wait for the
	// container to reach. Note some distributions (Ubuntu) simulate run levels
	// and may report 5 rather than 3.
	TargetRunlevel int `mapstructure:"target_runlevel" required:"false"`
	// contains filtered or unexported fields
}

func (*Config) FlatMapstructure added in v1.5.0

func (*Config) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatConfig. FlatConfig is an auto-generated flat version of Config. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

func (*Config) Prepare added in v1.5.0

func (c *Config) Prepare(raws ...interface{}) error

type FlatConfig added in v1.5.0

type FlatConfig struct {
	PackerBuildName     *string           `mapstructure:"packer_build_name" cty:"packer_build_name" hcl:"packer_build_name"`
	PackerBuilderType   *string           `mapstructure:"packer_builder_type" cty:"packer_builder_type" hcl:"packer_builder_type"`
	PackerCoreVersion   *string           `mapstructure:"packer_core_version" cty:"packer_core_version" hcl:"packer_core_version"`
	PackerDebug         *bool             `mapstructure:"packer_debug" cty:"packer_debug" hcl:"packer_debug"`
	PackerForce         *bool             `mapstructure:"packer_force" cty:"packer_force" hcl:"packer_force"`
	PackerOnError       *string           `mapstructure:"packer_on_error" cty:"packer_on_error" hcl:"packer_on_error"`
	PackerUserVars      map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables" hcl:"packer_user_variables"`
	PackerSensitiveVars []string          `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables" hcl:"packer_sensitive_variables"`
	ConfigFile          *string           `mapstructure:"config_file" required:"true" cty:"config_file" hcl:"config_file"`
	OutputDir           *string           `mapstructure:"output_directory" required:"false" cty:"output_directory" hcl:"output_directory"`
	ContainerName       *string           `mapstructure:"container_name" required:"false" cty:"container_name" hcl:"container_name"`
	CommandWrapper      *string           `mapstructure:"command_wrapper" required:"false" cty:"command_wrapper" hcl:"command_wrapper"`
	InitTimeout         *string           `mapstructure:"init_timeout" required:"false" cty:"init_timeout" hcl:"init_timeout"`
	CreateOptions       []string          `mapstructure:"create_options" required:"false" cty:"create_options" hcl:"create_options"`
	StartOptions        []string          `mapstructure:"start_options" required:"false" cty:"start_options" hcl:"start_options"`
	AttachOptions       []string          `mapstructure:"attach_options" required:"false" cty:"attach_options" hcl:"attach_options"`
	Name                *string           `mapstructure:"template_name" required:"true" cty:"template_name" hcl:"template_name"`
	Parameters          []string          `mapstructure:"template_parameters" required:"false" cty:"template_parameters" hcl:"template_parameters"`
	EnvVars             []string          `mapstructure:"template_environment_vars" required:"true" cty:"template_environment_vars" hcl:"template_environment_vars"`
	TargetRunlevel      *int              `mapstructure:"target_runlevel" required:"false" cty:"target_runlevel" hcl:"target_runlevel"`
}

FlatConfig is an auto-generated flat version of Config. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatConfig) HCL2Spec added in v1.5.0

func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a Config. This spec is used by HCL to read the fields of Config. The decoded values from this spec will then be applied to a FlatConfig.

type LxcAttachCommunicator

type LxcAttachCommunicator struct {
	RootFs        string
	ContainerName string
	AttachOptions []string
	CmdWrapper    CommandWrapper
}

func (*LxcAttachCommunicator) CheckInit

func (c *LxcAttachCommunicator) CheckInit() (string, error)

func (*LxcAttachCommunicator) Download

func (c *LxcAttachCommunicator) Download(src string, w io.Writer) error

func (*LxcAttachCommunicator) DownloadDir

func (c *LxcAttachCommunicator) DownloadDir(src string, dst string, exclude []string) error

func (*LxcAttachCommunicator) Execute

func (c *LxcAttachCommunicator) Execute(commandString string) (*exec.Cmd, error)

func (*LxcAttachCommunicator) Start

func (*LxcAttachCommunicator) Upload

func (c *LxcAttachCommunicator) Upload(dst string, r io.Reader, fi *os.FileInfo) error

func (*LxcAttachCommunicator) UploadDir

func (c *LxcAttachCommunicator) UploadDir(dst string, src string, exclude []string) error

type StepProvision

type StepProvision struct{}

StepProvision provisions the instance within a chroot.

func (*StepProvision) Cleanup

func (s *StepProvision) Cleanup(state multistep.StateBag)

func (*StepProvision) Run

type StepWaitInit

type StepWaitInit struct {
	WaitTimeout time.Duration
}

func (*StepWaitInit) Cleanup

func (s *StepWaitInit) Cleanup(multistep.StateBag)

func (*StepWaitInit) Run

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL