utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Name is the program name
	Name = "SKM by Toshiki's Devpedia"
	// Usage is for simple description
	Usage = "Manage your multiple SSH keys easily"

	// CheckSymbol is the code for check symbol
	CheckSymbol = "\u2714 "
	// CrossSymbol is the code for check symbol
	CrossSymbol = "\u2716 "

	// PublicKey is the default name of SSH public key
	PublicKey = "id_rsa.pub"
	// PrivateKey is the default name of SSH private key
	PrivateKey = "id_rsa"
	// DefaultKey is the default alias name of SSH key
	DefaultKey = "default"

	// HookName is the name of a hook that is called when present after using a key
	HookName = "hook"
)

Variables

This section is empty.

Functions

func AddCache

func AddCache(alias string, keyMap map[string]*models.SSHKey, env *models.Environment) error

AddCache adds SSH to ssh agent cache via key alias

func ClearKey

func ClearKey(env *models.Environment)

ClearKey clears both private & public keys from SSH key path

func CreateLink(alias string, keyMap map[string]*models.SSHKey, env *models.Environment)

CreateLink creates symbol link for specified SSH key

func DeleteCache

func DeleteCache(alias string, keyMap map[string]*models.SSHKey, env *models.Environment) error

DeleteCache removes SSH key from SSH agent cache via key alias

func DeleteKey

func DeleteKey(alias string, key *models.SSHKey, env *models.Environment, forTest ...bool)

DeleteKey delete key by its alias name

func Execute

func Execute(workDir, script string, args ...string) bool

Execute executes shell commands with arguments

func Fatalf

func Fatalf(format string, args ...interface{})

Fatalf output formatted fatal error info

func GetBakFileName

func GetBakFileName() string

GetBakFileName generates a backup file name by current date and time

func IsEmpty

func IsEmpty(path string) (bool, error)

IsEmpty checks if directory in path is empty

func ListCache

func ListCache() error

ListCache lists cached SSH key from SSH agent cache

func LoadSSHKeys

func LoadSSHKeys(env *models.Environment) map[string]*models.SSHKey

LoadSSHKeys loads all the SSH keys from key store

func MustGetEnvironment

func MustGetEnvironment(ctx *cli.Context) *models.Environment

func ParsePath

func ParsePath(path string) string

ParsePath return the original SSH key path if it is a symbol link

func RunHook

func RunHook(alias string, env *models.Environment)

RunHook runs hook file after switching SSH key

Types

This section is empty.

Jump to

Keyboard shortcuts

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