utils

package
v1.10.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2023 License: Apache-2.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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

func IsDockerInstalled() bool

IsDockerInstalled checks whether docker is installed/running.

func IsPodmanInstalled added in v1.9.0

func IsPodmanInstalled() bool

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 RunCmdAndWait

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

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"
)

Jump to

Keyboard shortcuts

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