utils

package
v0.0.0-...-50ffc52 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BecomeProcessGroupLeader

func BecomeProcessGroupLeader() int

func Contains

func Contains(items []string, ele string) bool

func CreateDevices

func CreateDevices() error

func FileExists

func FileExists(name string) bool

func KillProcess

func KillProcess(pid int) error

func Mkdev

func Mkdev(major, minor int) int

Mkdev is used to build the value of linux devices (in /dev/) which specifies major and minor number of the newly created device special file. Linux device nodes are a bit weird due to backwards compat with 16 bit device nodes. They are, from low to high: the lower 8 bits of the minor, then 12 bits of the major, then the top 12 bits of the minor.

func Mknod

func Mknod(path string, mode uint32, dev int) error

Mknod creates a filesystem node (file, device special file or named pipe) named path with attributes specified by mode and dev.

func UpdateEnv

func UpdateEnv(env []string)

func ValidateEnv

func ValidateEnv(val string) (string, error)

ValidateEnv validates an environment variable and returns it. If no value is specified, it obtains its value from the current environment

As on ParseEnvFile and related to #16585, environment variable names are not validated, and it's up to the application inside the container to validate them or not.

The only validation here is to check if name is empty, per #25099

func ValidateIPAddress

func ValidateIPAddress(val string) (string, error)

ValidateIPAddress validates an Ip address.

Types

type ListOpts

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

ListOpts holds a list of values and a validation function.

func NewListOpts

func NewListOpts(validator ValidatorFctType) ListOpts

NewListOpts creates a new ListOpts with the specified validator.

func NewListOptsRef

func NewListOptsRef(values *[]string, validator ValidatorFctType) *ListOpts

NewListOptsRef creates a new ListOpts with the specified values and validator.

func (*ListOpts) Delete

func (opts *ListOpts) Delete(key string)

Delete removes the specified element from the slice.

func (*ListOpts) Get

func (opts *ListOpts) Get(key string) bool

Get checks the existence of the specified key.

func (*ListOpts) GetAll

func (opts *ListOpts) GetAll() []string

GetAll returns the values of slice.

func (*ListOpts) GetAllOrEmpty

func (opts *ListOpts) GetAllOrEmpty() []string

GetAllOrEmpty returns the values of the slice or an empty slice when there are no values.

func (*ListOpts) GetMap

func (opts *ListOpts) GetMap() map[string]struct{}

GetMap returns the content of values in a map in order to avoid duplicates.

func (*ListOpts) Len

func (opts *ListOpts) Len() int

Len returns the amount of element in the slice.

func (*ListOpts) Set

func (opts *ListOpts) Set(value string) error

Set validates if needed the input value and adds it to the internal slice.

func (*ListOpts) String

func (opts *ListOpts) String() string

func (*ListOpts) Type

func (opts *ListOpts) Type() string

Type returns a string name for this Option type

func (*ListOpts) WithValidator

func (opts *ListOpts) WithValidator(validator ValidatorFctType) *ListOpts

WithValidator returns the ListOpts with validator set.

type MemBytes

type MemBytes int64

MemBytes is a type for human readable memory bytes (like 128M, 2g, etc)

func (*MemBytes) Set

func (m *MemBytes) Set(value string) error

Set sets the value of the MemBytes by passing a string

func (*MemBytes) String

func (m *MemBytes) String() string

String returns the string format of the human readable memory bytes

func (*MemBytes) Type

func (m *MemBytes) Type() string

Type returns the type

func (*MemBytes) Value

func (m *MemBytes) Value() int64

Value returns the value in int64

type MemSwapBytes

type MemSwapBytes int64

MemSwapBytes is a type for human readable memory bytes (like 128M, 2g, etc). It differs from MemBytes in that -1 is valid and the default.

func (*MemSwapBytes) Set

func (m *MemSwapBytes) Set(value string) error

Set sets the value of the MemSwapBytes by passing a string

func (*MemSwapBytes) String

func (m *MemSwapBytes) String() string

func (*MemSwapBytes) Type

func (m *MemSwapBytes) Type() string

Type returns the type

func (*MemSwapBytes) Value

func (m *MemSwapBytes) Value() int64

Value returns the value in int64

type ValidatorFctListType

type ValidatorFctListType func(val string) ([]string, error)

ValidatorFctListType defines a validator function that returns a validated list of string and/or an error

type ValidatorFctType

type ValidatorFctType func(val string) (string, error)

ValidatorFctType defines a validator function that returns a validated string and/or an error.

Jump to

Keyboard shortcuts

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