Skip to content

Commit

Permalink
[v14] fix tsh logout flags (#47461)
Browse files Browse the repository at this point in the history
* fix tsh logout flags

* reword logout error message
  • Loading branch information
GavinFrazar authored Oct 10, 2024
1 parent 2d85fa5 commit 3b2f289
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions tool/tsh/common/tsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -1361,9 +1361,6 @@ func Run(ctx context.Context, args []string, opts ...CliOption) error {
case login.FullCommand():
err = onLogin(&cf)
case logout.FullCommand():
if err := refuseArgs(logout.FullCommand(), args); err != nil {
return trace.Wrap(err)
}
err = onLogout(&cf)
case show.FullCommand():
err = onShow(&cf)
Expand Down Expand Up @@ -2211,9 +2208,10 @@ func onLogout(cf *CLIConf) error {
}

fmt.Printf("Logged out all users from all proxies.\n")
default:
fmt.Printf("Specify --proxy and --user to remove keys for specific user ")
fmt.Printf("from a proxy or neither to log out all users from all proxies.\n")
case proxyHost != "" && cf.Username == "":
fmt.Printf("Specify --user to log out a specific user from %q or remove the --proxy flag to log out all users from all proxies.\n", proxyHost)
case proxyHost == "" && cf.Username != "":
fmt.Printf("Specify --proxy to log out user %q from a specific proxy or remove the --user flag to log out all users from all proxies.\n", cf.Username)
}
return nil
}
Expand Down Expand Up @@ -4257,19 +4255,6 @@ func parseCertificateCompatibilityFlag(compatibility string, certificateFormat s
}
}

// refuseArgs helper makes sure that 'args' (list of CLI arguments)
// does not contain anything other than command
func refuseArgs(command string, args []string) error {
for _, arg := range args {
if arg == command || strings.HasPrefix(arg, "-") {
continue
} else {
return trace.BadParameter("unexpected argument: %s", arg)
}
}
return nil
}

// flattenIdentity reads an identity file and flattens it into a tsh profile on disk.
func flattenIdentity(cf *CLIConf) error {
// Save the identity file path for later
Expand Down

0 comments on commit 3b2f289

Please sign in to comment.