Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Remove extra hints from tsh app proxies. #45159

Merged
merged 1 commit into from
Aug 6, 2024
Merged

Conversation

greedy52
Copy link
Contributor

@greedy52 greedy52 commented Aug 6, 2024

changelog: Fixed an issue tsh aws may display extra text in addition to the original command output

Before:

$ tsh aws sts get-caller-identity
Proxying connections to aws-dev-config on 127.0.0.1:65277
To avoid port randomization, you can choose the listening port using the --port flag.
{
    "UserId": "AROAUBXDPZESRBDQYNUP5:STeve",
    "Account": "278576220453",
    "Arn": "arn:aws:sts::278576220453:assumed-role/steve-poweruser/STeve"
}

$ tsh proxy aws
Proxying connections to aws-dev-config on 127.0.0.1:65153
To avoid port randomization, you can choose the listening port using the --port flag.
Started AWS proxy on http://127.0.0.1:65154.
To avoid port randomization, you can choose the listening port using the --port flag.

Note that the first one breaks jq parsing. Second one is confusing because we showed both 65153 and 65154.

After:

$ tsh aws sts get-caller-identity
{
    "UserId": "AROAUBXDPZESRBDQYNUP5:STeve",
    "Account": "278576220453",
    "Arn": "arn:aws:sts::278576220453:assumed-role/steve-poweruser/STeve"
}

$ tsh proxy aws
Started AWS proxy on http://127.0.0.1:65190.
To avoid port randomization, you can choose the listening port using the --port flag.

$ tsh proxy app redis-tcp
Proxying connections to redis-tcp on 127.0.0.1:65217
To avoid port randomization, you can choose the listening port using the --port flag.

Couldn't find a good/easy way to unit test this. Any suggestion is welcome.

@greedy52 greedy52 requested review from Joerger and smallinsky August 6, 2024 17:57
@greedy52 greedy52 marked this pull request as ready for review August 6, 2024 17:57
@greedy52 greedy52 self-assigned this Aug 6, 2024
@github-actions github-actions bot added size/sm tsh tsh - Teleport's command line tool for logging into nodes running Teleport. labels Aug 6, 2024
Comment on lines +400 to +403
fmt.Printf("Proxying connections to %s on %v\n", cf.AppName, proxyApp.GetAddr())
if cf.LocalProxyPort == "" {
fmt.Println("To avoid port randomization, you can choose the listening port using the --port flag.")
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were removed so just adding them back.

@greedy52 greedy52 added this pull request to the merge queue Aug 6, 2024
Merged via the queue into master with commit 39b2d0f Aug 6, 2024
43 checks passed
@greedy52 greedy52 deleted the STeve/fix_tsh_aws branch August 6, 2024 19:55
@public-teleport-github-review-bot

@greedy52 See the table below for backport results.

Branch Result
branch/v16 Create PR

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
backport/branch/v16 size/sm tsh tsh - Teleport's command line tool for logging into nodes running Teleport.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants