shared

package
v0.0.0-...-0c63f15 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2016 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Overview

This is a FLEXible file which can be used by both client and daemon.
* Teehee.

That this code needs to exist is kind of dumb, but I'm not sure how else to do it.

Index

Constants

View Source
const (
	ARCH_UNKNOWN                     = 0
	ARCH_32BIT_INTEL_X86             = 1
	ARCH_64BIT_INTEL_X86             = 2
	ARCH_32BIT_ARMV7_LITTLE_ENDIAN   = 3
	ARCH_64BIT_ARMV8_LITTLE_ENDIAN   = 4
	ARCH_32BIT_POWERPC_BIG_ENDIAN    = 5
	ARCH_64BIT_POWERPC_BIG_ENDIAN    = 6
	ARCH_64BIT_POWERPC_LITTLE_ENDIAN = 7
	ARCH_64BIT_S390_BIG_ENDIAN       = 8
)
View Source
const ArchitectureDefault = "x86_64"
View Source
const DefaultPort = "8443"
View Source
const SnapshotDelimiter = "/"

Variables

View Source
var APIVersion = "1.0"

* Please increment the api compat number every time you change the API. * * Version 1.0: ping

View Source
var KnownContainerConfigKeys = map[string]func(value string) error{
	"boot.autostart":             IsBool,
	"boot.autostart.delay":       IsInt64,
	"boot.autostart.priority":    IsInt64,
	"boot.host_shutdown_timeout": IsInt64,

	"limits.cpu": IsAny,
	"limits.cpu.allowance": func(value string) error {
		if value == "" {
			return nil
		}

		if strings.HasSuffix(value, "%") {

			_, err := strconv.Atoi(strings.TrimSuffix(value, "%"))
			if err != nil {
				return err
			}

			return nil
		}

		fields := strings.SplitN(value, "/", 2)
		if len(fields) != 2 {
			return fmt.Errorf("Invalid allowance: %s", value)
		}

		_, err := strconv.Atoi(strings.TrimSuffix(fields[0], "ms"))
		if err != nil {
			return err
		}

		_, err = strconv.Atoi(strings.TrimSuffix(fields[1], "ms"))
		if err != nil {
			return err
		}

		return nil
	},
	"limits.cpu.priority": IsPriority,

	"limits.disk.priority": IsPriority,

	"limits.memory": func(value string) error {
		if value == "" {
			return nil
		}

		if strings.HasSuffix(value, "%") {
			_, err := strconv.ParseInt(strings.TrimSuffix(value, "%"), 10, 64)
			if err != nil {
				return err
			}

			return nil
		}

		_, err := ParseByteSizeString(value)
		if err != nil {
			return err
		}

		return nil
	},
	"limits.memory.enforce": func(value string) error {
		return IsOneOf(value, []string{"soft", "hard"})
	},
	"limits.memory.swap":          IsBool,
	"limits.memory.swap.priority": IsPriority,

	"limits.network.priority": IsPriority,

	"limits.processes": IsInt64,

	"linux.kernel_modules": IsAny,

	"security.nesting":    IsBool,
	"security.privileged": IsBool,

	"security.idmap.size":     IsUint32,
	"security.idmap.isolated": IsBool,

	"security.syscalls.blacklist_default": IsBool,
	"security.syscalls.blacklist_compat":  IsBool,
	"security.syscalls.blacklist":         IsAny,
	"security.syscalls.whitelist":         IsAny,

	"raw.apparmor": IsAny,
	"raw.lxc":      IsAny,
	"raw.seccomp":  IsAny,
	"raw.idmap":    IsAny,

	"volatile.apply_template":   IsAny,
	"volatile.base_image":       IsAny,
	"volatile.last_state.idmap": IsAny,
	"volatile.last_state.power": IsAny,
	"volatile.idmap.next":       IsAny,
	"volatile.idmap.base":       IsAny,
}

KnownContainerConfigKeys maps all fully defined, well-known config keys to an appropriate checker function, which validates whether or not a given value is syntactically legal.

View Source
var UserAgent = "LXD " + Version
View Source
var Version = "2.5"
View Source
var WebsocketUpgrader = websocket.Upgrader{
	CheckOrigin: func(r *http.Request) bool { return true },
}

