utils

package
v1.9.5 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Info print message
	Info func(a ...interface{})
	// Infof print message with format
	Infof func(format string, a ...interface{})
	// InfoP print message with padding
	InfoP func(padding int, a ...interface{})
	// Errf print error with format
	Errf func(format string, a ...interface{})
)

Functions

func Cleanup

func Cleanup() error

Cleanup removes the temporary directory

func CloseQuietly

func CloseQuietly(d io.Closer)

CloseQuietly closes `io.Closer` quietly. Very handy and helpful for code quality too.

func EditGatewayDefinition added in v1.7.4

func EditGatewayDefinition() error

EditGatewayDefinition edits the gateway trait definition. In VelaD, we use Traefik instead of Nginx.

func Exec

func Exec(ctx context.Context, cli *client.Client, containerID string, command []string) (types.IDResponse, error)

Exec create an exec command and return its ID

func GetCLIInstallPath added in v1.3.4

func GetCLIInstallPath() string

GetCLIInstallPath get vela CLI install path

func GetClient added in v1.7.4

func GetClient() (client.Client, error)

GetClient returns a client.Client

func GetDefaultVelaDKubeconfigPath

func GetDefaultVelaDKubeconfigPath() string

GetDefaultVelaDKubeconfigPath returns the default kubeconfig path for VelaD

func GetKubeconfigDir

func GetKubeconfigDir() string

GetKubeconfigDir returns the kubeconfig directory.

func GetTmpDir

func GetTmpDir() (string, error)

GetTmpDir returns the temporary directory when want to save some files

func GetTokenFromCluster

func GetTokenFromCluster(ctx context.Context, clusterName string) (string, error)

GetTokenFromCluster returns the token for k3d cluster

func InfoBytes

func InfoBytes(b []byte)

InfoBytes is a helper function to print a byte array

func IsVelaCommand

func IsVelaCommand(s string) bool

IsVelaCommand judge if app start by vela

func NewActionConfig

func NewActionConfig(config *rest.Config, showDetail bool) (*action.Configuration, error)

NewActionConfig returns a new helm action config

func PrintGuide

func PrintGuide(ctx *apis.Context, args apis.InstallArgs)

PrintGuide will print guide for user.

func RemoveNetworkProxyEnv added in v1.5.0

func RemoveNetworkProxyEnv()

RemoveNetworkProxyEnv remove network proxy environment vars in shell

func SaveToTemp

func SaveToTemp(content io.Reader, format string) (string, error)

SaveToTemp helps save an embedded file into a temporary file

func SetDefaultKubeConfigEnv

func SetDefaultKubeConfigEnv() error

SetDefaultKubeConfigEnv helps set KUBECONFIG to the default location

func TransArgsToString

func TransArgsToString(args cli.InstallArgs) []string

TransArgsToString converts args to string array, which helps to pass args to vela install command

func UnsupportedOS

func UnsupportedOS(os string)

UnsupportedOS will panic with a message about the unsupported OS

func WarnSaveToken

func WarnSaveToken(token string, clusterName string)

WarnSaveToken warns user to save token for cluster

Types

type ExecResult

type ExecResult struct {
	StdOut   string
	StdErr   string
	ExitCode int
}

ExecResult is the result of Docker Exec

func InspectExecResp

func InspectExecResp(ctx context.Context, cli *client.Client, id string) (ExecResult, error)

InspectExecResp helps turns types.IDResponse into a ExecResult

type VeladWriter

type VeladWriter struct {
	W io.Writer
}

VeladWriter will change "vela addon enable" hint and print else as it is.

func (VeladWriter) Write

func (v VeladWriter) Write(p []byte) (n int, err error)

Write implements io.Writer. Change the hint to "vela addon enable velaux" and print it with local dir.

Jump to

Keyboard shortcuts

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