-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add GetServers parameterized search for Connect grpc #15934
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
Closed
Closed
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
db8361f
changed names of handler and added serverside request handler
avatus ab46825
added separate GetServers grpc for connect
avatus 4bcfdf5
Merge branch 'master' into michaelmyers/connect/add-parameter-search
avatus 7ba931c
addressing reviews
avatus 134c9b4
more changes
avatus b4e1d19
run make grpc-teleterm
avatus c6daeaa
Merge branch 'master' into michaelmyers/connect/add-parameter-search
avatus 92c7f8a
moved clients outside of retry
avatus 08c90dd
Merge branch 'michaelmyers/connect/add-parameter-search' of https://g…
avatus 1a37ac7
Merge branch 'master' into michaelmyers/connect/add-parameter-search
avatus 235e650
move authClient into retyable
avatus 82896b1
abstracted sortby out
avatus 7e34859
Merge branch 'master' into michaelmyers/connect/add-parameter-search
avatus c9b2cd3
Merge branch 'michaelmyers/connect/add-parameter-search' of https://g…
avatus ee3e584
removed unused import
avatus 371d7f0
moved request into right scope
avatus f0574bd
used new sortby method in listResources and added tests
avatus 169345c
Merge branch 'master' into michaelmyers/connect/add-parameter-search
avatus 0c30b98
fixed godocs
avatus 08c0cc6
Merge branch 'master' into michaelmyers/connect/add-parameter-search
avatus d2a2eec
more contextual naming and removing useless comments
avatus 64a8719
Merge branch 'master' into michaelmyers/connect/add-parameter-search
avatus 6f8291d
fix-license
avatus d8ec5eb
Merge branch 'michaelmyers/connect/add-parameter-search' of https://g…
avatus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // Copyright 2022 Gravitational, Inc | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package types | ||
|
|
||
| import ( | ||
| "strings" | ||
| ) | ||
|
|
||
| // GetSortByFromString expects a string in format `<fieldName>:<asc|desc>` where | ||
| // index 0 is fieldName and index 1 is direction. | ||
| // If a direction is not set, or is not recognized, it defaults to ASC. | ||
| func GetSortByFromString(sortStr string) (sortBy SortBy) { | ||
| if sortStr == "" { | ||
| return sortBy | ||
| } | ||
|
|
||
| vals := strings.Split(sortStr, ":") | ||
| if vals[0] != "" { | ||
| sortBy.Field = vals[0] | ||
| if len(vals) > 1 && vals[1] == "desc" { | ||
| sortBy.IsDesc = true | ||
| } | ||
| } | ||
|
|
||
| return sortBy | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| // Copyright 2022 Gravitational, Inc | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package types | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestGetSortByFromString(t *testing.T) { | ||
| t.Parallel() | ||
| tests := []struct { | ||
| in string | ||
| out SortBy | ||
| }{ | ||
| { | ||
| "hostname:asc", | ||
| SortBy{ | ||
| Field: "hostname", | ||
| IsDesc: false, | ||
| }, | ||
| }, | ||
| { | ||
| "", | ||
| SortBy{}, | ||
| }, | ||
| { | ||
| "name:desc", | ||
| SortBy{ | ||
| Field: "name", | ||
| IsDesc: true, | ||
| }, | ||
| }, | ||
| { | ||
| "hostname", | ||
| SortBy{ | ||
| Field: "hostname", | ||
| IsDesc: false, | ||
| }, | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| tt := tt | ||
| t.Run(tt.in, func(t *testing.T) { | ||
|
|
||
| out := GetSortByFromString(tt.in) | ||
| require.Equal(t, tt.out, out) | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
typesthe best package for this? This is a pretty low-level commonly imported package. Maybe there's a better place for it?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was our first best guess at where to put it. I'm open to suggestions, not quite sure which context suites it best.