Documentation ¶
Index ¶
- Variables
- func PullImage(ctx context.Context, conf PullConf) error
- type Action
- type ActionOp
- type AppendLineCommand
- type BuildConf
- type BuildImageResult
- type BuilderResult
- type ChdirStep
- type ChmodCommand
- type CopyFile
- type CopyInCommand
- type CreateImage
- type ExtractResult
- type ImageForest
- func (f *ImageForest) BuildAllImages(bldConf *BuildConf) *BuilderResult
- func (f *ImageForest) BuildImage(bldConf *BuildConf, image string) (*BuilderResult, error)
- func (f *ImageForest) BuildImages(bldConf *BuildConf, queue []string) *BuilderResult
- func (f *ImageForest) Dependencies(image string) ([]string, error)
- func (f *ImageForest) ImageFilename(image string) (string, error)
- func (f *ImageForest) IsLeafImage(i string) bool
- func (f *ImageForest) IsRootImage(image string) (bool, error)
- func (f *ImageForest) LeafImages() []string
- func (f *ImageForest) RootImages() []string
- type ImagesConf
- type ImgConf
- type InstallKernelCommand
- type LinkCommand
- type MkdirCommand
- type PullConf
- type RunCommand
- type SetHostnameCommand
- type StepConf
- type UploadCommand
- type VirtCustomizeAction
- type VirtCustomizeStep
Constants ¶
This section is empty.
Variables ¶
var ( // Binaries used // Debootstrap = "debootstrap" Mmdebstrap = "mmdebstrap" QemuImg = "qemu-img" VirtCustomize = "virt-customize" GuestFish = "guestfish" Binaries = []string{ Mmdebstrap, QemuImg, VirtCustomize, GuestFish, } DefaultConfFile = "images.json" DefaultImageSize = "8G" )
var (
// DelImageIfExists: if set to true, image will be deleted at Cleanup() by the CreateImage step
DelImageIfExists = "DelImageIfExist"
)
var ExampleImagesConf = []ImgConf{ { Name: "base.img", Packages: []string{ "less", "vim", "sudo", "openssh-server", "curl", }, Actions: []Action{{ Comment: "disable password for root", Op: &RunCommand{ Cmd: "passwd -d root", }, }}, }, { Name: "k8s.qcow2", Parent: "base.img", Packages: []string{ "docker.io", }, }, }
Functions ¶
Types ¶
type ActionOp ¶
ActionOp is the interface that actions operations need to implement.
Note: If you create an instance of ActionOp, you need to add it to actionOpInstances so that JSON marshaling/unmarshaling works. Please also consider adding a test case in actions_json_test.go to ensure that all works.
type AppendLineCommand ¶
AppendLineCommand
func (*AppendLineCommand) ActionOpName ¶
func (c *AppendLineCommand) ActionOpName() string
type BuildConf ¶
type BuildConf struct { Log *logrus.Logger // if DryRun set, no actual images will be build. Instead, empty files will be created DryRun bool // if ForceRebuild is set, images will be build even if they exist already ForceRebuild bool // if MergeSteps is set, image build steps will be merged when possible (better performance at the cost making operations more complicated) MergeSteps bool }
BuildConf configures how a set of images are build
type BuildImageResult ¶
type BuildImageResult struct { // Error is not nil, if building the image failed. Error error // CachedImageUsed is set to true if a cached image was found and no // actual build happened. CachedImageUsed bool // CachedImageDeleted is set to an non empty string if the image file // was deleted. The string describes the reason. CachedImageDeleted string }
BuildImageResult describes the result of building a single image
type BuilderResult ¶
type BuilderResult struct { // Error is not nil if an error happened outside image builds Error error // ImageResults results of building images ImageResults map[string]BuildImageResult }
BuilderResult encodes the result of building a set of images
func (*BuilderResult) Err ¶
func (r *BuilderResult) Err() error
Err() returns a summary error or nil if no errors were encountered
type ChdirStep ¶
func NewChdirStep ¶
type ChmodCommand ¶
ChmodCommand
func (*ChmodCommand) ActionOpName ¶
func (c *ChmodCommand) ActionOpName() string
type CopyInCommand ¶
CopyInCommand copies local files in the image (recursively)
func (*CopyInCommand) ActionOpName ¶
func (c *CopyInCommand) ActionOpName() string
type CreateImage ¶
type CreateImage struct {
*StepConf
}
func NewCreateImage ¶
func NewCreateImage(cnf *StepConf) *CreateImage
func (*CreateImage) Cleanup ¶
func (s *CreateImage) Cleanup(ctx context.Context)
type ExtractResult ¶ added in v0.0.14
type ExtractResult struct {
Images []string
}
func ExtractImage ¶ added in v0.0.14
func ExtractImage(ctx context.Context, conf PullConf) (*ExtractResult, error)
type ImageForest ¶
type ImageForest struct {
// contains filtered or unexported fields
}
ImageForest is a set of images forming a forest (i.e., a set of trees)
func NewImageForest ¶
func NewImageForest(conf *ImagesConf, saveConfFile bool) (*ImageForest, error)
NewImageForest creates a new image forest it will create a new image directory if it does not exist if saveConfigFileInDir is set, a serialized version of the configuration file will be saved in the image directory
func (*ImageForest) BuildAllImages ¶
func (f *ImageForest) BuildAllImages(bldConf *BuildConf) *BuilderResult
BuildAllImages will build all images in the forest. It will start from the roots, and work its way down.
func (*ImageForest) BuildImage ¶
func (f *ImageForest) BuildImage(bldConf *BuildConf, image string) (*BuilderResult, error)
BuildImage builds an image, with all of its dependencies
func (*ImageForest) BuildImages ¶ added in v0.0.18
func (f *ImageForest) BuildImages(bldConf *BuildConf, queue []string) *BuilderResult
BuildImages will build the images specified in the queue from the forest. It will start from the roots, and work its way down.
func (*ImageForest) Dependencies ¶
func (f *ImageForest) Dependencies(image string) ([]string, error)
Dependencies returns the dependencies of an image, i.e., what images need to be build before it
func (*ImageForest) ImageFilename ¶
func (f *ImageForest) ImageFilename(image string) (string, error)
ImageFilename returns the filename of an image
func (*ImageForest) IsLeafImage ¶
func (f *ImageForest) IsLeafImage(i string) bool
func (*ImageForest) IsRootImage ¶
func (f *ImageForest) IsRootImage(image string) (bool, error)
func (*ImageForest) LeafImages ¶
func (f *ImageForest) LeafImages() []string
func (*ImageForest) RootImages ¶
func (f *ImageForest) RootImages() []string
RootImages are the images which do not have dependencies (i.e., no parents)
type ImagesConf ¶
type ImagesConf struct { // ImageDir is the directory for the images Dir string // Images is the configuration for all images Images []ImgConf }
ImagesConf is the configuration of a set of images
type ImgConf ¶
type ImgConf struct { // Name of the image Name string `json:"name"` // Parent is the name parent image (or "" if image does not have a parent) Parent string `json:"parent,omitempty"` // ImageSize is the size of the image (defaults to images.DefaultImageSize) ImageSize string `json:"image_size,omitempty"` // Bootable indicates if the image should be bootable, i.e. contain a kernel // and a bootloader. Bootable *bool `json:"bootable,omitempty"` // Packages is the list of packages contained in the image Packages []string `json:"packages"` // Actions is a list of additional actions for building the image. // Order will be maintained during execution. Actions []Action `json:"actions,omitempty"` }
ImgConf is the configuration of an image
type InstallKernelCommand ¶
type InstallKernelCommand struct {
KernelInstallDir string
}
InstallKernelCommand
func (*InstallKernelCommand) ActionOpName ¶
func (c *InstallKernelCommand) ActionOpName() string
type LinkCommand ¶
LinkCommand
func (*LinkCommand) ActionOpName ¶
func (c *LinkCommand) ActionOpName() string
type MkdirCommand ¶
type MkdirCommand struct {
Dir string
}
MkdirCommand creates a directory
func (*MkdirCommand) ActionOpName ¶
func (c *MkdirCommand) ActionOpName() string
type RunCommand ¶
type RunCommand struct {
Cmd string
}
RunCommand runs a script in a path specified by a string
func (*RunCommand) ActionOpName ¶
func (rc *RunCommand) ActionOpName() string
type SetHostnameCommand ¶
type SetHostnameCommand struct {
Hostname string
}
SetHostnameCommand sets the hostname
func (*SetHostnameCommand) ActionOpName ¶
func (c *SetHostnameCommand) ActionOpName() string
type StepConf ¶
type StepConf struct {
// contains filtered or unexported fields
}
StepConf is common step configuration
type UploadCommand ¶
UploadCommand copies a file to the vim
func (*UploadCommand) ActionOpName ¶
func (c *UploadCommand) ActionOpName() string
type VirtCustomizeAction ¶
type VirtCustomizeAction struct { OpName string // contains filtered or unexported fields }
type VirtCustomizeStep ¶
VirtCustomizeStep is a step implemented a set of arguments in virt-customize
NB: we can maybe merge multiple VirtCustomizeStep in a single virt-customize invocation. The idea here would be that virt-customize performs the actions in its arguments sequentially.
NB: we can probably do the same with guestfish as well
func (*VirtCustomizeStep) Cleanup ¶
func (s *VirtCustomizeStep) Cleanup(ctx context.Context)