Documentation ¶
Index ¶
- Constants
- Variables
- func AskForConfirmation(s string, def bool) (rtn bool)
- func AskForConfirmationWithError(s string, def bool) (rtn bool, err error)
- func AskForSelectItem(s string, ss map[string]string) string
- func CommandExitWithoutHelpInfo(f func(cmd *cobra.Command, args []string) error) func(cmd *cobra.Command, args []string)
- func ConvertFlags(cmd *cobra.Command, fs []types.Flag) *pflag.FlagSet
- func ConvertToFields(obj interface{}) (map[string]schemas.Field, error)
- func EnsureFileExist(file string) error
- func EnsureFolderExist(path string) error
- func GenerateRand() int
- func GenerateSSHKey(path string) error
- func GetFileContent(path string) ([]byte, error)
- func GetSSHConfig(username, sshPrivateKeyString, passphrase, sshCert string, password string, ...) (*ssh.ClientConfig, error)
- func IsFileExists(file string) bool
- func IsTerm() bool
- func MergeConfig(source, target reflect.Value)
- func RandomToken(size int) (string, error)
- func RegistryToString(registry *registries.Registry) (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 StripUserHome(path string) string
- func UniqueArray(origin []string) (unique []string)
- func UserHome() string
- func ValidateRequiredFlags(flags *pflag.FlagSet)
- func VerifyRegistryFileContent(path, content string) (*registries.Registry, error)
- func WaitFor(fn func() (bool, error)) error
- type FirstErrGroup
- 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 AskForConfirmationWithError ¶ added in v0.7.0
func AskForSelectItem ¶
AskForSelectItem ask for select item from the given map key.
func CommandExitWithoutHelpInfo ¶ added in v0.7.0
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 EnsureFolderExist ¶
EnsureFolderExist ensures folder exist.
func GenerateRand ¶ added in v0.5.1
func GenerateRand() int
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 GetFileContent ¶ added in v0.7.0
func GetSSHConfig ¶
func GetSSHConfig(username, sshPrivateKeyString, passphrase, sshCert string, password string, timeout time.Duration, useAgentAuth bool) (*ssh.ClientConfig, error)
GetSSHConfig generate ssh config.
func IsFileExists ¶ added in v0.7.0
func MergeConfig ¶ added in v0.4.0
MergeConfig merge config.
func RegistryToString ¶ added in v0.8.0
func RegistryToString(registry *registries.Registry) (string, error)
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 StripUserHome ¶ added in v0.7.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
func VerifyRegistryFileContent ¶ added in v0.8.0
func VerifyRegistryFileContent(path, content string) (*registries.Registry, error)
Types ¶
type FirstErrGroup ¶ added in v0.6.0
type FirstErrGroup struct {
// contains filtered or unexported fields
}
func NewFirstErrorGroup ¶ added in v0.6.0
func NewFirstErrorGroup() *FirstErrGroup
func (*FirstErrGroup) FirstError ¶ added in v0.6.0
func (g *FirstErrGroup) FirstError() <-chan error
func (*FirstErrGroup) Go ¶ added in v0.6.0
func (g *FirstErrGroup) Go(f func() error)
func (*FirstErrGroup) Wait ¶ added in v0.6.0
func (g *FirstErrGroup) Wait() int32
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.