Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[v9.1 backport] Updates tsh ls for node/app/db/kube to accept new filter flags #11016

Merged
merged 5 commits into from
Mar 18, 2022

Conversation

kimlisa
Copy link
Contributor

@kimlisa kimlisa commented Mar 10, 2022

Backport #10980 to branch/v9

Before Merge

  • merge after v9 release? (needs to be part of v9.1 release)

@kimlisa kimlisa changed the title [v9.1 backport] Updates tsh ls for node/app/db/kube to accept new filter flags (#10… [v9.1 backport] Updates tsh ls for node/app/db/kube to accept new filter flags Mar 10, 2022
@github-actions github-actions bot added kubernetes-access tsh tsh - Teleport's command line tool for logging into nodes running Teleport. labels Mar 10, 2022
Copy link
Contributor

@espadolini espadolini left a comment

Choose a reason for hiding this comment

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

Is there another PR for the docs for this (and the corresponding tctl changes)?

@kimlisa
Copy link
Contributor Author

kimlisa commented Mar 10, 2022

@espadolini this is the docs PR: #11012

api/client/client.go Show resolved Hide resolved
return proxyClient.GetDatabaseServers(ctx, tc.Namespace)

filter := customFilter
if customFilter == nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if customFilter == nil {
if filter == nil {

The end result is equivalent, but you're trying to set filter if not already set, so I think this check is easier to reason about.

func TestParseSearchKeywords(t *testing.T) {
t.Parallel()

expected := [][]string{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you make expected a field of the testCases anonymous struct?

When writing a new test it's nice to see the input and expected output together, rather than updating them in two separate places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry zac, i wasn't sure what you meant by updating them in two places? the expected values should not change? i put it out b/c they are the same expects for each tests that test with similar inputs but with different delimiters.

This is what it looks like if something does not match (which looks easy to understand, to me at least):
image

maybe my test is confusing? should i create individual tests for each delimiter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i separated the test to make it easier to understand: 1adccd8

for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would remove the parallel here, and then there's no need for the tc := tc line.

These tests will be super fast (they're pure computation, no network calls or anything that can block), so no need to further parallelize them.


resources, err := client.GetResourcesWithFilters(ctx, site, req)
if err != nil {
// ListResources for nodes not availalbe, provide fallback.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// ListResources for nodes not availalbe, provide fallback.
// ListResources for nodes not available, provide fallback.

@@ -663,13 +717,32 @@ func (proxy *ProxyClient) DeleteAppSession(ctx context.Context, sessionID string
return nil
}

// GetDatabaseServers returns all registered database proxy servers.
func (proxy *ProxyClient) GetDatabaseServers(ctx context.Context, namespace string) ([]types.DatabaseServer, error) {
// FindDatabaseServersByFilters returns all registered database proxy servers.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// FindDatabaseServersByFilters returns all registered database proxy servers.
// FindDatabaseServersByFilters returns registered database proxy servers that match the provided filter.

Technically it doesn't return all database servers.

lib/client/api.go Outdated Show resolved Hide resolved
lib/client/api.go Outdated Show resolved Hide resolved
lib/client/api.go Outdated Show resolved Hide resolved
kimlisa added 2 commits March 14, 2022 11:41
)

* Also adds a search keyword parser that takes in different
  delimiters (comma is used for tsh, space is used for web UI)

part of RFD 55
@kimlisa kimlisa force-pushed the lisa/v9/backport-tsh-ls-update branch from bf8095d to d63e507 Compare March 14, 2022 19:32
@kimlisa kimlisa requested a review from zmb3 March 16, 2022 19:29
@kimlisa kimlisa enabled auto-merge (squash) March 18, 2022 15:43
@kimlisa kimlisa merged commit 7499530 into branch/v9 Mar 18, 2022
@kimlisa kimlisa deleted the lisa/v9/backport-tsh-ls-update branch March 18, 2022 16:28
@webvictim webvictim mentioned this pull request Apr 19, 2022
kimlisa added a commit that referenced this pull request Apr 20, 2022
Addressing minor code reviews received on a backport
(mostly grammer fixes and updating a test)
kimlisa added a commit that referenced this pull request Apr 20, 2022
Addressing minor code reviews received on a backport
@webvictim webvictim mentioned this pull request Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kubernetes-access 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.

5 participants