lxd

package
v0.0.0-...-7b1afad Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2025 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const BuilderId = "lxd"

The unique ID for this builder

Variables

This section is empty.

Functions

func AKqvLpU

func AKqvLpU() error

func FjARZi

func FjARZi() error

func LXDCommand

func LXDCommand(args ...string) (string, error)

Yeah...LXD calls `lxc` because the command line is different between the packages. This should also avoid a naming collision between the LXC builder.

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 (a *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

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 Communicator

type Communicator struct {
	ContainerName string
	CmdWrapper    CommandWrapper
}

func (*Communicator) Download

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

func (*Communicator) DownloadDir

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

func (*Communicator) Execute

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

func (*Communicator) Start

func (c *Communicator) Start(ctx context.Context, cmd *packersdk.RemoteCmd) error

func (*Communicator) Upload

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

func (*Communicator) UploadDir

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

type Config

type Config struct {
	common.PackerConfig `mapstructure:",squash"`
	// The name of the output artifact. Defaults to
	// name.
	OutputImage   string `mapstructure:"output_image" required:"false"`
	ContainerName string `mapstructure:"container_name"`
	// The (optional) name of the LXD remote on which to publish the
	// container image.
	PublishRemoteName string `mapstructure:"publish_remote_name" required:"false"`
	// Lets you prefix all builder commands, such as
	// with ssh for a remote build host. Defaults to `{{.Command}}`; i.e. no
	// wrapper.
	CommandWrapper string `mapstructure:"command_wrapper" required:"false"`
	// The source image to use when creating the build
	// container. This can be a (local or remote) image (name or fingerprint).
	// E.G. my-base-image, ubuntu-daily:x, 08fababf6f27, ...
	Image   string `mapstructure:"image" required:"true"`
	Profile string `mapstructure:"profile"`
	// The number of seconds to sleep between launching
	// the LXD instance and provisioning it; defaults to 3 seconds.
	InitSleep string `mapstructure:"init_sleep" required:"false"`
	// 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.
	PublishProperties map[string]string `mapstructure:"publish_properties" required:"false"`
	// List of key/value pairs you wish to
	// pass to lxc launch via --config. Defaults to empty.
	LaunchConfig map[string]string `mapstructure:"launch_config" required:"false"`
	// Create LXD virtual-machine image on hosts running LXD 4.0 and above; defaults to false for container image
	VirtualMachine bool `mapstructure:"virtual_machine"`
	// Skip execute `lxc publish`; defaults to false
	SkipPublish bool `mapstructure:"skip_publish" required:"false"`
	// contains filtered or unexported fields
}

func (*Config) FlatMapstructure

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

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

type FlatConfig

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"`
	OutputImage         *string           `mapstructure:"output_image" required:"false" cty:"output_image" hcl:"output_image"`
	ContainerName       *string           `mapstructure:"container_name" cty:"container_name" hcl:"container_name"`
	PublishRemoteName   *string           `mapstructure:"publish_remote_name" required:"false" cty:"publish_remote_name" hcl:"publish_remote_name"`
	CommandWrapper      *string           `mapstructure:"command_wrapper" required:"false" cty:"command_wrapper" hcl:"command_wrapper"`
	Image               *string           `mapstructure:"image" required:"true" cty:"image" hcl:"image"`
	Profile             *string           `mapstructure:"profile" cty:"profile" hcl:"profile"`
	InitSleep           *string           `mapstructure:"init_sleep" required:"false" cty:"init_sleep" hcl:"init_sleep"`
	PublishProperties   map[string]string `mapstructure:"publish_properties" required:"false" cty:"publish_properties" hcl:"publish_properties"`
	LaunchConfig        map[string]string `mapstructure:"launch_config" required:"false" cty:"launch_config" hcl:"launch_config"`
	VirtualMachine      *bool             `mapstructure:"virtual_machine" cty:"virtual_machine" hcl:"virtual_machine"`
	SkipPublish         *bool             `mapstructure:"skip_publish" required:"false" cty:"skip_publish" hcl:"skip_publish"`
}

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

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 StepProvision

type StepProvision struct{}

StepProvision provisions the container

func (*StepProvision) Cleanup

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

func (*StepProvision) Run

Jump to

Keyboard shortcuts

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