base

package
v0.0.0-...-77b1a84 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultBaseConfigDir string
	DefaultCacheDir      string
	DefaultCertDir       string
	DefaultHistoryPath   string

	LocalKubeConfigPath = "~/.kube/config"

	ErrFailedCreateCacheDir = errors.New("failed to create cache dir")
	ErrFailedCreateCertDir  = errors.New("failed to create cert dir")
	ErrFailedCreateHistory  = errors.New("failed to create history file")
)

Functions

func ExtractHost

func ExtractHost(remoteAddr string) string

ExtractHost extracts host info from remoteAddr which is in the format `user@host`

func FileExists

func FileExists(filename string) (exist, isDir bool)

FileExists checks if a file exists refer, https://golangcode.com/check-if-a-file-exists/

func GenLocalCertAuthPath

func GenLocalCertAuthPath(remoteAddr string) string

GenLocalCertAuthPath creates local path for remote cert-auth file

func GenLocalCertClientKeyPath

func GenLocalCertClientKeyPath(remoteAddr string) string

GenLocalCertClientKeyPath creates local path for remote client-key file

func GenLocalCertClientPath

func GenLocalCertClientPath(remoteAddr string) string

GenLocalCertClientPath creates local path for remote client-cert file

func GetHost

func GetHost(srvAddr string) string

GetHost returns Host part of address, Host or Host:port if port given.

func GetHostAndPort

func GetHostAndPort(addr string) (string, string)

func GetHostname

func GetHostname(addr string) string

TODO: add tests GetHostname returns host, stripping any valid port number if present.

func GetLocalKubePath

func GetLocalKubePath() string

GetLocalKubePath returns local kubeconfig absolute path.

func GetPort

func GetPort(srvAddr string) (port int, notFound bool)

GetPort returns port part of address.

func IsAvailable

func IsAvailable(port int) bool

IsAvailable tests whether given port is available on localhost.

func SshHost

func SshHost(user, ip string) string

SshHost returns host used for ssh/scp connection

Types

This section is empty.

Jump to

Keyboard shortcuts

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