Documentation ¶
Index ¶
- Constants
- Variables
- func AskForConfirmation(s string) bool
- func AskForSelectItem(s string, ss map[string]string) string
- func ConvertFlags(cmd *cobra.Command, fs []types.Flag) *pflag.FlagSet
- func ConvertToFields(obj interface{}) (map[string]schemas.Field, error)
- func EnsureFileExist(path, file string) error
- func EnsureFolderExist(path string) error
- func GenerateSSHKey(path string) error
- func GetSSHConfig(username, sshPrivateKeyString, passphrase, sshCert string, password string, ...) (*ssh.ClientConfig, error)
- func MergeConfig(source, target reflect.Value)
- func RandomToken(size int) (string, error)
- func RemoveSSHKey(path string) error
- func SSHCertificatePath(sshCertPath string) (string, error)
- func SSHPrivateKeyPath(sshKey string) (string, error)
- func StringSupportBase64(value string) string
- func UniqueArray(origin []string) (unique []string)
- func UserHome() string
- func ValidateRequiredFlags(flags *pflag.FlagSet)
- func WaitFor(fn func() (bool, error)) error
- type KeyPair
Constants ¶
const BashCompEnvVarFlag = "cobra_annotation_bash_env_var_flag"
BashCompEnvVarFlag cobra flag's annotation used for bind env to flag.
Variables ¶
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 ¶
AskForConfirmation ask for confirmation form os.Stdin.
func AskForSelectItem ¶
AskForSelectItem ask for select item from the given map key.
func ConvertFlags ¶ added in v0.3.0
ConvertFlags change autok3s flags to FlagSet, will mark required annotation if possible.
func ConvertToFields ¶ added in v0.4.0
ConvertToFields convert interface to schemas' field.
func EnsureFileExist ¶
EnsureFileExist ensures file exist.
func EnsureFolderExist ¶
EnsureFolderExist ensures folder exist.
func GenerateSSHKey ¶ added in v0.3.0
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)
GetSSHConfig generate ssh config.
func MergeConfig ¶ added in v0.4.0
MergeConfig merge config.
func RemoveSSHKey ¶ added in v0.4.1
RemoveSSHKey delete SSH keypair based on path.
func SSHCertificatePath ¶
SSHCertificatePath returns ssh certificate key content from given path
func SSHPrivateKeyPath ¶
SSHPrivateKeyPath returns ssh private key content from given path.
func StringSupportBase64 ¶ added in v0.5.0
func UniqueArray ¶
UniqueArray returns unique array.
func ValidateRequiredFlags ¶ added in v0.4.0
ValidateRequiredFlags set `flag.Change` if the required flag has default value but not changed by flags.Set to pass the required check https://github.com/spf13/cobra/blob/v1.1.1/command.go#L1001
Types ¶
type KeyPair ¶ added in v0.3.0
KeyPair struct for private/public key.
func NewKeyPair ¶ added in v0.3.0
NewKeyPair generates a new SSH keypair This will return a private & public key encoded as DER.
func (*KeyPair) Fingerprint ¶ added in v0.3.0
Fingerprint calculates the fingerprint of the public key.