Functions

func AddSlash

func AddSlash(path string) string

AddSlash adds a slash to the end of paths if they don't already have one. This can be useful for rsyncing things, since rsync has behavior present on the presence or absence of a trailing slash.

func ArchitectureGetLocal

func ArchitectureGetLocal() (string, error)

func ArchitectureId

func ArchitectureId(arch string) (int, error)

func ArchitectureName

func ArchitectureName(arch int) (string, error)

func ArchitecturePersonalities

func ArchitecturePersonalities(arch int) ([]int, error)

func ArchitecturePersonality

func ArchitecturePersonality(arch int) (string, error)

func AtoiEmptyDefault

func AtoiEmptyDefault(s string, def int) (int, error)

func BlockFsDetect

func BlockFsDetect(dev string) (string, error)

func CachePath

func CachePath(path ...string) string

CachePath returns the directory that LXD should its cache under. If LXD_DIR is set, this path is $LXD_DIR/cache, otherwise it is /var/cache/lxd.

func ConfigKeyChecker

func ConfigKeyChecker(key string) (func(value string) error, error)

ConfigKeyChecker returns a function that will check whether or not a provide value is valid for the associate config key. Returns an error if the key is not known. The checker function only performs syntactic checking of the value, semantic and usage checking must be done by the caller. User defined keys are always considered to be valid, e.g. user.* and environment.* keys.

func DebugJson

func DebugJson(r *bytes.Buffer)

func DeepCopy

func DeepCopy(src, dest interface{}) error

DeepCopy copies src to dest by using encoding/gob so its not that fast.

func ExtractSnapshotName

func ExtractSnapshotName(name string) string

func FileCopy

func FileCopy(source string, dest string) error

FileCopy copies a file, overwriting the target if it exists.

func FileMove

func FileMove(oldPath string, newPath string) error

FileMove tries to move a file by using os.Rename, if that fails it tries to copy the file and remove the source.

func FindOrGenCert

func FindOrGenCert(certf string, keyf string, certtype bool) error

func GenCert

func GenCert(certf string, keyf string, certtype bool) error

GenCert will create and populate a certificate file and a key file

func GenerateMemCert

func GenerateMemCert(client bool) ([]byte, []byte, error)

GenerateMemCert creates client or server certificate and key pair, returning them as byte arrays in memory.

func GetAllXattr

func GetAllXattr(path string) (xattrs map[string]string, err error)

GetAllXattr retrieves all extended attributes associated with a file, directory or symbolic link.

func GetByteSizeString

func GetByteSizeString(input int64) string

func GetFileStat

func GetFileStat(p string) (uid int, gid int, major int, minor int,
	inode uint64, nlink int, err error)

func GetOwner

func GetOwner(path string) (int, int, error)

func GetOwnerMode

func GetOwnerMode(fInfo os.FileInfo) (os.FileMode, int, int)

func GetTLSConfig

func GetTLSConfig(tlsClientCertFile string, tlsClientKeyFile string, tlsClientCAFile string, tlsRemoteCert *x509.Certificate) (*tls.Config, error)

func GetTLSConfigMem

func GetTLSConfigMem(tlsClientCert string, tlsClientKey string, tlsClientCA string, tlsRemoteCertPEM string) (*tls.Config, error)

func GroupId

func GroupId(name string) (int, error)

GroupId is an adaption from https://codereview.appspot.com/4589049.

func GroupName

func GroupName(gid int) (string, error)

GroupName is an adaption from https://codereview.appspot.com/4589049.

func IntInSlice

func IntInSlice(key int, list []int) bool

func IsAny

func IsAny(value string) error

func IsBlockdev

func IsBlockdev(fm os.FileMode) bool

func IsBlockdevPath

func IsBlockdevPath(pathName string) bool

func IsBool

func IsBool(value string) error

func IsDir

func IsDir(name string) bool

IsDir returns true if the given path is a directory.

func IsInt64

func IsInt64(value string) error

func IsLoopback

func IsLoopback(iface *net.Interface) bool

func IsMountPoint

func IsMountPoint(name string) bool

