util

package
Version: v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2021 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CfgFile string
	WorkDir string
	LogDir  string
)

Functions

func AddShutDownHook added in v1.1.0

func AddShutDownHook(stopFunc func())

func CheckDockerDaemon

func CheckDockerDaemon() error

CheckDockerDaemon checks if docker daemon is running.

func ExecuteCommand

func ExecuteCommand(cmd string) (stdout, stderr string, err error)

ExecuteCommand executes the given command and returns the result.

func ExpandFilePath

func ExpandFilePath(path string) string

ExpandFilePath expands the leading `~` to absolute path

func ExportEnvVars added in v1.1.0

func ExportEnvVars(envFile string)

func GetManifests

func GetManifests(manifests string) (files []string, err error)

GetManifests recursively gets all yml and yaml files from manifests string.

func OperateManifest

func OperateManifest(c *kubernetes.Clientset, dc dynamic.Interface, manifest string, operation apiv1.Operation) error

OperateManifest operates manifest in k8s cluster which kind created.

func PathExist

func PathExist(_path string) bool

PathExist checks if a file/directory is exist.

func ReadFileContent

func ReadFileContent(filename string) (string, error)

ReadFileContent reads the file content.

func ResolveAbs

func ResolveAbs(p string) string

ResolveAbs resolves the relative path (relative to CfgFile) to an absolute file path.

func ResolveAbsWithBase added in v1.1.0

func ResolveAbsWithBase(p, baseFile string) string

ResolveAbsWithBase resolves the relative path (relative to appoint file path) to an absolute file path.

func UserHomeDir

func UserHomeDir() string

UserHomeDir returns the current user's home directory absolute path, which is usually represented as `~` in most shells

Types

type HookScriptTemplate

type HookScriptTemplate struct {
	EnvFile string
}

type K8sClusterInfo

type K8sClusterInfo struct {
	Client    *kubernetes.Clientset
	Interface dynamic.Interface
	// contains filtered or unexported fields
}

K8sClusterInfo created when connect to cluster

func ConnectToK8sCluster

func ConnectToK8sCluster(kubeConfigPath string) (info *K8sClusterInfo, err error)

ConnectToK8sCluster gets clientSet and dynamic client from k8s config file.

func (*K8sClusterInfo) CopyClusterToNamespace added in v1.1.0

func (c *K8sClusterInfo) CopyClusterToNamespace(namespace string) *K8sClusterInfo

func (*K8sClusterInfo) ToDiscoveryClient added in v1.1.0

func (c *K8sClusterInfo) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)

func (*K8sClusterInfo) ToRESTConfig added in v1.1.0

func (c *K8sClusterInfo) ToRESTConfig() (*rest.Config, error)

func (*K8sClusterInfo) ToRESTMapper added in v1.1.0

func (c *K8sClusterInfo) ToRESTMapper() (meta.RESTMapper, error)

func (*K8sClusterInfo) ToRawKubeConfigLoader added in v1.1.0

func (c *K8sClusterInfo) ToRawKubeConfigLoader() clientcmd.ClientConfig

type ResourceLogFollower added in v1.1.0

type ResourceLogFollower struct {
	Ctx context.Context
	// contains filtered or unexported fields
}

func NewResourceLogFollower added in v1.1.0

func NewResourceLogFollower(ctx context.Context, basePath string) *ResourceLogFollower

func (*ResourceLogFollower) BuildLogWriter added in v1.1.0

func (l *ResourceLogFollower) BuildLogWriter(path string) (*os.File, error)

func (*ResourceLogFollower) Close added in v1.1.0

func (l *ResourceLogFollower) Close()

func (*ResourceLogFollower) ConsumeLog added in v1.1.0

func (l *ResourceLogFollower) ConsumeLog(logWriter *os.File, stream io.ReadCloser) <-chan struct{}

func (*ResourceLogFollower) IsFollowed added in v1.1.0

func (l *ResourceLogFollower) IsFollowed(path string) bool

type WaitSet

type WaitSet struct {
	WaitGroup  sync.WaitGroup
	ErrChan    chan error
	FinishChan chan bool
	Timeout    time.Duration
}

func NewWaitSet

func NewWaitSet(timeout time.Duration) *WaitSet

Jump to

Keyboard shortcuts

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