utils

package
v0.0.0-...-3d7b588 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttachJobObjectToProcess

func AttachJobObjectToProcess(pid string, proc *os.Process)

Attach Job object to App Process.

func CheckIfPortAvailable

func CheckIfPortAvailable(port int) error

CheckIfPortAvailable returns an error if the port is not available else returns nil.

func Contains

func Contains[T comparable](vs []T, x T) bool

Contains returns true if vs contains x.

func CreateContainerName

func CreateContainerName(serviceContainerName string, dockerNetwork string) string

func CreateDirectory

func CreateDirectory(dir string) error

func FindFileInDir

func FindFileInDir(dirPath, fileName string) (string, error)

FindFileInDir finds and returns the path of the given file name in the given directory.

func GetAbsPath

func GetAbsPath(baseDir, path string) string

GetAbsPath returns the absolute path of the given file path and base directory.

func GetContainerRuntimeCmd

func GetContainerRuntimeCmd(containerRuntime string) string

GetContainerRuntimeCmd returns a valid container runtime to be used by CLI operations. If the input is a valid container runtime, it is returned as is. Otherwise the default container runtime, docker, is returned.

func GetDefaultRegistry

func GetDefaultRegistry(githubContainerRegistryName, dockerContainerRegistryName string) (string, error)

func GetEnv

func GetEnv(envName string, defaultValue string) string

GetEnv get value from environment variable.

func GetJobObjectNameFromPID

func GetJobObjectNameFromPID(pid string) string

GetJobObjectNameFromPID returns the name of the Windows job object that is used to manage the Daprized app's processes on windows.

func GetSocket

func GetSocket(path, appID, protocol string) string

func GetVariantVersion

func GetVariantVersion(version, imageVariant string) string

func GetVersionAndImageVariant

func GetVersionAndImageVariant(imageTag string) (string, string)

Returns image version and variant. Expected imageTag format: <version>-<variant>, i.e. 1.0.0-mariner or 1.0.0-rc.1-mariner.

func IsAddressLegal

func IsAddressLegal(address string) bool

func IsContainerRuntimeInstalled

func IsContainerRuntimeInstalled(containerRuntime string) bool

IsContainerRuntimeInstalled checks whether the given container runtime is installed. If the container runtime is unsupported, false is returned.

func IsDaprListeningOnPort

func IsDaprListeningOnPort(port int, timeout time.Duration) error

IsDaprListeningOnPort checks if Dapr is litening to a given port.

func IsDaprListeningOnSocket

func IsDaprListeningOnSocket(socket string, timeout time.Duration) error

func IsValidContainerRuntime

func IsValidContainerRuntime(containerRuntime string) bool

IsValidContainerRuntime checks if the input is a valid container runtime. Valid container runtimes are docker and podman.

func MarshalAndWriteTable

func MarshalAndWriteTable(writer io.Writer, in interface{}) error

func PrintDetail

func PrintDetail(writer io.Writer, outputFormat string, list interface{}) error

func PrintTable

func PrintTable(csvContent string)

PrintTable to print in the table format.

func ReadFile

func ReadFile(filePath string) ([]byte, error)

func ResolveHomeDir

func ResolveHomeDir(filePath string) (string, error)

ResolveHomeDir resolves prefix of the given path, if present, to the user's home directory and returns it.

func RunCmdAndWait

func RunCmdAndWait(name string, args ...string) (string, error)

func SanitizeDir

func SanitizeDir(destDir string) string

SanitizeDir sanitizes the input string to make it a valid directory.

func TruncateString

func TruncateString(str string, maxLength int) string

func ValidateFilePath

func ValidateFilePath(filePath string) error

Returns true if the given file path is valid.

func ValidateImageVariant

func ValidateImageVariant(imageVariant string) error

func WriteTable

func WriteTable(writer io.Writer, csvContent string)

WriteTable writes the csv table to writer.

Types

type ContainerRuntime

type ContainerRuntime string
const (
	DOCKER ContainerRuntime = "docker"
	PODMAN ContainerRuntime = "podman"

	// DefaultAppChannelAddress is the default local network address that user application listen on.
	DefaultAppChannelAddress = "127.0.0.1"
)

Jump to

Keyboard shortcuts

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