func IsOnSharedMount

func IsOnSharedMount(pathName string) (bool, error)

func IsOneOf

func IsOneOf(value string, valid []string) error

func IsPriority

func IsPriority(value string) error

func IsSnapshot

func IsSnapshot(name string) bool

func IsTrue

func IsTrue(value string) bool

func IsUint32

func IsUint32(value string) error

func IsUnixSocket

func IsUnixSocket(path string) bool

IsUnixSocket returns true if the given path is either a Unix socket or a symbolic link pointing at a Unix socket.

func LogCrit

func LogCrit(msg string, ctx interface{})

func LogCritf

func LogCritf(format string, args ...interface{})

func LogDebug

func LogDebug(msg string, ctx interface{})

General wrappers around Logger interface functions.

func LogDebugf

func LogDebugf(format string, args ...interface{})

func LogError

func LogError(msg string, ctx interface{})

func LogErrorf

func LogErrorf(format string, args ...interface{})

func LogInfo

func LogInfo(msg string, ctx interface{})

func LogInfof

func LogInfof(format string, args ...interface{})

Wrappers around Logger interface functions that send a string to the Logger by running it through fmt.Sprintf().

func LogPath

func LogPath(path ...string) string

LogPath returns the directory that LXD should put logs under. If LXD_DIR is set, this path is $LXD_DIR/logs, otherwise it is /var/log/lxd.

func LogWarn

func LogWarn(msg string, ctx interface{})

func LogWarnf

func LogWarnf(format string, args ...interface{})

func MkdirAllOwner

func MkdirAllOwner(path string, perm os.FileMode, uid int, gid int) error

func OpenPty

func OpenPty(uid, gid int) (master *os.File, slave *os.File, err error)

func ParseBitSizeString

func ParseBitSizeString(input string) (int64, error)

Parse a size string in bits (e.g. 200kbit or 5Gbit) into the number of bits it represents. Supports suffixes up to Ebit. "" == 0.

func ParseByteSizeString

func ParseByteSizeString(input string) (int64, error)

Parse a size string in bytes (e.g. 200kB or 5GB) into the number of bytes it represents. Supports suffixes up to EB. "" == 0.

func ParseLXDFileHeaders

func ParseLXDFileHeaders(headers http.Header) (uid int, gid int, mode int, type_ string)

func ParseMetadata

func ParseMetadata(metadata interface{}) (map[string]interface{}, error)

func PathExists

func PathExists(name string) bool

func PathIsEmpty

func PathIsEmpty(path string) (bool, error)

PathIsEmpty checks if the given path is empty.

func Pipe

func Pipe() (master *os.File, slave *os.File, err error)

func PrintStack

func PrintStack()

func ProxyFromConfig

func ProxyFromConfig(httpsProxy string, httpProxy string, noProxy string) func(req *http.Request) (*url.URL, error)

func ProxyFromEnvironment

func ProxyFromEnvironment(req *http.Request) (*url.URL, error)

This is basically the same as golang's ProxyFromEnvironment, except it doesn't fall back to http_proxy when https_proxy isn't around, which is incorrect behavior. It still respects HTTP_PROXY, HTTPS_PROXY, and NO_PROXY.

func RFC3493Dialer

func RFC3493Dialer(network, address string) (net.Conn, error)

func RandomCryptoString

func RandomCryptoString() (string, error)

Returns a random base64 encoded string from crypto/rand.

func ReadCert

func ReadCert(fpath string) (*x509.Certificate, error)

func ReadDir

func ReadDir(p string) ([]string, error)

func ReadLastNLines

func ReadLastNLines(f *os.File, lines int) (string, error)

func ReadStdin

func ReadStdin() ([]byte, error)

func ReadToJSON

func ReadToJSON(r io.Reader, req interface{}) error

func ReaderToChannel

func ReaderToChannel(r io.Reader, bufferSize int) <-chan []byte

func RemoveDuplicatesFromString

func RemoveDuplicatesFromString(s string, sep string) string

RemoveDuplicatesFromString removes all duplicates of the string 'sep' from the specified string 's'. Leading and trailing occurences of sep are NOT removed (duplicate leading/trailing are). Performs poorly if there are multiple consecutive redundant separators.

