utils

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 19 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttachJobObjectToProcess added in v1.12.0

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

Attach Job object to App Process.

func CheckIfPortAvailable added in v1.10.0

func CheckIfPortAvailable(port int) error

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

func Contains added in v1.9.0

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

Contains returns true if vs contains x.

func CreateContainerName added in v0.2.0

func CreateContainerName(serviceContainerName string, dockerNetwork string) string

func CreateDirectory added in v0.3.0

func CreateDirectory(dir string) error

func FindFileInDir added in v1.10.0

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

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

func GetAbsPath added in v1.10.0

func GetAbsPath(baseDir, path string) string

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

func GetContainerRuntimeCmd added in v1.9.0

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 added in v1.7.0

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

func GetEnv added in v1.9.0

func GetEnv(envName string, defaultValue string) string

GetEnv get value from environment variable.

func GetJobObjectNameFromPID added in v1.12.0

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 added in v1.5.0

func GetSocket(path, appID, protocol string) string

func GetVariantVersion added in v1.9.0

func GetVariantVersion(version, imageVariant string) string

func GetVersionAndImageVariant added in v1.10.0

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 added in v1.4.0

func IsAddressLegal(address string) bool

func IsContainerRuntimeInstalled added in v1.12.0

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 added in v0.11.0

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

IsDaprListeningOnPort checks if Dapr is litening to a given port.

func IsDaprListeningOnSocket added in v1.5.0

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

func IsValidContainerRuntime added in v1.9.0

func IsValidContainerRuntime(containerRuntime string) bool

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

func MarshalAndWriteTable added in v1.0.0

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

func PrintDetail added in v1.0.0

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 added in v1.10.0

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

func ResolveHomeDir added in v1.11.0

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 added in v1.12.0

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 added in v1.10.0

func ValidateFilePath(filePath string) error

Returns true if the given file path is valid.

func ValidateImageVariant added in v1.9.0

func ValidateImageVariant(imageVariant string) error

func WriteTable added in v1.0.0

func WriteTable(writer io.Writer, csvContent string)

WriteTable writes the csv table to writer.

Types

type ContainerRuntime added in v1.9.0

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