util

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NamespaceSeparator = '_'
)

Variables

View Source
var (
	// VERSION is set during the build from the file at itzo/version
	VERSION string = ""
	// GIT_REVISION and GIT_DIRTY are set during build.
	GIT_REVISION string = ""
	GIT_DIRTY    string = ""
)

Functions

func APIEnvVarsToMap

func APIEnvVarsToMap(envs []api.EnvVar) map[string]string

V1EnvVarsToMap constructs a map of environment name to value from a slice of env vars.

func AddToEnvList

func AddToEnvList(env []string, key string, value string, overwrite bool) []string

Add an entry to the list of environment variables. Also removes duplicate entries, only keeping the last one.

func EnsureProg

func EnsureProg(prog, downloadURL, minVersion, versionArg string) (string, error)

func EnvironToAPIEnvVar

func EnvironToAPIEnvVar(envs []string) []api.EnvVar

func ExpandContainerCommandOnlyStatic

func ExpandContainerCommandOnlyStatic(containerCommand []string, envs []api.EnvVar) (command []string)

ExpandContainerCommandOnlyStatic substitutes only static environment variable values from the container environment definitions. This does *not* include valueFrom substitutions. TODO: callers should use ExpandContainerCommandAndArgs with a fully resolved list of environment.

func GetNameFromString

func GetNameFromString(n string) string

func GetNamespaceFromString

func GetNamespaceFromString(n string) string

func GetNumberOfFreeAndAvailableBlocks

func GetNumberOfFreeAndAvailableBlocks(path string) (uint64, uint64, error)

func InstallProg

func InstallProg(url, path string) error

func LookupUser

func LookupUser(userspec string, lookup UserLookup) (uint32, uint32, string, error)

func MapDiff

func MapDiff(spec, status map[string]interface{}) ([]string, []string, []string)

func Minint64

func Minint64(a, b int64) int64

func ParseImageSpec

func ParseImageSpec(image string) (string, string, error)

Parse the image spec and extract the registry server and the repo name. Example image specs:

ECS: ACCOUNT.dkr.ecr.REGION.amazonaws.com/imagename:tag
Docker Hub: imagename:tag or owner/imagename:tag

func RunProg

func RunProg(prog string, outputLimit, maxRetries int, args ...string) error

func SetOOMScore

func SetOOMScore(pid, score int) error

We disable the OOM Killer for Itzo in the itzo startup script but we want to reenable it for user processes that itzo spawns

func SplitNamespaceAndName

func SplitNamespaceAndName(n string) (string, string)

func Version

func Version() string

func WithNamespace

func WithNamespace(ns, name string) string

Types

type FakeUserLookup

type FakeUserLookup struct {
	Uid     uint32
	UidGid  uint32
	UidErr  error
	Gid     uint32
	GidErr  error
	Homedir string
}

func (*FakeUserLookup) Lookup

func (ful *FakeUserLookup) Lookup(username string) (*user.User, error)

func (*FakeUserLookup) LookupGroup

func (ful *FakeUserLookup) LookupGroup(name string) (*user.Group, error)

func (*FakeUserLookup) LookupGroupId

func (ful *FakeUserLookup) LookupGroupId(name string) (*user.Group, error)

func (*FakeUserLookup) LookupId

func (ful *FakeUserLookup) LookupId(username string) (*user.User, error)

type OsUserLookup

type OsUserLookup struct{}

func (*OsUserLookup) Lookup

func (oul *OsUserLookup) Lookup(username string) (*user.User, error)

func (*OsUserLookup) LookupGroup

func (oul *OsUserLookup) LookupGroup(name string) (*user.Group, error)

func (*OsUserLookup) LookupGroupId

func (oul *OsUserLookup) LookupGroupId(name string) (*user.Group, error)

func (*OsUserLookup) LookupId

func (oul *OsUserLookup) LookupId(username string) (*user.User, error)

type PasswdUserLookup

type PasswdUserLookup struct {
	RootFs string
	// contains filtered or unexported fields
}

func NewPasswdUserLookup

func NewPasswdUserLookup(path string) (*PasswdUserLookup, error)

func (*PasswdUserLookup) Lookup

func (l *PasswdUserLookup) Lookup(username string) (*user.User, error)

func (*PasswdUserLookup) LookupGroup

func (l *PasswdUserLookup) LookupGroup(name string) (*user.Group, error)

func (*PasswdUserLookup) LookupGroupId

func (l *PasswdUserLookup) LookupGroupId(name string) (*user.Group, error)

func (*PasswdUserLookup) LookupId

func (l *PasswdUserLookup) LookupId(username string) (*user.User, error)

type UserLookup

type UserLookup interface {
	Lookup(username string) (*user.User, error)
	LookupId(username string) (*user.User, error)
	LookupGroup(name string) (*user.Group, error)
	LookupGroupId(name string) (*user.Group, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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