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

Sort packages, actions, triggers, rules by name alphabetically. #1729

Closed
wants to merge 1 commit into from

Conversation

lzbj
Copy link
Contributor

@lzbj lzbj commented Jan 17, 2017

Address issue #1569.

@rabbah
Copy link
Member

rabbah commented Jan 17, 2017

I would make this a feature toggled by a flag: sort by date or alphabetelically.

@csantanapr
Copy link
Member

@rabbah 😕 date? I'm not aware that entities like rules, packages, etc.. have a date associated to it.

@rabbah
Copy link
Member

rabbah commented Jan 17, 2017

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).

@csantanapr
Copy link
Member

csantanapr commented Jan 17, 2017

@rabbah ah so your saying that the REST API already support a sort parameter that CLI can pass to it to sort by date or alphabetically?

@csantanapr
Copy link
Member

I tried wsk list and wsk rule get with -v and was not able to see a date property in the return data. I was just trying to understand where is this sorting that your proposing happens client or server side.

@rabbah
Copy link
Member

rabbah commented Jan 17, 2017

No I'm saying records in the database have a date field. It is not visible to you as the end user.

@csantanapr
Copy link
Member

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.

@rabbah
Copy link
Member

rabbah commented Jan 17, 2017

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.

@csantanapr
Copy link
Member

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 sort possible values date or name

My OCD tells me that default when flag not specify should be name
But practical person says date

I'm OK flipping a coin, or if someone has a strong opinion

@rabbah
Copy link
Member

rabbah commented Jan 17, 2017

Thought: sort by name by default and add -t to sort by time (matching ls -t for example).
For activations however should we support sorting lexically? One thought is to sort lexically by the corresponding action/trigger/rule name and within each group sort by time. And the flag -t could then flatten the grouping... Seems confusing though.

@lzbj
Copy link
Contributor Author

lzbj commented Jan 18, 2017

@rabbah ,@csantanapr, I'll try to figure out and and a flag. Thanks for review.

@lzbj lzbj force-pushed the issue#1569 branch 2 times, most recently from a9aa8eb to d10ed7a Compare January 19, 2017 00:55
@rabbah
Copy link
Member

rabbah commented Jan 24, 2017

@lzbj I added wip flag - remove it when ready and apply review label.

@lzbj lzbj added review Review for this PR has been requested and yet needs to be done. and removed wip labels Jan 25, 2017
@rabbah
Copy link
Member

rabbah commented Jan 31, 2017

Looks good. A test should be added. I suggest WskBasicUsageTests class.

@lzbj
Copy link
Contributor Author

lzbj commented Feb 6, 2017

Thanks, I'll add a basic test cases for it. @rabbah ,pls help review, thank you.

@dubee
Copy link
Member

dubee commented Feb 21, 2017

Needs a PG.

@lzbj
Copy link
Contributor Author

lzbj commented Feb 22, 2017

@dubeejw , could you please help run a PG? thank you.

@csantanapr csantanapr assigned csantanapr and unassigned dubee Feb 22, 2017
Copy link
Member

@rabbah rabbah left a 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,
Copy link
Member

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?

Copy link
Contributor Author

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
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, add it.

Copy link
Member

@rabbah rabbah left a 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"))
Copy link
Member

@dubee dubee Feb 22, 2017

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.

Copy link
Contributor Author

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
Copy link
Member

@dubee dubee Feb 22, 2017

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.

Copy link
Contributor Author

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.

@csantanapr csantanapr assigned rabbah and unassigned csantanapr Feb 22, 2017
@csantanapr
Copy link
Member

@rabbah assigning to you since you are already reviewing this PR

@lzbj
Copy link
Contributor Author

lzbj commented Feb 23, 2017

@rabbah @dubeejw @csantanapr ,thank you, I'll try to update accordingly.

@cfjedimaster
Copy link
Contributor

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.

@rabbah
Copy link
Member

rabbah commented Mar 16, 2017

@lzbj are you still working on this? It would be nice to get this in.

@lzbj
Copy link
Contributor Author

lzbj commented Mar 16, 2017

@rabbah , not recently, I'll work on this when available.

@rabbah
Copy link
Member

rabbah commented Apr 10, 2017

@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?

@lzbj
Copy link
Contributor Author

lzbj commented Apr 11, 2017

@rabbah , yes, I'll provide an update.

@@ -285,8 +285,26 @@ func printSummary(collection interface{}) {
}
}

func Len(collection interface{}) func() int {
Copy link
Contributor Author

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.
@lzbj
Copy link
Contributor Author

lzbj commented Apr 11, 2017

@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.

@rabbah
Copy link
Member

rabbah commented Jun 13, 2017

Closing in favor of #2326.

@rabbah rabbah closed this Jun 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli review Review for this PR has been requested and yet needs to be done.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants