package common
import "github.com/coreos/rkt/common"
Package common defines values shared by different parts of rkt (e.g. stage0 and stage1)
Index ¶
- Constants
- func AppCreatedPath(root, appName string) string
- func AppCreatedPathFromStage1Rootfs(rootfs, appName string) string
- func AppImageManifestPath(root string, appName types.ACName) string
- func AppInfoPath(root string, appName types.ACName) string
- func AppPath(root string, appName types.ACName) string
- func AppRootfsPath(root string, appName types.ACName) string
- func AppStartedPath(root, appName string) string
- func AppStartedPathFromStage1Rootfs(rootfs, appName string) string
- func AppStatusPath(root, appName string) string
- func AppStatusPathFromStage1Rootfs(rootfs, appName string) string
- func AppTreeStoreIDPath(root string, appName types.ACName) string
- func AppsInfoPath(root string) string
- func AppsPath(root string) string
- func AppsStatusesPath(root string) string
- func AppsStatusesPathFromStage1Rootfs(rootfs string) string
- func ChrootPrivateUnmount(targetPath string, log *rktlog.Logger, diagf func(string, ...interface{})) error
- func ComposeEnviron(env types.Environment) []string
- func CreateSharedVolumesPath(root string) (string, error)
- func GetArch() string
- func GetExitStatus(err error) (int, error)
- func GetOS() string
- func GetOSArch() (os string, arch string)
- func GetRktLockFD() (int, error)
- func ImageManifestPath(root string, appName types.ACName) string
- func ImageNameToAppName(name types.ACIdentifier) (*types.ACName, error)
- func IsDNSZero(dns *cnitypes.DNS) bool
- func IsExperimentEnabled(name string) bool
- func LookupGid(groupName string) (gid int, err error)
- func LookupPath(bin string, paths string) (string, error)
- func MakeResolvConf(dns cnitypes.DNS, comment string) string
- func MetadataServicePublicURL(ip net.IP, token string) string
- func PathSupportsOverlay(path string) error
- func PodCreatedPath(root string) string
- func PodManifestLockPath(root string) string
- func PodManifestPath(root string) string
- func ReadEnvFileRaw(envFilePath string) ([]string, error)
- func RelAppPath(appName types.ACName) string
- func RelAppRootfsPath(appName types.ACName) string
- func RemoveEmptyLines(str string) []string
- func SharedVolumesPath(root string) string
- func SliceToPath(unit string) (string, error)
- func Stage1ImagePath(root string) string
- func Stage1ManifestPath(root string) string
- func Stage1RootfsPath(root string) string
- func SupportsOverlay() error
- func SupportsUserNS() bool
- func SystemdVersion(systemdBinaryPath string) (int, error)
- func WriteEnvFile(env []string, uidRange *user.UidRange, envFilePath string) error
- type ErrOverlayUnsupported
- type NetList
- func (l *NetList) All() bool
- func (l *NetList) Contained() bool
- func (l *NetList) Host() bool
- func (l *NetList) None() bool
- func (l *NetList) Set(value string) error
- func (l *NetList) Specific(net string) bool
- func (l *NetList) SpecificArgs(net string) string
- func (l *NetList) String() string
- func (l *NetList) Strings() []string
- func (l *NetList) StringsOnlyNames() (list []string)
- func (l *NetList) Type() string
Constants ¶
const ( os.FileMode(0755) AppsInfoDir = "/appsinfo" EnvLockFd = "RKT_LOCK_FD" EnvSELinuxContext = "RKT_SELINUX_CONTEXT" EnvSELinuxMountContext = "RKT_SELINUX_MOUNT_CONTEXT" Stage1TreeStoreIDFilename = "stage1TreeStoreID" AppTreeStoreIDFilename = "treeStoreID" OverlayPreparedFilename = "overlay-prepared" PrivateUsersPreparedFilename = "private-users-prepared" PrepareLock = "prepareLock" MetadataServicePort = 18112 MetadataServiceRegSock = "/run/rkt/metadata-svc.sock" APIServiceListenAddr = "localhost:15441" DefaultLocalConfigDir = "/etc/rkt" DefaultSystemConfigDir = "/usr/lib/rkt" // Default perm bits for the regular files // within the stage1 directory. (e.g. image manifest, // pod manifest, stage1ID, etc). DefaultRegularFilePerm = os.FileMode(0640) // Default perm bits for the regular directories // within the stage1 directory. DefaultRegularDirPerm = os.FileMode(0750) // Enter command for crossing entrypoints. CrossingEnterCmd = "RKT_STAGE1_ENTERCMD" // Stage1 (PID) to enter, used by crossing entrypoints. CrossingEnterPID = "RKT_STAGE1_ENTERPID" // Stage2 (application name) to enter, optionally used by crossing entrypoints. CrossingEnterApp = "RKT_STAGE1_ENTERAPP" )=
const ( FsMagicAUFS = 0x61756673 // https://goo.gl/CBwx43 FsMagicZFS = 0x2FC12FC1 // https://goo.gl/xTvzO5 )
const ( RktGroup = "rkt" // owns /var/lib/rkt RktAdminGroup = "rkt-admin" // owns /etc/rkt )
const DefaultPath = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Functions ¶
func AppCreatedPath ¶
AppCreatedPath returns the path of the ${appname}-created file, which is used to record the creation timestamp of the app.
func AppCreatedPathFromStage1Rootfs ¶
AppCreatedPathFromStage1Rootfs returns the path of the ${appname}-created file, which is used to record the creation timestamp of the app. It receives the stage1 rootfs as parameter instead of the pod root.
func AppImageManifestPath ¶
AppImageManifestPath returns the path to the app's ImageManifest file
func AppInfoPath ¶
AppInfoPath returns the path to the app's appsinfo directory of a pod.
func AppPath ¶
AppPath returns the path to an app's rootfs.
func AppRootfsPath ¶
AppRootfsPath returns the path to an app's rootfs.
func AppStartedPath ¶
AppStartedPath returns the path of the ${appname}-started file, which is used to record the start timestamp of the app.
func AppStartedPathFromStage1Rootfs ¶
AppStartedPathFromStage1Rootfs returns the path of the ${appname}-started file, which is used to record the start timestamp of the app. It receives the stage1 rootfs as parameter instead of the pod root.
func AppStatusPath ¶
AppStatusPath returns the path of the status file of an app.
func AppStatusPathFromStage1Rootfs ¶
AppStatusPathFromStage1Rootfs returns the path of the status file of an app. It receives the stage1 rootfs as parameter instead of the pod root.
func AppTreeStoreIDPath ¶
AppTreeStoreIDPath returns the path to the app's treeStoreID file of a pod.
func AppsInfoPath ¶
AppsInfoPath returns the path to the appsinfo directory of a pod.
func AppsPath ¶
AppsPath returns the path where the apps within a pod live.
func AppsStatusesPath ¶
AppsStatusesPath returns the path of the status dir for all apps.
func AppsStatusesPathFromStage1Rootfs ¶
AppsStatusesPathFromStage1Rootfs returns the path of the status dir for all apps. It receives the stage1 rootfs as parameter instead of the pod root.
func ChrootPrivateUnmount ¶
func ChrootPrivateUnmount(targetPath string, log *rktlog.Logger, diagf func(string, ...interface{})) error
ChrootPrivateUnmount cleans up in a safe way all mountpoints existing under `targetPath`. This requires multiple steps:
- take handles to the current rootdir and workdir (to restore at the end)
- parse /proc/self/mountinfo to get a list of all mount targets, and filter out those outside of targetPath
- chroot into target path, so that all mounts and symlinks can be properly de-referenced as they appear inside the rootfs
- mark all mounts as private, so that further operations are not propagated outside of this rootfs - in descending nest order (parent first)
- unmount all mount targets - in ascending nest order (children first). If unmount fails, lazy-detach the mount target so that the kernel can still clean it up once it ceases to be busy
- chdir and chroot back to the original state
func ComposeEnviron ¶
func ComposeEnviron(env types.Environment) []string
ComposeEnviron formats the environment into a slice of strings, each of the form "key=value". The minimum required environment variables by the appc spec will be set to sensible defaults here if they're not provided by env.
func CreateSharedVolumesPath ¶
CreateSharedVolumesPath ensures the sharedVolumePath for the pod root passed in exists. It returns the shared volume path or an error.
func GetArch ¶
func GetArch() string
GetArch returns the current ACI architecture.
func GetExitStatus ¶
GetExitStatus converts an error to an exit status. If it wasn't an exit status != 0 it returns the same error that it was called with
func GetOS ¶
func GetOS() string
GetOS returns the current ACI operating system (linux, windows etc...)
func GetOSArch ¶
func GetRktLockFD ¶
func ImageManifestPath ¶
ImageManifestPath returns the path to the app's manifest file of a pod.
func ImageNameToAppName ¶
func ImageNameToAppName(name types.ACIdentifier) (*types.ACName, error)
ImageNameToAppName converts the full name of image to an app name without special characters - we use it as a default app name when specyfing it is optional
func IsDNSZero ¶
- TODO(cdc) move this to cnitypes
IsDNSZero checks if the DNS configuration has any information
func IsExperimentEnabled ¶
IsExperimentEnabled returns true if the given rkt experiment is enabled. The given name is converted to upper case and a bool RKT_EXPERIMENT_{NAME} environment variable is retrieved. If the experiment name is unknown, false is returned. If the environment variable does not contain a valid bool value according to strconv.ParseBool, false is returned.
func LookupGid ¶
LookupGid reads the group file and returns the gid of the group specified by groupName.
func LookupPath ¶
LookupPath search for bin in paths. If found, it returns its absolute path, if not, an error
func MakeResolvConf ¶
MakeResolvConf generates resolv.conf contents given a cni DNS configuration
func MetadataServicePublicURL ¶
MetadataServicePublicURL returns the public URL used to host the metadata service
func PathSupportsOverlay ¶
PathSupportsOverlay checks whether the given path is compatible with OverlayFS. This method also calls SupportsOverlay().
It returns an instance of ErrOverlayUnsupported if OverlayFS is not supported or any other error if determining overlay support failed.
func PodCreatedPath ¶
PodCreatedPath returns the path in root to the Pod Created file used to denote the time of creation.
func PodManifestLockPath ¶
PodManifestLockPath returns the path in root to the Pod Manifest lock file. This must be different from the PodManifestPath since mutations on the pod manifest file happen by overwriting the original file.
func PodManifestPath ¶
PodManifestPath returns the path in root to the Pod Manifest
func ReadEnvFileRaw ¶
ReadEnvFileRaw reads the environment file, returning it as a slice of strings, each expected but not checked to be of the form "key=value". (The suffix leaves room for a function which parallels WriteEnvFile, which splits each string and has a return type of types.Environment.)
func RelAppPath ¶
RelAppPath returns the path of an app relative to the stage1 chroot.
func RelAppRootfsPath ¶
RelAppRootfsPath returns the path of an app's rootfs relative to the stage1 chroot.
func RemoveEmptyLines ¶
RemoveEmptyLines removes empty lines from the given string and breaks it up into a list of strings at newline characters
func SharedVolumesPath ¶
SharedVolumesPath returns the path to the shared (empty) volumes of a pod.
func SliceToPath ¶
SliceToPath explodes a slice name to its corresponding path in the cgroup hierarchy. For example, a slice named "foo-bar-baz.slice" corresponds to the path "foo.slice/foo-bar.slice/foo-bar-baz.slice". See systemd.slice(5)
func Stage1ImagePath ¶
Stage1ImagePath returns the path where the stage1 app image (unpacked ACI) is rooted, (i.e. where its contents are extracted during stage0).
func Stage1ManifestPath ¶
Stage1ManifestPath returns the path to the stage1's manifest file inside the expanded ACI.
func Stage1RootfsPath ¶
Stage1RootfsPath returns the path to the stage1 rootfs
func SupportsOverlay ¶
func SupportsOverlay() error
SupportsOverlay returns whether the operating system generally supports OverlayFS, returning an instance of ErrOverlayUnsupported which encodes the reason. It is sufficient to check for nil if the reason is not of interest.
func SupportsUserNS ¶
func SupportsUserNS() bool
SupportsUserNS returns whether the kernel has CONFIG_USER_NS set
func SystemdVersion ¶
SystemdVersion parses and returns the version of a given systemd binary
func WriteEnvFile ¶
WriteEnvFile creates an environment file for given app name. To ensure the minimum required environment variables by the appc spec are set to sensible defaults, env should be the result of calling ComposeEnviron. The containing directory and its ancestors will be created if necessary.
Types ¶
type ErrOverlayUnsupported ¶
type ErrOverlayUnsupported string
ErrOverlayUnsupported is the error determining whether OverlayFS is supported.
func (ErrOverlayUnsupported) Error ¶
func (e ErrOverlayUnsupported) Error() string
type NetList ¶
type NetList struct {
// contains filtered or unexported fields
}
NetList implements the flag.Value interface to allow specification of --net with and without values Example: --net="all,net1:k1=v1;k2=v2,net2:l1=w1"
func (*NetList) All ¶
func (*NetList) Contained ¶
Check if the container needs to be put in a separate network namespace
func (*NetList) Host ¶
Check if host networking has been requested
func (*NetList) None ¶
Check if 'none' (loopback only) networking has been requested
func (*NetList) Set ¶
func (*NetList) Specific ¶
func (*NetList) SpecificArgs ¶
func (*NetList) String ¶
func (*NetList) Strings ¶
func (*NetList) StringsOnlyNames ¶
func (*NetList) Type ¶
Source Files ¶
cgroup_util.go common.go environment.go experiment.go group.go mount.go resolv_conf.go
Directories ¶
Path | Synopsis |
---|---|
common/apps | |
common/cgroup | |
common/cgroup/v1 | |
common/cgroup/v2 | |
common/labelsort | |
common/networking | networking is the package that implements small functionality shared between state0 and stage1. |
common/overlay |
- Version
- v1.30.0 (latest)
- Published
- Apr 13, 2018
- Platform
- linux/amd64
- Imports
- 25 packages
- Last checked
- 5 days ago –
Tools for package owners.