utils

package
v0.3.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2020 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HomeEnv        = "HOME"
	HomeDriveEnv   = "HOMEDRIVE"
	HomePathEnv    = "HOMEPATH"
	UserProfileEnv = "USERPROFILE"
)
View Source
const BashCompEnvVarFlag = "cobra_annotation_bash_env_var_flag"
View Source
const SSHAuthSock = "SSH_AUTH_SOCK"

Variables

View Source
var (
	ErrKeyGeneration     = errors.New("Unable to generate key")
	ErrValidation        = errors.New("Unable to validate key")
	ErrPublicKey         = errors.New("Unable to convert public key")
	ErrUnableToWriteFile = errors.New("Unable to write file")
)

This file Borrowed from https://github.com/docker/machine/blob/master/libmachine/ssh/keys.go

Functions

func AskForConfirmation

func AskForConfirmation(s string) bool

func AskForSelectItem

func AskForSelectItem(s string, ss map[string]string) string

func ConvertFlags added in v0.3.0

func ConvertFlags(cmd *cobra.Command, fs []types.Flag) *pflag.FlagSet

ConvertFlags change autok3s flags to FlagSet, will mark required annotation if possible.

func EnsureFileExist

func EnsureFileExist(path, file string) error

func EnsureFolderExist

func EnsureFolderExist(path string) error

func GenerateSSHKey added in v0.3.0

func GenerateSSHKey(path string) error

GenerateSSHKey generates SSH keypair based on path of the private key The public key would be generated to the same path with ".pub" added

func GetSSHConfig

func GetSSHConfig(username, sshPrivateKeyString, passphrase, sshCert string, password string, timeout time.Duration, useAgentAuth bool) (*ssh.ClientConfig, error)

func NewSpinner

func NewSpinner(prefix string) *spinner.Spinner

func RandomToken

func RandomToken(size int) (string, error)

func ReadYaml

func ReadYaml(path, name string) (i []interface{}, err error)

func SSHCertificatePath

func SSHCertificatePath(sshCertPath string) (string, error)

func SSHPrivateKeyPath

func SSHPrivateKeyPath(sshKey string) (string, error)

func UniqueArray

func UniqueArray(origin []string) (unique []string)

func UserHome

func UserHome() string

func WaitFor added in v0.3.0

func WaitFor(fn func() (bool, error)) error

func WaitForBackoff added in v0.3.0

func WaitForBackoff(fn func() (bool, error), backoff wait.Backoff) error

func WriteBytesToYaml

func WriteBytesToYaml(b []byte, path, name string) error

func WriteYaml

func WriteYaml(source interface{}, path, name string) error

Types

type KeyPair added in v0.3.0

type KeyPair struct {
	PrivateKey []byte
	PublicKey  []byte
}

func NewKeyPair added in v0.3.0

func NewKeyPair() (keyPair *KeyPair, err error)

NewKeyPair generates a new SSH keypair This will return a private & public key encoded as DER.

func (*KeyPair) Fingerprint added in v0.3.0

func (kp *KeyPair) Fingerprint() string

Fingerprint calculates the fingerprint of the public key

func (*KeyPair) WriteToFile added in v0.3.0

func (kp *KeyPair) WriteToFile(privateKeyPath string, publicKeyPath string) error

WriteToFile writes keypair to files

Jump to

Keyboard shortcuts

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