Add short flag -c for --cluster in tsh (#13044)

This commit is contained in:
Gavin Frazar 2022-06-07 16:01:43 -07:00 committed by GitHub
parent 2dad6039a7
commit 0cf23de3b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -508,7 +508,7 @@ func Run(ctx context.Context, args []string, opts ...cliOption) error {
ssh.Flag("dynamic-forward", "Forward localhost connections to remote server using SOCKS5").Short('D').StringsVar(&cf.DynamicForwardedPorts) ssh.Flag("dynamic-forward", "Forward localhost connections to remote server using SOCKS5").Short('D').StringsVar(&cf.DynamicForwardedPorts)
ssh.Flag("local", "Execute command on localhost after connecting to SSH node").Default("false").BoolVar(&cf.LocalExec) ssh.Flag("local", "Execute command on localhost after connecting to SSH node").Default("false").BoolVar(&cf.LocalExec)
ssh.Flag("tty", "Allocate TTY").Short('t').BoolVar(&cf.Interactive) ssh.Flag("tty", "Allocate TTY").Short('t').BoolVar(&cf.Interactive)
ssh.Flag("cluster", clusterHelp).StringVar(&cf.SiteName) ssh.Flag("cluster", clusterHelp).Short('c').StringVar(&cf.SiteName)
ssh.Flag("option", "OpenSSH options in the format used in the configuration file").Short('o').AllowDuplicate().StringsVar(&cf.Options) ssh.Flag("option", "OpenSSH options in the format used in the configuration file").Short('o').AllowDuplicate().StringsVar(&cf.Options)
ssh.Flag("no-remote-exec", "Don't execute remote command, useful for port forwarding").Short('N').BoolVar(&cf.NoRemoteExec) ssh.Flag("no-remote-exec", "Don't execute remote command, useful for port forwarding").Short('N').BoolVar(&cf.NoRemoteExec)
ssh.Flag("x11-untrusted", "Requests untrusted (secure) X11 forwarding for this session").Short('X').BoolVar(&cf.X11ForwardingUntrusted) ssh.Flag("x11-untrusted", "Requests untrusted (secure) X11 forwarding for this session").Short('X').BoolVar(&cf.X11ForwardingUntrusted)
@ -534,7 +534,7 @@ func Run(ctx context.Context, args []string, opts ...cliOption) error {
apps := app.Command("apps", "View and control proxied applications.").Alias("app") apps := app.Command("apps", "View and control proxied applications.").Alias("app")
lsApps := apps.Command("ls", "List available applications.") lsApps := apps.Command("ls", "List available applications.")
lsApps.Flag("verbose", "Show extra application fields.").Short('v').BoolVar(&cf.Verbose) lsApps.Flag("verbose", "Show extra application fields.").Short('v').BoolVar(&cf.Verbose)
lsApps.Flag("cluster", clusterHelp).StringVar(&cf.SiteName) lsApps.Flag("cluster", clusterHelp).Short('c').StringVar(&cf.SiteName)
lsApps.Flag("search", searchHelp).StringVar(&cf.SearchKeywords) lsApps.Flag("search", searchHelp).StringVar(&cf.SearchKeywords)
lsApps.Flag("query", queryHelp).StringVar(&cf.PredicateExpression) lsApps.Flag("query", queryHelp).StringVar(&cf.PredicateExpression)
lsApps.Flag("format", formatFlagDescription(defaultFormats...)).Short('f').Default(teleport.Text).EnumVar(&cf.Format, defaultFormats...) lsApps.Flag("format", formatFlagDescription(defaultFormats...)).Short('f').Default(teleport.Text).EnumVar(&cf.Format, defaultFormats...)
@ -554,7 +554,7 @@ func Run(ctx context.Context, args []string, opts ...cliOption) error {
proxy := app.Command("proxy", "Run local TLS proxy allowing connecting to Teleport in single-port mode") proxy := app.Command("proxy", "Run local TLS proxy allowing connecting to Teleport in single-port mode")
proxySSH := proxy.Command("ssh", "Start local TLS proxy for ssh connections when using Teleport in single-port mode") proxySSH := proxy.Command("ssh", "Start local TLS proxy for ssh connections when using Teleport in single-port mode")
proxySSH.Arg("[user@]host", "Remote hostname and the login to use").Required().StringVar(&cf.UserHost) proxySSH.Arg("[user@]host", "Remote hostname and the login to use").Required().StringVar(&cf.UserHost)
proxySSH.Flag("cluster", clusterHelp).StringVar(&cf.SiteName) proxySSH.Flag("cluster", clusterHelp).Short('c').StringVar(&cf.SiteName)
proxyDB := proxy.Command("db", "Start local TLS proxy for database connections when using Teleport in single-port mode") proxyDB := proxy.Command("db", "Start local TLS proxy for database connections when using Teleport in single-port mode")
proxyDB.Arg("db", "The name of the database to start local proxy for").Required().StringVar(&cf.DatabaseService) proxyDB.Arg("db", "The name of the database to start local proxy for").Required().StringVar(&cf.DatabaseService)
proxyDB.Flag("port", "Specifies the source port used by proxy db listener").Short('p').StringVar(&cf.LocalProxyPort) proxyDB.Flag("port", "Specifies the source port used by proxy db listener").Short('p').StringVar(&cf.LocalProxyPort)
@ -571,7 +571,7 @@ func Run(ctx context.Context, args []string, opts ...cliOption) error {
// Databases. // Databases.
db := app.Command("db", "View and control proxied databases.") db := app.Command("db", "View and control proxied databases.")
db.Flag("cluster", clusterHelp).StringVar(&cf.SiteName) db.Flag("cluster", clusterHelp).Short('c').StringVar(&cf.SiteName)
dbList := db.Command("ls", "List all available databases.") dbList := db.Command("ls", "List all available databases.")
dbList.Flag("verbose", "Show extra database fields.").Short('v').BoolVar(&cf.Verbose) dbList.Flag("verbose", "Show extra database fields.").Short('v').BoolVar(&cf.Verbose)
dbList.Flag("search", searchHelp).StringVar(&cf.SearchKeywords) dbList.Flag("search", searchHelp).StringVar(&cf.SearchKeywords)
@ -602,14 +602,14 @@ func Run(ctx context.Context, args []string, opts ...cliOption) error {
// join // join
join := app.Command("join", "Join the active SSH session") join := app.Command("join", "Join the active SSH session")
join.Flag("cluster", clusterHelp).StringVar(&cf.SiteName) join.Flag("cluster", clusterHelp).Short('c').StringVar(&cf.SiteName)
join.Flag("mode", "Mode of joining the session, valid modes are observer and moderator").Short('m').Default("peer").StringVar(&cf.JoinMode) join.Flag("mode", "Mode of joining the session, valid modes are observer and moderator").Short('m').Default("peer").StringVar(&cf.JoinMode)
join.Flag("reason", "The purpose of the session.").StringVar(&cf.Reason) join.Flag("reason", "The purpose of the session.").StringVar(&cf.Reason)
join.Flag("invite", "A comma separated list of people to mark as invited for the session.").StringsVar(&cf.Invited) join.Flag("invite", "A comma separated list of people to mark as invited for the session.").StringsVar(&cf.Invited)
join.Arg("session-id", "ID of the session to join").Required().StringVar(&cf.SessionID) join.Arg("session-id", "ID of the session to join").Required().StringVar(&cf.SessionID)
// play // play
play := app.Command("play", "Replay the recorded SSH session") play := app.Command("play", "Replay the recorded SSH session")
play.Flag("cluster", clusterHelp).StringVar(&cf.SiteName) play.Flag("cluster", clusterHelp).Short('c').StringVar(&cf.SiteName)
play.Flag("format", formatFlagDescription( play.Flag("format", formatFlagDescription(
teleport.PTY, teleport.JSON, teleport.YAML, teleport.PTY, teleport.JSON, teleport.YAML,
)).Short('f').Default(teleport.PTY).EnumVar(&cf.Format, teleport.PTY, teleport.JSON, teleport.YAML) )).Short('f').Default(teleport.PTY).EnumVar(&cf.Format, teleport.PTY, teleport.JSON, teleport.YAML)
@ -617,7 +617,7 @@ func Run(ctx context.Context, args []string, opts ...cliOption) error {
// scp // scp
scp := app.Command("scp", "Secure file copy") scp := app.Command("scp", "Secure file copy")
scp.Flag("cluster", clusterHelp).StringVar(&cf.SiteName) scp.Flag("cluster", clusterHelp).Short('c').StringVar(&cf.SiteName)
scp.Arg("from, to", "Source and destination to copy").Required().StringsVar(&cf.CopySpec) scp.Arg("from, to", "Source and destination to copy").Required().StringsVar(&cf.CopySpec)
scp.Flag("recursive", "Recursive copy of subdirectories").Short('r').BoolVar(&cf.RecursiveCopy) scp.Flag("recursive", "Recursive copy of subdirectories").Short('r').BoolVar(&cf.RecursiveCopy)
scp.Flag("port", "Port to connect to on the remote host").Short('P').Int32Var(&cf.NodePort) scp.Flag("port", "Port to connect to on the remote host").Short('P').Int32Var(&cf.NodePort)
@ -625,7 +625,7 @@ func Run(ctx context.Context, args []string, opts ...cliOption) error {
scp.Flag("quiet", "Quiet mode").Short('q').BoolVar(&cf.Quiet) scp.Flag("quiet", "Quiet mode").Short('q').BoolVar(&cf.Quiet)
// ls // ls
ls := app.Command("ls", "List remote SSH nodes") ls := app.Command("ls", "List remote SSH nodes")
ls.Flag("cluster", clusterHelp).StringVar(&cf.SiteName) ls.Flag("cluster", clusterHelp).Short('c').StringVar(&cf.SiteName)
ls.Flag("verbose", "One-line output (for text format), including node UUIDs").Short('v').BoolVar(&cf.Verbose) ls.Flag("verbose", "One-line output (for text format), including node UUIDs").Short('v').BoolVar(&cf.Verbose)
ls.Flag("format", formatFlagDescription( ls.Flag("format", formatFlagDescription(
teleport.Text, teleport.JSON, teleport.YAML, teleport.Names, teleport.Text, teleport.JSON, teleport.YAML, teleport.Names,
@ -663,7 +663,7 @@ func Run(ctx context.Context, args []string, opts ...cliOption) error {
// bench // bench
bench := app.Command("bench", "Run shell or execute a command on a remote SSH node").Hidden() bench := app.Command("bench", "Run shell or execute a command on a remote SSH node").Hidden()
bench.Flag("cluster", clusterHelp).StringVar(&cf.SiteName) bench.Flag("cluster", clusterHelp).Short('c').StringVar(&cf.SiteName)
bench.Arg("[user@]host", "Remote hostname and the login to use").Required().StringVar(&cf.UserHost) bench.Arg("[user@]host", "Remote hostname and the login to use").Required().StringVar(&cf.UserHost)
bench.Arg("command", "Command to execute on a remote host").Required().StringsVar(&cf.RemoteCommand) bench.Arg("command", "Command to execute on a remote host").Required().StringsVar(&cf.RemoteCommand)
bench.Flag("port", "SSH port on a remote host").Short('p').Int32Var(&cf.NodePort) bench.Flag("port", "SSH port on a remote host").Short('p').Int32Var(&cf.NodePort)