func RunCommand

func RunCommand(name string, arg ...string) error

func RunningInUserNS

func RunningInUserNS() bool

func SetSize

func SetSize(fd int, width int, height int) (err error)

func ShiftOwner

func ShiftOwner(basepath string, path string, uid int, gid int) error

func SplitExt

func SplitExt(fpath string) (string, string)

func StringInSlice

func StringInSlice(key string, list []string) bool

func TestIdmapSetAddSafe_lower

func TestIdmapSetAddSafe_lower(t *testing.T)

func TestIdmapSetAddSafe_split

func TestIdmapSetAddSafe_split(t *testing.T)

func TestIdmapSetAddSafe_upper

func TestIdmapSetAddSafe_upper(t *testing.T)

func TestIdmapSetIntersects

func TestIdmapSetIntersects(t *testing.T)

func TextEditor

func TextEditor(inPath string, inContent []byte) ([]byte, error)

func ValidHostname

func ValidHostname(name string) bool

func VarPath

func VarPath(path ...string) string

VarPath returns the provided path elements joined by a slash and appended to the end of $LXD_DIR, which defaults to /var/lib/lxd.

func WebsocketMirror

func WebsocketMirror(conn *websocket.Conn, w io.WriteCloser, r io.ReadCloser) (chan bool, chan bool)

WebsocketMirror allows mirroring a reader to a websocket and taking the result and writing it to a writer. This function allows for multiple mirrorings and correctly negotiates stream endings. However, it means any websocket.Conns passed to it are live when it returns, and must be closed explicitly.

func WebsocketRecvStream

func WebsocketRecvStream(w io.Writer, conn *websocket.Conn) chan bool

func WebsocketSendStream

func WebsocketSendStream(conn *websocket.Conn, r io.Reader, bufferSize int) chan bool

func WriteAll

func WriteAll(w io.Writer, buf []byte) error

func WriteAllBuf

func WriteAllBuf(w io.Writer, buf *bytes.Buffer) error

Types

type BriefContainerInfo

type BriefContainerInfo struct {
	Name      string            `json:"name"`
	Profiles  []string          `json:"profiles"`
	Config    map[string]string `json:"config"`
	Devices   Devices           `json:"devices"`
	Ephemeral bool              `json:"ephemeral"`
}

* BriefContainerState contains a subset of the fields in * ContainerState, namely those which a user may update

type BriefImageInfo

type BriefImageInfo struct {
	AutoUpdate bool              `json:"auto_update"`
	Properties map[string]string `json:"properties"`
	Public     bool              `json:"public"`
}

* BriefImageInfo contains a subset of the fields in * ImageInfo, namely those which a user may update

type BriefServerState

type BriefServerState struct {
	Config map[string]interface{} `json:"config"`
}

type ByHostid

type ByHostid []*IdmapEntry

func (ByHostid) Len

func (s ByHostid) Len() int

func (ByHostid) Less

func (s ByHostid) Less(i, j int) bool

func (ByHostid) Swap

func (s ByHostid) Swap(i, j int)

type BytesReadCloser

type BytesReadCloser struct {
	Buf *bytes.Buffer
}

func (BytesReadCloser) Close

func (r BytesReadCloser) Close() error

func (BytesReadCloser) Read

func (r BytesReadCloser) Read(b []byte) (n int, err error)

type CertInfo

type CertInfo struct {
	Certificate string `json:"certificate"`
	Fingerprint string `json:"fingerprint"`
	Name        string `json:"name"`
	Type        string `json:"type"`
}

CertInfo is the representation of a Certificate in the API.

type ContainerAction

type ContainerAction string
const (
	Stop     ContainerAction = "stop"
	Start    ContainerAction = "start"
	Restart  ContainerAction = "restart"
	Freeze   ContainerAction = "freeze"
	Unfreeze ContainerAction = "unfreeze"
)

type ContainerExecControl

type ContainerExecControl struct {
	Command string            `json:"command"`
	Args    map[string]string `json:"args"`
	Signal  syscall.Signal    `json:"signal"`
}

type ContainerInfo

