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

Update getPaginatedChartList to use namespace. #1562

Merged
merged 6 commits into from
Mar 16, 2020

Conversation

absoludity
Copy link
Contributor

This PR cannot land without the related change to the handlers nor updating the frontend to always send the namespace (following PR).

Updates getPaginatedChartList to expect namespace with a value or "_all" and filter accordingly. Adds actual tests for postgres, but not mongodb.

Ref #1521

@absoludity absoludity requested a review from andresmgot March 6, 2020 06:31
Copy link
Contributor

@andresmgot andresmgot left a comment

Choose a reason for hiding this comment

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

It's a pity we are maintaining the getPaginated method and we are not using it from the UI...

@@ -131,9 +131,10 @@ func listCharts(w http.ResponseWriter, req *http.Request) {
}

// listRepoCharts returns a list of charts in the given repo
// TODO: mnelson: check with Andres why we need a separate function above when `params["repo"]` should be "" by default
Copy link
Contributor

Choose a reason for hiding this comment

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

we don't need it now since both functions now require "params". Before they were different functions to make it clear that listCharts didn't require any param.

apiv1.Methods("GET").Path("/assets/{repo}/{chartName}/versions/{version}/README.md").Handler(WithParams(getChartVersionReadme))
apiv1.Methods("GET").Path("/assets/{repo}/{chartName}/versions/{version}/values.yaml").Handler(WithParams(getChartVersionValues))
apiv1.Methods("GET").Path("/assets/{repo}/{chartName}/versions/{version}/values.schema.json").Handler(WithParams(getChartVersionSchema))
// TODO: Check if we actually need multiple handlers here or can just use one path per endpoint.
Copy link
Contributor

Choose a reason for hiding this comment

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

I see changes in all these lines but I am actually not seeing any change 🤔 I guess you are just changing the call to listCharts to add WithParams but I am not sure.

BTW potentially answering your TODO, it's necessary to repeat the Handler every time there is a new Query param

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 see changes in all these lines but I am actually not seeing any change thinking I guess you are just changing the call to listCharts to add WithParams but I am not sure.

The new versions are prefixed with /ns/{namespace} in the paths.

BTW potentially answering your TODO, it's necessary to repeat the Handler every time there is a new Query param

Why is that? I mean, if we have one path here which defines all possible query params, and one handler which handles that (including if those params are empty)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Why is that? I mean, if we have one path here which defines all possible query params, and one handler which handles that (including if those params are empty)?

The matches were tricky. I am not sure if a request will match if there is a query parameter missing. In any case, I think that defining the query params in the path is not required so if you only have one backend function you can just try to read those params in the function.

if repo != "" {
pipeline = append(pipeline, bson.M{"$match": bson.M{"repo.name": repo}})
matcher["repo.name"] = repo
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, I see you are removing the "$match": ... I guess it's fine if this means that the match should be exact

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, that was a mistake. I meant to include it in the created pipeline. Updated, thanks.

@absoludity absoludity force-pushed the 1521-send-namespace-assetsvc branch from e1e735d to 2beffbe Compare March 9, 2020 01:29
absoludity and others added 4 commits March 10, 2020 14:10
* Update GetChart to inlude namespace

* Add namespace to getChartVersion

* Add filtered queries

* Remove TODO comment

* Remove searchCharts handler and functionality as it appears not to be used in the frontend at all.
@absoludity absoludity force-pushed the 1521-send-namespace-assetsvc branch from 2acd502 to fab345a Compare March 10, 2020 03:10
@andresmgot
Copy link
Contributor

Let me know if you need me to re-review this

@absoludity
Copy link
Contributor Author

Let me know if you need me to re-review this

Thanks, no, I'm just merging the other branches that you approve into this one which I'll then land.

* Update assetsvc URIs to be namespaced.

* Delete unused function.

* Update listWithFilters to include namespace

* Return namespaced self-links in responses. (#1574)
* Update assetsvc chart test for namespaced URIs

* Remove unnecessary handler (#1581)

* Disable helm tests unless testing latest release.
@absoludity absoludity merged commit be439bd into master Mar 16, 2020
@absoludity absoludity deleted the 1521-send-namespace-assetsvc branch March 16, 2020 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants