Conversation
sami-alajrami
left a comment
There was a problem hiding this comment.
there are some flag duplication and some inconsistencies with how other list commands (e.g. list artifacts) commands work.
I get it about backward compatibility for returning all trails on the API, although not sure if we need it on the CLI. You can keep the backward compatability but reuse the addListFlags func after adding a param for a custom default.
you can modify that func like this:
func addListFlags(cmd *cobra.Command, o *listOptions, customPageLimit ...int) {
cmd.Flags().StringVarP(&o.output, "output", "o", "table", outputFlag)
cmd.Flags().IntVar(&o.pageNumber, "page", 1, pageNumberFlag)
// Use customPageLimit if provided, otherwise default to 15
pageLimit := 15
if len(customPageLimit) > 0 {
pageLimit = customPageLimit[0]
}
cmd.Flags().IntVarP(&o.pageLimit, "page-limit", "n", pageLimit, pageLimitFlag)
}
cmd/kosli/listTrails.go
Outdated
|
|
||
| // For backward compatibility, we need to return all of the results if no pagination | ||
| // flags are provided - i.e. by not passing a pageLimit parameter to the API. | ||
| if o.pageLimit != 0 { |
There was a problem hiding this comment.
is this if needed? what happens if we send per_page=0 to the API? and how are we maintaining backward compatibility there?
There was a problem hiding this comment.
It looks like if we send per_page=0 then the API returns all results, so we could get away without this. I'm just not sure why it returns all the results, so it makes me uncomfortable :P
In the API, if no parameter is provided for per_page (which is not defaulted) then it behaves the same as it does now, which should ensure the backwards compatibility.
With the modified function above - I'm not sure that will work, because we need there to be no default for the pageLimit for list trails (or a default of 0 if none is provided with the flag). Your function defaults to 15 if none is provided, which won't work.
There was a problem hiding this comment.
With the modified function above - I'm not sure that will work, because we need there to be no default for the pageLimit for list trails (or a default of 0 if none is provided with the flag). Your function defaults to 15 if none is provided, which won't work.
yes, the modified version of the function above adds the optional arg customPageLimit which you can set to 0 without modifying other calls of that function.
No description provided.