type ContainerInfo struct {
	Architecture    string            `json:"architecture"`
	Config          map[string]string `json:"config"`
	CreationDate    time.Time         `json:"created_at"`
	Devices         Devices           `json:"devices"`
	Ephemeral       bool              `json:"ephemeral"`
	ExpandedConfig  map[string]string `json:"expanded_config"`
	ExpandedDevices Devices           `json:"expanded_devices"`
	LastUsedDate    time.Time         `json:"last_used_at"`
	Name            string            `json:"name"`
	Profiles        []string          `json:"profiles"`
	Stateful        bool              `json:"stateful"`
	Status          string            `json:"status"`
	StatusCode      StatusCode        `json:"status_code"`
}

func (*ContainerInfo) Brief

func (c *ContainerInfo) Brief() BriefContainerInfo

func (*ContainerInfo) BriefExpanded

func (c *ContainerInfo) BriefExpanded() BriefContainerInfo

func (ContainerInfo) IsActive

func (c ContainerInfo) IsActive() bool

type ContainerState

type ContainerState struct {
	Status     string                           `json:"status"`
	StatusCode StatusCode                       `json:"status_code"`
	CPU        ContainerStateCPU                `json:"cpu"`
	Disk       map[string]ContainerStateDisk    `json:"disk"`
	Memory     ContainerStateMemory             `json:"memory"`
	Network    map[string]ContainerStateNetwork `json:"network"`
	Pid        int64                            `json:"pid"`
	Processes  int64                            `json:"processes"`
}

type ContainerStateCPU

type ContainerStateCPU struct {
	Usage int64 `json:"usage"`
}

type ContainerStateDisk

type ContainerStateDisk struct {
	Usage int64 `json:"usage"`
}

type ContainerStateMemory

type ContainerStateMemory struct {
	Usage         int64 `json:"usage"`
	UsagePeak     int64 `json:"usage_peak"`
	SwapUsage     int64 `json:"swap_usage"`
	SwapUsagePeak int64 `json:"swap_usage_peak"`
}

type ContainerStateNetwork

type ContainerStateNetwork struct {
	Addresses []ContainerStateNetworkAddress `json:"addresses"`
	Counters  ContainerStateNetworkCounters  `json:"counters"`
	Hwaddr    string                         `json:"hwaddr"`
	HostName  string                         `json:"host_name"`
	Mtu       int                            `json:"mtu"`
	State     string                         `json:"state"`
	Type      string                         `json:"type"`
}

type ContainerStateNetworkAddress

type ContainerStateNetworkAddress struct {
	Family  string `json:"family"`
	Address string `json:"address"`
	Netmask string `json:"netmask"`
	Scope   string `json:"scope"`
}

type ContainerStateNetworkCounters

type ContainerStateNetworkCounters struct {
	BytesReceived   int64 `json:"bytes_received"`
	BytesSent       int64 `json:"bytes_sent"`
	PacketsReceived int64 `json:"packets_received"`
	PacketsSent     int64 `json:"packets_sent"`
}

type Device

type Device map[string]string

type Devices

type Devices map[string]Device

func (Devices) Contains

func (list Devices) Contains(k string, d Device) bool

func (Devices) ContainsName

func (list Devices) ContainsName(k string) bool

func (Devices) DeviceNames

func (devices Devices) DeviceNames() []string

DeviceNames returns the device names for this Devices in sorted order

func (Devices) ExtendFromProfile

func (newBaseDevices Devices) ExtendFromProfile(currentFullDevices Devices, newDevicesFromProfile Devices) error

func (Devices) Update

func (old Devices) Update(newlist Devices) (map[string]Device, map[string]Device, map[string]Device)

type IdmapEntry

type IdmapEntry struct {
	Isuid    bool
	Isgid    bool
	Hostid   int // id as seen on the host - i.e. 100000
	Nsid     int // id as seen in the ns - i.e. 0
	Maprange int
}

* One entry in id mapping set - a single range of either * uid or gid mappings.

func Extend

func Extend(slice []IdmapEntry, element IdmapEntry) []IdmapEntry

taken from http://blog.golang.org/slices (which is under BSD licence)

