Documentation ¶
Overview ¶
Package generate implements functions generating container config files.
Index ¶
- Variables
- type ExportOptions
- type Generator
- func (g *Generator) AddAnnotation(key, value string)
- func (g *Generator) AddBindMount(source, dest string, options []string)
- func (g *Generator) AddCgroupsMount(mountCgroupOption string) error
- func (g *Generator) AddDevice(device rspec.LinuxDevice)
- func (g *Generator) AddLinuxGIDMapping(hid, cid, size uint32)
- func (g *Generator) AddLinuxMaskedPaths(path string)
- func (g *Generator) AddLinuxReadonlyPaths(path string)
- func (g *Generator) AddLinuxResourcesHugepageLimit(pageSize string, limit uint64)
- func (g *Generator) AddLinuxResourcesNetworkPriorities(name string, prio uint32)
- func (g *Generator) AddLinuxSysctl(key, value string)
- func (g *Generator) AddLinuxUIDMapping(hid, cid, size uint32)
- func (g *Generator) AddOrReplaceLinuxNamespace(ns string, path string) error
- func (g *Generator) AddPostStartHook(path string, args []string)
- func (g *Generator) AddPostStartHookEnv(path string, envs []string)
- func (g *Generator) AddPostStartHookTimeout(path string, timeout int)
- func (g *Generator) AddPostStopHook(path string, args []string)
- func (g *Generator) AddPostStopHookEnv(path string, envs []string)
- func (g *Generator) AddPostStopHookTimeout(path string, timeout int)
- func (g *Generator) AddPreStartHook(path string, args []string)
- func (g *Generator) AddPreStartHookEnv(path string, envs []string)
- func (g *Generator) AddPreStartHookTimeout(path string, timeout int)
- func (g *Generator) AddProcessAdditionalGid(gid uint32)
- func (g *Generator) AddProcessCapabilityAmbient(c string) error
- func (g *Generator) AddProcessCapabilityBounding(c string) error
- func (g *Generator) AddProcessCapabilityEffective(c string) error
- func (g *Generator) AddProcessCapabilityInheritable(c string) error
- func (g *Generator) AddProcessCapabilityPermitted(c string) error
- func (g *Generator) AddProcessEnv(name, value string)
- func (g *Generator) AddProcessRlimits(rType string, rHard uint64, rSoft uint64)
- func (g *Generator) AddTmpfsMount(dest string, options []string)
- func (g *Generator) ClearAnnotations()
- func (g *Generator) ClearLinuxDevices()
- func (g *Generator) ClearLinuxGIDMappings()
- func (g *Generator) ClearLinuxNamespaces()
- func (g *Generator) ClearLinuxSysctl()
- func (g *Generator) ClearLinuxUIDMappings()
- func (g *Generator) ClearPostStartHooks()
- func (g *Generator) ClearPostStopHooks()
- func (g *Generator) ClearPreStartHooks()
- func (g *Generator) ClearProcessAdditionalGids()
- func (g *Generator) ClearProcessCapabilities()
- func (g *Generator) ClearProcessEnv()
- func (g *Generator) ClearProcessRlimits()
- func (g *Generator) DropLinuxResourcesHugepageLimit(pageSize string) error
- func (g *Generator) DropLinuxResourcesNetworkPriorities(name string)
- func (g *Generator) DropProcessCapabilityAmbient(c string) error
- func (g *Generator) DropProcessCapabilityBounding(c string) error
- func (g *Generator) DropProcessCapabilityEffective(c string) error
- func (g *Generator) DropProcessCapabilityInheritable(c string) error
- func (g *Generator) DropProcessCapabilityPermitted(c string) error
- func (g *Generator) RemoveAllSeccompRules() error
- func (g *Generator) RemoveAnnotation(key string)
- func (g *Generator) RemoveDevice(path string) error
- func (g *Generator) RemoveLinuxNamespace(ns string) error
- func (g *Generator) RemoveLinuxSysctl(key string)
- func (g *Generator) RemoveProcessRlimits(rType string) error
- func (g *Generator) RemoveSeccompRule(arguments string) error
- func (g *Generator) Save(w io.Writer, exportOpts ExportOptions) (err error)
- func (g *Generator) SaveToFile(path string, exportOpts ExportOptions) error
- func (g *Generator) SetDefaultSeccompAction(action string) error
- func (g *Generator) SetDefaultSeccompActionForce(action string) error
- func (g *Generator) SetHostname(s string)
- func (g *Generator) SetLinuxCgroupsPath(path string)
- func (g *Generator) SetLinuxMountLabel(label string)
- func (g *Generator) SetLinuxResourcesCPUCpus(cpus string)
- func (g *Generator) SetLinuxResourcesCPUMems(mems string)
- func (g *Generator) SetLinuxResourcesCPUPeriod(period uint64)
- func (g *Generator) SetLinuxResourcesCPUQuota(quota int64)
- func (g *Generator) SetLinuxResourcesCPURealtimePeriod(period uint64)
- func (g *Generator) SetLinuxResourcesCPURealtimeRuntime(time int64)
- func (g *Generator) SetLinuxResourcesCPUShares(shares uint64)
- func (g *Generator) SetLinuxResourcesMemoryDisableOOMKiller(disable bool)
- func (g *Generator) SetLinuxResourcesMemoryKernel(kernel int64)
- func (g *Generator) SetLinuxResourcesMemoryKernelTCP(kernelTCP int64)
- func (g *Generator) SetLinuxResourcesMemoryLimit(limit int64)
- func (g *Generator) SetLinuxResourcesMemoryReservation(reservation int64)
- func (g *Generator) SetLinuxResourcesMemorySwap(swap int64)
- func (g *Generator) SetLinuxResourcesMemorySwappiness(swappiness uint64)
- func (g *Generator) SetLinuxResourcesNetworkClassID(classid uint32)
- func (g *Generator) SetLinuxResourcesPidsLimit(limit int64)
- func (g *Generator) SetLinuxRootPropagation(rp string) error
- func (g *Generator) SetProcessApparmorProfile(prof string)
- func (g *Generator) SetProcessArgs(args []string)
- func (g *Generator) SetProcessConsoleSize(width, height uint)
- func (g *Generator) SetProcessCwd(cwd string)
- func (g *Generator) SetProcessGID(gid uint32)
- func (g *Generator) SetProcessNoNewPrivileges(b bool)
- func (g *Generator) SetProcessOOMScoreAdj(adj int)
- func (g *Generator) SetProcessSelinuxLabel(label string)
- func (g *Generator) SetProcessTerminal(b bool)
- func (g *Generator) SetProcessUID(uid uint32)
- func (g *Generator) SetRootPath(path string)
- func (g *Generator) SetRootReadonly(b bool)
- func (g *Generator) SetSeccompArchitecture(architecture string) error
- func (g *Generator) SetSpec(spec *rspec.Spec)
- func (g *Generator) SetSyscallAction(arguments seccomp.SyscallOpts) error
- func (g *Generator) SetVersion(version string)
- func (g *Generator) SetupPrivileged(privileged bool)
- func (g *Generator) Spec() *rspec.Spec
Constants ¶
This section is empty.
Variables ¶
var ( // Namespaces include the names of supported namespaces. Namespaces = []string{"network", "pid", "mount", "ipc", "uts", "user", "cgroup"} )
Functions ¶
This section is empty.
Types ¶
type ExportOptions ¶
type ExportOptions struct {
Seccomp bool // seccomp toggles if only seccomp should be exported
}
ExportOptions have toggles for exporting only certain parts of the specification
type Generator ¶
type Generator struct { HostSpecific bool // contains filtered or unexported fields }
Generator represents a generator for a container spec.
func NewFromFile ¶
NewFromFile loads the template specified in a file into a spec Generator.
func NewFromSpec ¶
NewFromSpec creates a spec Generator from a given spec.
func NewFromTemplate ¶
NewFromTemplate loads the template from io.Reader into a spec Generator.
func (*Generator) AddAnnotation ¶
AddAnnotation adds an annotation into g.spec.Annotations.
func (*Generator) AddBindMount ¶
AddBindMount adds a bind mount into g.spec.Mounts.
func (*Generator) AddCgroupsMount ¶
AddCgroupsMount adds a cgroup mount into g.spec.Mounts.
func (*Generator) AddDevice ¶
func (g *Generator) AddDevice(device rspec.LinuxDevice)
AddDevice - add a device into g.spec.Linux.Devices
func (*Generator) AddLinuxGIDMapping ¶
AddLinuxGIDMapping adds gidMap into g.spec.Linux.GIDMappings.
func (*Generator) AddLinuxMaskedPaths ¶
AddLinuxMaskedPaths adds masked paths into g.spec.Linux.MaskedPaths.
func (*Generator) AddLinuxReadonlyPaths ¶
AddLinuxReadonlyPaths adds readonly paths into g.spec.Linux.MaskedPaths.
func (*Generator) AddLinuxResourcesHugepageLimit ¶
AddLinuxResourcesHugepageLimit adds or sets g.spec.Linux.Resources.HugepageLimits.
func (*Generator) AddLinuxResourcesNetworkPriorities ¶
AddLinuxResourcesNetworkPriorities adds or sets g.spec.Linux.Resources.Network.Priorities.
func (*Generator) AddLinuxSysctl ¶
AddLinuxSysctl adds a new sysctl config into g.spec.Linux.Sysctl.
func (*Generator) AddLinuxUIDMapping ¶
AddLinuxUIDMapping adds uidMap into g.spec.Linux.UIDMappings.
func (*Generator) AddOrReplaceLinuxNamespace ¶
AddOrReplaceLinuxNamespace adds or replaces a namespace inside g.spec.Linux.Namespaces.
func (*Generator) AddPostStartHook ¶
AddPostStartHook adds a poststart hook into g.spec.Hooks.Poststart.
func (*Generator) AddPostStartHookEnv ¶
AddPostStartHookEnv adds envs of a poststart hook into g.spec.Hooks.Poststart.
func (*Generator) AddPostStartHookTimeout ¶
AddPostStartHookTimeout adds timeout of a poststart hook into g.spec.Hooks.Poststart.
func (*Generator) AddPostStopHook ¶
AddPostStopHook adds a poststop hook into g.spec.Hooks.Poststop.
func (*Generator) AddPostStopHookEnv ¶
AddPostStopHookEnv adds envs of a poststop hook into g.spec.Hooks.Poststop.
func (*Generator) AddPostStopHookTimeout ¶
AddPostStopHookTimeout adds timeout of a poststop hook into g.spec.Hooks.Poststop.
func (*Generator) AddPreStartHook ¶
AddPreStartHook add a prestart hook into g.spec.Hooks.Prestart.
func (*Generator) AddPreStartHookEnv ¶
AddPreStartHookEnv adds envs of a prestart hook into g.spec.Hooks.Prestart.
func (*Generator) AddPreStartHookTimeout ¶
AddPreStartHookTimeout adds timeout of a prestart hook into g.spec.Hooks.Prestart.
func (*Generator) AddProcessAdditionalGid ¶
AddProcessAdditionalGid adds an additional gid into g.spec.Process.AdditionalGids.
func (*Generator) AddProcessCapabilityAmbient ¶ added in v0.2.0
AddProcessCapabilityAmbient adds a process capability into g.spec.Process.Capabilities.Ambient.
func (*Generator) AddProcessCapabilityBounding ¶ added in v0.2.0
AddProcessCapabilityBounding adds a process capability into g.spec.Process.Capabilities.Bounding.
func (*Generator) AddProcessCapabilityEffective ¶ added in v0.2.0
AddProcessCapabilityEffective adds a process capability into g.spec.Process.Capabilities.Effective.
func (*Generator) AddProcessCapabilityInheritable ¶ added in v0.2.0
AddProcessCapabilityInheritable adds a process capability into g.spec.Process.Capabilities.Inheritable.
func (*Generator) AddProcessCapabilityPermitted ¶ added in v0.2.0
AddProcessCapabilityPermitted adds a process capability into g.spec.Process.Capabilities.Permitted.
func (*Generator) AddProcessEnv ¶
AddProcessEnv adds name=value into g.spec.Process.Env, or replaces an existing entry with the given name.
func (*Generator) AddProcessRlimits ¶
AddProcessRlimits adds rlimit into g.spec.Process.Rlimits.
func (*Generator) AddTmpfsMount ¶
AddTmpfsMount adds a tmpfs mount into g.spec.Mounts.
func (*Generator) ClearAnnotations ¶
func (g *Generator) ClearAnnotations()
ClearAnnotations clears g.spec.Annotations.
func (*Generator) ClearLinuxDevices ¶
func (g *Generator) ClearLinuxDevices()
ClearLinuxDevices clears g.spec.Linux.Devices
func (*Generator) ClearLinuxGIDMappings ¶
func (g *Generator) ClearLinuxGIDMappings()
ClearLinuxGIDMappings clear g.spec.Linux.GIDMappings.
func (*Generator) ClearLinuxNamespaces ¶
func (g *Generator) ClearLinuxNamespaces()
ClearLinuxNamespaces clear g.spec.Linux.Namespaces.
func (*Generator) ClearLinuxSysctl ¶
func (g *Generator) ClearLinuxSysctl()
ClearLinuxSysctl clears g.spec.Linux.Sysctl.
func (*Generator) ClearLinuxUIDMappings ¶
func (g *Generator) ClearLinuxUIDMappings()
ClearLinuxUIDMappings clear g.spec.Linux.UIDMappings.
func (*Generator) ClearPostStartHooks ¶
func (g *Generator) ClearPostStartHooks()
ClearPostStartHooks clear g.spec.Hooks.Poststart.
func (*Generator) ClearPostStopHooks ¶
func (g *Generator) ClearPostStopHooks()
ClearPostStopHooks clear g.spec.Hooks.Poststop.
func (*Generator) ClearPreStartHooks ¶
func (g *Generator) ClearPreStartHooks()
ClearPreStartHooks clear g.spec.Hooks.Prestart.
func (*Generator) ClearProcessAdditionalGids ¶
func (g *Generator) ClearProcessAdditionalGids()
ClearProcessAdditionalGids clear g.spec.Process.AdditionalGids.
func (*Generator) ClearProcessCapabilities ¶
func (g *Generator) ClearProcessCapabilities()
ClearProcessCapabilities clear g.spec.Process.Capabilities.
func (*Generator) ClearProcessEnv ¶
func (g *Generator) ClearProcessEnv()
ClearProcessEnv clears g.spec.Process.Env.
func (*Generator) ClearProcessRlimits ¶
func (g *Generator) ClearProcessRlimits()
ClearProcessRlimits clear g.spec.Process.Rlimits.
func (*Generator) DropLinuxResourcesHugepageLimit ¶
DropLinuxResourcesHugepageLimit drops a hugepage limit from g.spec.Linux.Resources.HugepageLimits.
func (*Generator) DropLinuxResourcesNetworkPriorities ¶
DropLinuxResourcesNetworkPriorities drops one item from g.spec.Linux.Resources.Network.Priorities.
func (*Generator) DropProcessCapabilityAmbient ¶ added in v0.2.0
DropProcessCapabilityAmbient drops a process capability from g.spec.Process.Capabilities.Ambient.
func (*Generator) DropProcessCapabilityBounding ¶ added in v0.2.0
DropProcessCapabilityBounding drops a process capability from g.spec.Process.Capabilities.Bounding.
func (*Generator) DropProcessCapabilityEffective ¶ added in v0.2.0
DropProcessCapabilityEffective drops a process capability from g.spec.Process.Capabilities.Effective.
func (*Generator) DropProcessCapabilityInheritable ¶ added in v0.2.0
DropProcessCapabilityInheritable drops a process capability from g.spec.Process.Capabilities.Inheritable.
func (*Generator) DropProcessCapabilityPermitted ¶ added in v0.2.0
DropProcessCapabilityPermitted drops a process capability from g.spec.Process.Capabilities.Permitted.
func (*Generator) RemoveAllSeccompRules ¶
RemoveAllSeccompRules removes all syscall rules
func (*Generator) RemoveAnnotation ¶
RemoveAnnotation remove an annotation from g.spec.Annotations.
func (*Generator) RemoveDevice ¶
RemoveDevice remove a device from g.spec.Linux.Devices
func (*Generator) RemoveLinuxNamespace ¶
RemoveLinuxNamespace removes a namespace from g.spec.Linux.Namespaces.
func (*Generator) RemoveLinuxSysctl ¶
RemoveLinuxSysctl removes a sysctl config from g.spec.Linux.Sysctl.
func (*Generator) RemoveProcessRlimits ¶
RemoveProcessRlimits removes a rlimit from g.spec.Process.Rlimits.
func (*Generator) RemoveSeccompRule ¶
RemoveSeccompRule removes rules for any specified syscalls
func (*Generator) Save ¶
func (g *Generator) Save(w io.Writer, exportOpts ExportOptions) (err error)
Save writes the spec into w.
func (*Generator) SaveToFile ¶
func (g *Generator) SaveToFile(path string, exportOpts ExportOptions) error
SaveToFile writes the spec into a file.
func (*Generator) SetDefaultSeccompAction ¶
SetDefaultSeccompAction sets the default action for all syscalls not defined and then removes any syscall rules with this action already specified.
func (*Generator) SetDefaultSeccompActionForce ¶
SetDefaultSeccompActionForce only sets the default action for all syscalls not defined
func (*Generator) SetHostname ¶
SetHostname sets g.spec.Hostname.
func (*Generator) SetLinuxCgroupsPath ¶
SetLinuxCgroupsPath sets g.spec.Linux.CgroupsPath.
func (*Generator) SetLinuxMountLabel ¶
SetLinuxMountLabel sets g.spec.Linux.MountLabel.
func (*Generator) SetLinuxResourcesCPUCpus ¶
SetLinuxResourcesCPUCpus sets g.spec.Linux.Resources.CPU.Cpus.
func (*Generator) SetLinuxResourcesCPUMems ¶
SetLinuxResourcesCPUMems sets g.spec.Linux.Resources.CPU.Mems.
func (*Generator) SetLinuxResourcesCPUPeriod ¶
SetLinuxResourcesCPUPeriod sets g.spec.Linux.Resources.CPU.Period.
func (*Generator) SetLinuxResourcesCPUQuota ¶
SetLinuxResourcesCPUQuota sets g.spec.Linux.Resources.CPU.Quota.
func (*Generator) SetLinuxResourcesCPURealtimePeriod ¶
SetLinuxResourcesCPURealtimePeriod sets g.spec.Linux.Resources.CPU.RealtimePeriod.
func (*Generator) SetLinuxResourcesCPURealtimeRuntime ¶
SetLinuxResourcesCPURealtimeRuntime sets g.spec.Linux.Resources.CPU.RealtimeRuntime.
func (*Generator) SetLinuxResourcesCPUShares ¶
SetLinuxResourcesCPUShares sets g.spec.Linux.Resources.CPU.Shares.
func (*Generator) SetLinuxResourcesMemoryDisableOOMKiller ¶
SetLinuxResourcesMemoryDisableOOMKiller sets g.spec.Linux.Resources.Memory.DisableOOMKiller.
func (*Generator) SetLinuxResourcesMemoryKernel ¶
SetLinuxResourcesMemoryKernel sets g.spec.Linux.Resources.Memory.Kernel.
func (*Generator) SetLinuxResourcesMemoryKernelTCP ¶
SetLinuxResourcesMemoryKernelTCP sets g.spec.Linux.Resources.Memory.KernelTCP.
func (*Generator) SetLinuxResourcesMemoryLimit ¶
SetLinuxResourcesMemoryLimit sets g.spec.Linux.Resources.Memory.Limit.
func (*Generator) SetLinuxResourcesMemoryReservation ¶
SetLinuxResourcesMemoryReservation sets g.spec.Linux.Resources.Memory.Reservation.
func (*Generator) SetLinuxResourcesMemorySwap ¶
SetLinuxResourcesMemorySwap sets g.spec.Linux.Resources.Memory.Swap.
func (*Generator) SetLinuxResourcesMemorySwappiness ¶
SetLinuxResourcesMemorySwappiness sets g.spec.Linux.Resources.Memory.Swappiness.
func (*Generator) SetLinuxResourcesNetworkClassID ¶
SetLinuxResourcesNetworkClassID sets g.spec.Linux.Resources.Network.ClassID.
func (*Generator) SetLinuxResourcesPidsLimit ¶
SetLinuxResourcesPidsLimit sets g.spec.Linux.Resources.Pids.Limit.
func (*Generator) SetLinuxRootPropagation ¶
SetLinuxRootPropagation sets g.spec.Linux.RootfsPropagation.
func (*Generator) SetProcessApparmorProfile ¶
SetProcessApparmorProfile sets g.spec.Process.ApparmorProfile.
func (*Generator) SetProcessArgs ¶
SetProcessArgs sets g.spec.Process.Args.
func (*Generator) SetProcessConsoleSize ¶
SetProcessConsoleSize sets g.spec.Process.ConsoleSize.
func (*Generator) SetProcessCwd ¶
SetProcessCwd sets g.spec.Process.Cwd.
func (*Generator) SetProcessGID ¶
SetProcessGID sets g.spec.Process.User.GID.
func (*Generator) SetProcessNoNewPrivileges ¶
SetProcessNoNewPrivileges sets g.spec.Process.NoNewPrivileges.
func (*Generator) SetProcessOOMScoreAdj ¶
SetProcessOOMScoreAdj sets g.spec.Process.OOMScoreAdj.
func (*Generator) SetProcessSelinuxLabel ¶
SetProcessSelinuxLabel sets g.spec.Process.SelinuxLabel.
func (*Generator) SetProcessTerminal ¶
SetProcessTerminal sets g.spec.Process.Terminal.
func (*Generator) SetProcessUID ¶
SetProcessUID sets g.spec.Process.User.UID.
func (*Generator) SetRootPath ¶
SetRootPath sets g.spec.Root.Path.
func (*Generator) SetRootReadonly ¶
SetRootReadonly sets g.spec.Root.Readonly.
func (*Generator) SetSeccompArchitecture ¶
SetSeccompArchitecture sets the supported seccomp architectures
func (*Generator) SetSyscallAction ¶
func (g *Generator) SetSyscallAction(arguments seccomp.SyscallOpts) error
SetSyscallAction adds rules for syscalls with the specified action
func (*Generator) SetVersion ¶
SetVersion sets g.spec.Version.
func (*Generator) SetupPrivileged ¶
SetupPrivileged sets up the privilege-related fields inside g.spec.