Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var PassAgentCmd = &cobra.Command{ Use: "pass", Short: "Ask and cache a passphrase in memory", Run: func(cmd *cobra.Command, args []string) { var repoName string targetRepo, err := rr.GetAtWorkingDir(cfg.Node.GitBinPath) if err == nil { repoName = targetRepo.GetName() } pf := pflag.NewFlagSet("", pflag.ContinueOnError) pf.StringP("key", "k", "", "The index or address of the key") pf.StringP("cache", "c", "", "Cache the key for the specified duration (e.g 10s, 2m, 24h)") pf.Bool("start-agent", false, "Start the passphrase agent service") pf.Bool("stop-agent", false, "Stop the passphrase agent service") pf.StringP("port", "p", config.DefaultPassAgentPort, "Set the cache agent listening port") pf.ParseErrorsWhitelist.UnknownFlags = true if err = pf.Parse(args); err != nil { log.Fatal(err.Error()) } args = util.RemoveFlag(args, "key", "k", "cache", "c", "port", "p") key, _ := pf.GetString("key") cacheDurStr, _ := pf.GetString("cache") port, _ := pf.GetString("port") startAgent, _ := pf.GetBool("start-agent") stopAgent, _ := pf.GetBool("stop-agent") if err := PassCmd(&PassArgs{ Args: args, RepoName: repoName, Key: key, CacheDuration: cacheDurStr, Port: port, StartAgent: startAgent, StopAgent: stopAgent, CommandCreator: util.NewCommand, AskPass: AskPass, Stdout: os.Stdout, Stderr: os.Stderr, Stdin: os.Stdin, }); err != nil { if e, ok := err.(*exec.ExitError); ok { os.Exit(e.ExitCode()) } log.Fatal(err.Error()) } }, }
PassAgentCmd represents the PassAgentCmd command
Functions ¶
Types ¶
type PassArgs ¶
type PassArgs struct {
// Args is the program argument
Args []string
// RepoName is the name of the repository
RepoName string
// Key is the unique name for identifying a passphrase
Key string
// CacheDuration is the duration to keep a passphrase in memory.
// If set and agent is not running, the agent is started.
// If unset, the key will not be cached. Instead, the
// key will be set on <APPNAME>_PASS env variable.
CacheDuration string
// Port determines the port where the agent will or is listen on
Port string
// StartAgent indicates that the agent should be started
StartAgent bool
// StopAgent indicates that the agent should be stopped
StopAgent bool
// CommandCreator creates a wrapped exec.Cmd object
CommandCreator util.CommandCreator
// AskPass is a function for reading a passphrase from stdin
AskPass keystore.AskPassOnceFunc
// AgentStarter is a function that starts the pass agent service
AgentStarter agent.RunFunc
// AgentStop is a function that stops the pass agent service
AgentStop agent.StopFunc
// AgentUp is a function that checks if the agent server is running
AgentUp agent.IsUpFunc
// AgentSet is a function for sending set request to the agent service
AgentSet agent.SetFunc
Stdout io.Writer
Stderr io.Writer
Stdin io.Reader
}
PassArgs contains parameters for PassCmd
Click to show internal directories.
Click to hide internal directories.