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

Allow to sync and store charts with spaces in name (#3758) #3863

Merged
merged 2 commits into from
Dec 1, 2021

Conversation

castelblanque
Copy link
Collaborator

Signed-off-by: Rafa Castelblanque rcastelblanq@vmware.com

Description of the change

This PR allows to sync and store in DB charts that contain spaces in name. End user will then be allowed to reach to the package details page, and when deploying, the error thrown by Helm will be shown.
Applied only to Helm repos, not to OCI.

Benefits

Kubeapps is transparent with regards to charts containing spaces in name. Those charts are synced and stored properly, and end user can navigate to package details now. However Helm installation will still fail due to its restrictions. See here

Possible drawbacks

Packages that can not be installed are listed.
This fix applies only to spaces in name: should we do the same exercise for other special characters? Helm only allows alphanumeric, dash, dot and underscore.

Applicable issues

Additional information

Signed-off-by: Rafa Castelblanque <rcastelblanq@vmware.com>
Copy link
Contributor

@antgamdia antgamdia left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for this fix!

However, I wonder what would happen if the chart also contains encoded / (%2F) as part of the name.
Have you also checked if a chart whose id is, for instance, my-repo/bitnami/cool wordpress is also stored properly? I guess so, because (from memory I recall) we were handling the %2F when retrieving data from the database, but not sure atm.

Have a look also at: https://github.com/kubeapps/kubeapps/blob/master/cmd/assetsvc/pkg/utils/postgresql_utils.go

btw, I don't know why Go doesn't have a "safe" version of url.PathUnescape(value), it is always so verbose...

@castelblanque
Copy link
Collaborator Author

castelblanque commented Nov 30, 2021

That scenario is not tested, but I didn't want to mix things up, due to the issue referencing spaces only.
That is why I raise the question in "Possible drawbacks" section above: the number of special characters that may appear in a chart name is unknown (e.g. {, &, etc.). We only know what Helm allows.
Probably this needs further discussion.

Copy link
Contributor

@absoludity absoludity left a comment

Choose a reason for hiding this comment

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

Excellent :)

cmd/asset-syncer/server/utils_test.go Outdated Show resolved Hide resolved
Signed-off-by: Rafa Castelblanque <rcastelblanq@vmware.com>
@castelblanque castelblanque merged commit 3f8e755 into master Dec 1, 2021
@castelblanque castelblanque deleted the 3758-chart-name-with-spaces branch December 1, 2021 09:59
absoludity added a commit that referenced this pull request Feb 8, 2023
Signed-off-by: Michael Nelson <minelson@vmware.com>

<!--
Before you open the request please review the following guidelines and
tips to help it be more easily integrated:

 - Describe the scope of your change - i.e. what the change does.
 - Describe any known limitations with your change.
- Please run any tests or examples that can exercise your modified code.

 Thank you for contributing!
 -->

### Description of the change

<!-- Describe the scope of your change - i.e. what the change does. -->

In #3863 a change was made to ensure that we unescape spaces in the
chart name before syncing data to the database, which unintentionally
stopped Kubeapps from being able to retrieve charts that include a slash
`/` in the chart name (as is the case when using a unified repository
with Harbor). It was [noted on the PR as a
possibility](#3863 (review)),
but at the time, we didn't have non-OCI helm chart names with slashes
that we were aware of, so we didn't follow it up.

### Benefits

<!-- What benefits will be realized by the code change? -->
A unified Harbor Helm repo can be used with Kubeapps.

### Possible drawbacks

<!-- Describe any known limitations with your change -->
Haven't checked if the chart will display with the escaped slash or not,
but still better to be able to display it rather than error.

### Applicable issues

<!-- Enter any applicable Issues here (You can reference an issue using
#) -->

- fixes #5897 

### Additional information

<!-- If there's anything else that's important and relevant to your pull
request, mention that information here.-->

Signed-off-by: Michael Nelson <minelson@vmware.com>
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.

Problems with charts with spaces in their name
3 participants