utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildExecCommandString

func BuildExecCommandString(cmd []string, env []corev1.EnvVar) (string, error)

BuildExecCommandString returns a shell command that executes the given command in a shell. The command is formatted as "sh -c $'COMMAND'" where COMMAND is the given command string. If the command has arguments, they are appended to the command string.

func BuildExportEnvCommand

func BuildExportEnvCommand(env corev1.EnvVar) string

BuildExportEnvCommand returns a shell command that exports the given environment variable. The command is formatted as "export NAME=VALUE" where VALUE is escaped using heredoc syntax if it contains newlines.

func ExtractCPURequest

func ExtractCPURequest(rl corev1.ResourceList) (uint, error)

func ExtractMemoryRequest

func ExtractMemoryRequest(rl corev1.ResourceList) (uint64, error)

func GetContainerID

func GetContainerID(protocol, containerName string) string

GetContainerID returns a container ID based on the container name

func SanitizeAppleCPUModelForK8sLabel

func SanitizeAppleCPUModelForK8sLabel(name string) string

SanitizeAppleCPUModelForK8sLabel simplifies the Apple CPU model name to a valid k8s label value

Types

type FileCloner

type FileCloner struct {
	TempDir          string
	FilenamePrefix   string
	SysClonefileFunc func(src, dst string, flags int) error
}

FileCloner is a utility to clone files.

func NewFileCloner

func NewFileCloner() *FileCloner

NewFileCloner creates a new FileCloner with default values.

func (*FileCloner) Clonefile

func (fc *FileCloner) Clonefile(path, pattern string) (string, error)

Clonefile clones the file at the given path and returns the path of the cloned file.

Jump to

Keyboard shortcuts

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