func (*IdmapEntry) HostidsIntersect

func (e *IdmapEntry) HostidsIntersect(i IdmapEntry) bool

func (*IdmapEntry) Intersects

func (e *IdmapEntry) Intersects(i IdmapEntry) bool

func (*IdmapEntry) ToLxcString

func (e *IdmapEntry) ToLxcString() string

type IdmapSet

type IdmapSet struct {
	Idmap []IdmapEntry
}

func DefaultIdmapSet

func DefaultIdmapSet() (*IdmapSet, error)

* Create a new default idmap

func (*IdmapSet) AddSafe

func (m *IdmapSet) AddSafe(i IdmapEntry) error

AddSafe adds an entry to the idmap set, breaking apart any ranges that the * new idmap intersects with in the process.

func (IdmapSet) Append

func (m IdmapSet) Append(s string) (IdmapSet, error)

func (IdmapSet) HostidsIntersect

func (m IdmapSet) HostidsIntersect(i IdmapEntry) bool

func (IdmapSet) Intersects

func (m IdmapSet) Intersects(i IdmapEntry) bool

func (IdmapSet) Len

func (m IdmapSet) Len() int

func (*IdmapSet) ShiftFile

func (set *IdmapSet) ShiftFile(p string) error

func (IdmapSet) ShiftFromNs

func (m IdmapSet) ShiftFromNs(uid int, gid int) (int, int)

func (IdmapSet) ShiftIntoNs

func (m IdmapSet) ShiftIntoNs(uid int, gid int) (int, int)

func (*IdmapSet) ShiftRootfs

func (set *IdmapSet) ShiftRootfs(p string) error

func (IdmapSet) ToLxcString

func (m IdmapSet) ToLxcString() []string

func (*IdmapSet) UidshiftFromContainer

func (set *IdmapSet) UidshiftFromContainer(dir string, testmode bool) error

func (*IdmapSet) UidshiftIntoContainer

func (set *IdmapSet) UidshiftIntoContainer(dir string, testmode bool) error

func (*IdmapSet) UnshiftRootfs

func (set *IdmapSet) UnshiftRootfs(p string) error

type ImageAlias

type ImageAlias struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

type ImageAliases

type ImageAliases []ImageAliasesEntry

type ImageAliasesEntry

type ImageAliasesEntry struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Target      string `json:"target"`
}

type ImageInfo

type ImageInfo struct {
	Aliases      []ImageAlias      `json:"aliases"`
	Architecture string            `json:"architecture"`
	Cached       bool              `json:"cached"`
	Filename     string            `json:"filename"`
	Fingerprint  string            `json:"fingerprint"`
	Properties   map[string]string `json:"properties"`
	Public       bool              `json:"public"`
	Size         int64             `json:"size"`

	AutoUpdate bool         `json:"auto_update"`
	Source     *ImageSource `json:"update_source,omitempty"`

	CreationDate time.Time `json:"created_at"`
	ExpiryDate   time.Time `json:"expires_at"`
	LastUsedDate time.Time `json:"last_used_at"`
	UploadDate   time.Time `json:"uploaded_at"`
}

func (*ImageInfo) Brief

func (i *ImageInfo) Brief() BriefImageInfo

type ImageProperties

type ImageProperties map[string]string

type ImageSource

type ImageSource struct {
	Server      string `json:"server"`
	Protocol    string `json:"protocol"`
	Certificate string `json:"certificate"`
	Alias       string `json:"alias"`
}

type Jmap

type Jmap map[string]interface{}

func (Jmap) GetBool

func (m Jmap) GetBool(key string) (bool, error)

func (Jmap) GetInt

func (m Jmap) GetInt(key string) (int, error)

func (Jmap) GetMap

func (m Jmap) GetMap(key string) (Jmap, error)

func (Jmap) GetString

func (m Jmap) GetString(key string) (string, error)

type Logger

type Logger interface {
	Debug(msg string, ctx ...interface{})
	Info(msg string, ctx ...interface{})
	Warn(msg string, ctx ...interface{})
	Error(msg string, ctx ...interface{})
	Crit(msg string, ctx ...interface{})
}
var Log Logger

type NetworkConfig

type NetworkConfig struct {
	Name    string            `json:"name"`
	Config  map[string]string `json:"config"`
	Managed bool              `json:"managed"`
	Type    string            `json:"type"`
	UsedBy  []string          `json:"used_by"`
}

type Operation

type Operation struct {
	Id         string              `json:"id"`
	Class      string              `json:"class"`
	CreatedAt  time.Time           `json:"created_at"`
	UpdatedAt  time.Time           `json:"updated_at"`
	Status     string              `json:"status"`
	StatusCode StatusCode          `json:"status_code"`
	Resources  map[string][]string `json:"resources"`
	Metadata   *Jmap               `json:"metadata"`
	MayCancel  bool                `json:"may_cancel"`
	Err        string              `json:"err"`
}

type ProfileConfig

type ProfileConfig struct {
	Name        string            `json:"name"`
	Config      map[string]string `json:"config"`
	Description string            `json:"description"`
	Devices     Devices           `json:"devices"`
	UsedBy      []string          `json:"used_by"`
}

type ProgressReader

type ProgressReader struct {
	io.ReadCloser
	Tracker *ProgressTracker
}

func (*ProgressReader) Read

func (pt *ProgressReader) Read(p []byte) (int, error)

type ProgressTracker

type ProgressTracker struct {
	Length  int64
	Handler func(int64, int64)
	// contains filtered or unexported fields
}

func (*ProgressTracker) Update

func (pt *ProgressTracker) Update(n int)

type ProgressWriter

type ProgressWriter struct {
	io.WriteCloser
	Tracker *ProgressTracker
}

func (*ProgressWriter) Write

func (pt *ProgressWriter) Write(p []byte) (int, error)

type ServerState

type ServerState struct {
	APIExtensions []string               `json:"api_extensions"`
	APIStatus     string                 `json:"api_status"`
	APIVersion    string                 `json:"api_version"`
	Auth          string                 `json:"auth"`
	Environment   ServerStateEnvironment `json:"environment"`
	Config        map[string]interface{} `json:"config"`
	Public        bool                   `json:"public"`
}

func (*ServerState) Brief

func (c *ServerState) Brief() BriefServerState

type ServerStateEnvironment

type ServerStateEnvironment struct {
	Addresses              []string `json:"addresses"`
	Architectures          []string `json:"architectures"`
	Certificate            string   `json:"certificate"`
	CertificateFingerprint string   `json:"certificate_fingerprint"`
	Driver                 string   `json:"driver"`
	DriverVersion          string   `json:"driver_version"`
	Kernel                 string   `json:"kernel"`
	KernelArchitecture     string   `json:"kernel_architecture"`
	KernelVersion          string   `json:"kernel_version"`
	Server                 string   `json:"server"`
	ServerPid              int      `json:"server_pid"`
	ServerVersion          string   `json:"server_version"`
	Storage                string   `json:"storage"`
	StorageVersion         string   `json:"storage_version"`
}

type SimpleStreams

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

func SimpleStreamsClient

func SimpleStreamsClient(url string, proxy func(*http.Request) (*url.URL, error)) (*SimpleStreams, error)

func (*SimpleStreams) Download

func (s *SimpleStreams) Download(image string, file string, target string, progress func(int64, int64)) error

func (*SimpleStreams) ExportImage

func (s *SimpleStreams) ExportImage(image string, target string) (string, error)

func (*SimpleStreams) GetAlias

func (s *SimpleStreams) GetAlias(name string) string

func (*SimpleStreams) GetImageInfo

func (s *SimpleStreams) GetImageInfo(fingerprint string) (*ImageInfo, error)

func (*SimpleStreams) ListAliases

func (s *SimpleStreams) ListAliases() (ImageAliases, error)

func (*SimpleStreams) ListImages

func (s *SimpleStreams) ListImages() ([]ImageInfo, error)

type SimpleStreamsIndex

type SimpleStreamsIndex struct {
	Format  string                              `json:"format"`
	Index   map[string]SimpleStreamsIndexStream `json:"index"`
	Updated string                              `json:"updated"`
}

type SimpleStreamsIndexStream

