-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Sort packages, actions, triggers, rules by name alphabetically. #1729
Conversation
I would make this a feature toggled by a flag: sort by date or alphabetelically. |
@rabbah 😕 date? I'm not aware that entities like rules, packages, etc.. have a date associated to it. |
The current order is by date (last updated eg). All entities when stored in the database have a generated date property (it's hidden from the user) if the entity doesn't have an obvious property to use as date (which is the case for activations for example). |
@rabbah ah so your saying that the REST API already support a |
I tried |
No I'm saying records in the database have a date field. It is not visible to you as the end user. |
OK How are you proposing we implement this sorting featured flag? It looks like it can't be done ONLY with CLI changes. Something along the lines to add support in the backend to provide a parameter that get's used to return the sorted list, or return the list with the date information for the client to do the sorting. |
We already have sort by date. This is the current ordering. I'm simply proposing that you choose a default (name vs date) and guard the sort in the cli by such a flag. |
Ah see, make sense now. I think it's being a long day for me 🤣 going home now. @lzbj I assume you understood the propose change, very simple to handle. I propose flag name My OCD tells me that default when flag not specify should be I'm OK flipping a coin, or if someone has a strong opinion |
Thought: sort by name by default and add |
@rabbah ,@csantanapr, I'll try to figure out and and a flag. Thanks for review. |
a9aa8eb
to
d10ed7a
Compare
@lzbj I added |
Looks good. A test should be added. I suggest WskBasicUsageTests class. |
Thanks, I'll add a basic test cases for it. @rabbah ,pls help review, thank you. |
Needs a PG. |
@dubeejw , could you please help run a PG? thank you. |
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.
@dubeejw is all the code duplication really necessary?
does the CLI have some common base types where the comparators can be added?
Would be also nice to inherit common flags.
try { | ||
val namespace = wsk.namespace.list().stdout.trim.split("\n").last | ||
val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath()) | ||
wsk.cli(Seq("property", "set", "-i", "--apihost", wskprops.apihost, "--auth", wskprops.authKey, |
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.
using a config file seems like overkill - this is to avoid adding sort
to the Wsk.list
method?
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.
Correct, I'll remove it.
action.create(name2, file2, annotations = getValidJSONTestArgInput, | ||
parameters = getValidJSONTestArgInput) | ||
} | ||
val stdout = wsk.cli(Seq("list", "-i", "--apihost", wskprops.apihost, "--auth", wskprops.authKey), env = env).stdout |
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.
I think a better approach is to change list
to accept sort
.
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.
ok, add it.
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.
see comments.
@@ -119,8 +119,10 @@ var listCmd = &cobra.Command{ | |||
} | |||
|
|||
func init() { | |||
listCmd.Flags().BoolVarP(&flags.namespace.date, "sort", "t", false, wski18n.T("sort by date")) |
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.
Looks like this flag will work for wsk list
, but not for individual list commands like wsk action list
. Also, I don't think the flag name is very descriptive.
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.
Yes, just to address issue #1569, ok, I'll try to change a better one for your review.
@@ -46,6 +46,20 @@ type TriggerListOptions struct { | |||
Docs bool `url:"docs,omitempty"` | |||
} | |||
|
|||
type TriggerArray []Trigger |
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.
I think you might be able to create functions that expect an generic interface {}
type. Then cast to the appropriate type for Name
comparison. This way there isn't specific sort functions needed for triggers, actions, rules, and packages. See https://golang.org/doc/effective_go.html#type_switch.
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.
Ok, I'll try this approach, my initial though was to let entities like action, trigger implements some interface which is convenient for container manipulates etc, but anyway, if you think it's not necessary, let's change it.
@rabbah assigning to you since you are already reviewing this PR |
@rabbah @dubeejw @csantanapr ,thank you, I'll try to update accordingly. |
As just an FYI - and sorry if I missed this in the thread - but I'd argue for sorting by alpha to be the default. I can see supporting date sorting too as an option, but I'd imagine it being more normal to have an alpha sort. |
@lzbj are you still working on this? It would be nice to get this in. |
@rabbah , not recently, I'll work on this when available. |
@RSulzmann can you take this over? it's fairly close and I think @lzbj isn't actively working on this. David, can you provide an update if you are still working on this? |
@rabbah , yes, I'll provide an update. |
@@ -285,8 +285,26 @@ func printSummary(collection interface{}) { | |||
} | |||
} | |||
|
|||
func Len(collection interface{}) func() int { |
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.
@dubeejw , is your comments means this kind of function? I thought perhaps the action array should implement the sort interfaces, right?
By default will sort by entity name alphabetically. Address issue apache#1569 for enhancement request.
@rabbah , I just added a simple function to discuss with dubeejw about his comments, anyhow, feel free to reassign other people if this high priority. |
Closing in favor of #2326. |
Address issue #1569.