type SimpleStreamsIndexStream struct {
	Updated  string   `json:"updated"`
	DataType string   `json:"datatype"`
	Path     string   `json:"path"`
	Products []string `json:"products"`
}

type SimpleStreamsManifest

type SimpleStreamsManifest struct {
	Updated  string                                  `json:"updated"`
	DataType string                                  `json:"datatype"`
	Format   string                                  `json:"format"`
	License  string                                  `json:"license"`
	Products map[string]SimpleStreamsManifestProduct `json:"products"`
}

func (*SimpleStreamsManifest) ToLXD

func (s *SimpleStreamsManifest) ToLXD() ([]ImageInfo, map[string][][]string)

type SimpleStreamsManifestProduct

type SimpleStreamsManifestProduct struct {
	Aliases         string                                         `json:"aliases"`
	Architecture    string                                         `json:"arch"`
	OperatingSystem string                                         `json:"os"`
	Release         string                                         `json:"release"`
	ReleaseCodename string                                         `json:"release_codename"`
	ReleaseTitle    string                                         `json:"release_title"`
	Supported       bool                                           `json:"supported"`
	SupportedEOL    string                                         `json:"support_eol"`
	Version         string                                         `json:"version"`
	Versions        map[string]SimpleStreamsManifestProductVersion `json:"versions"`
}

type SimpleStreamsManifestProductVersion

type SimpleStreamsManifestProductVersion struct {
	PublicName string                                             `json:"pubname"`
	Label      string                                             `json:"label"`
	Items      map[string]SimpleStreamsManifestProductVersionItem `json:"items"`
}

type SimpleStreamsManifestProductVersionItem

type SimpleStreamsManifestProductVersionItem struct {
	Path                  string `json:"path"`
	FileType              string `json:"ftype"`
	HashMd5               string `json:"md5"`
	HashSha256            string `json:"sha256"`
	LXDHashSha256         string `json:"combined_sha256"`
	LXDHashSha256RootXz   string `json:"combined_rootxz_sha256"`
	LXDHashSha256SquashFs string `json:"combined_squashfs_sha256"`
	Size                  int64  `json:"size"`
}

type SnapshotInfo

type SnapshotInfo struct {
	Architecture    string            `json:"architecture"`
	Config          map[string]string `json:"config"`
	CreationDate    time.Time         `json:"created_at"`
	Devices         Devices           `json:"devices"`
	Ephemeral       bool              `json:"ephemeral"`
	ExpandedConfig  map[string]string `json:"expanded_config"`
	ExpandedDevices Devices           `json:"expanded_devices"`
	LastUsedDate    time.Time         `json:"last_used_at"`
	Name            string            `json:"name"`
	Profiles        []string          `json:"profiles"`
	Stateful        bool              `json:"stateful"`
}

type StatusCode

type StatusCode int
const (
	OperationCreated StatusCode = 100
	Started          StatusCode = 101
	Stopped          StatusCode = 102
	Running          StatusCode = 103
	Cancelling       StatusCode = 104
	Pending          StatusCode = 105
	Starting         StatusCode = 106
	Stopping         StatusCode = 107
	Aborting         StatusCode = 108
	Freezing         StatusCode = 109
	Frozen           StatusCode = 110
	Thawed           StatusCode = 111
	Error            StatusCode = 112

	Success StatusCode = 200

	Failure   StatusCode = 400
	Cancelled StatusCode = 401
)

func FromLXCState

func FromLXCState(state int) StatusCode

* Create a StatusCode from an lxc.State code. N.B.: we accept an int instead * of a lxc.State so that the shared code doesn't depend on lxc, which depends * on liblxc, etc.

func (StatusCode) IsFinal

func (o StatusCode) IsFinal() bool

func (StatusCode) String

func (o StatusCode) String() string

type StringSet

type StringSet map[string]bool

func NewStringSet

func NewStringSet(strings []string) StringSet

func (StringSet) IsSubset

func (ss StringSet) IsSubset(oss StringSet) bool

Directories

Path Synopsis
Package flag implements command-line flag parsing in the GNU style.
Package flag implements command-line flag parsing in the GNU style.

Jump to

Keyboard shortcuts

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