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
filter incompatible helm charts from dev catalog #5767
filter incompatible helm charts from dev catalog #5767
Conversation
/assign @rohitkrai03 |
5fb8264
to
18b069a
Compare
/retest |
_.forEach(helmCharts, (obj: HelmChart) => { | ||
if (obj?.kubeVersion && semver.valid(kubernetesVersion)) { | ||
if (semver.satisfies(kubernetesVersion, obj.kubeVersion)) { | ||
arr = [...arr, obj]; |
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.
why not push? Does it fail a shallow compare somewhere?
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.
+1 for add.push here.
And just one addition when you accept this change: Give things more meaningful names, like const filteredCharts
instead of arr and maybe helmChart instead of just obj? :)
arr = [...arr, obj]; | ||
} | ||
} else { | ||
arr = [...arr, obj]; |
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.
can it be clubbed with above arr = [ ...arr, obj ]
statement using ||
?
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.
Use add.push(obj) here as well. I personally like this else case :)
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.
@abhinandan13jan the purpose of adding this in else is if a helm chart doesn't have kubeVersion
then consider it as compatible
setHelmCharts(json.entries); | ||
let kubernetesVersion: string = ''; | ||
await k8sVersion() | ||
.then((response) => { |
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 personally would prefer not to mix async/await with .then/.catch. Could you use a try catch block here instead? What do you think? Because this is personal preference I would also accept this as it is.
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.
added try-catch block
arr = [...arr, obj]; | ||
} | ||
} else { | ||
arr = [...arr, obj]; |
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.
Use add.push(obj) here as well. I personally like this else case :)
_.forEach(helmCharts, (obj: HelmChart) => { | ||
if (obj?.kubeVersion && semver.valid(kubernetesVersion)) { | ||
if (semver.satisfies(kubernetesVersion, obj.kubeVersion)) { | ||
arr = [...arr, obj]; |
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.
+1 for add.push here.
And just one addition when you accept this change: Give things more meaningful names, like const filteredCharts
instead of arr and maybe helmChart instead of just obj? :)
18b069a
to
7e7af31
Compare
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.
/lgtm
/test images |
try { | ||
const response = await k8sVersion(); | ||
kubernetesVersion = getK8sGitVersion(response) || '-'; | ||
} catch { | ||
kubernetesVersion = 'unknown'; | ||
} |
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.
Move this logic outside into a separate effect.
const filteredHelmChartEntries = filterIncompatibleHelmCharts( | ||
json.entries, | ||
kubernetesVersion, | ||
); |
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.
Why do you have the filtering mechanism separately? While normalizing the helm charts we already go through all the helm charts and reduce it into items for catalog. You can re-use that same reduce to do the filtering easily. We also do filtering of chart versions there. Later on we would have so many helm charts that this would come out to be really expensive.
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 would like to have the filtering based on kubeVersion
to be along with this logic - #5699
7e7af31
to
2db07b9
Compare
2db07b9
to
c153f83
Compare
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.
/lgtm
/assign @christianvogt |
setHelmChartEntries(_.get(json, ['entries', chartName])); | ||
setHelmChartVersions(getChartVersions(_.get(json, ['entries', chartName]))); | ||
setHelmChartVersions( | ||
getChartVersions(_.get(json, ['entries', chartName]), kubernetesVersion), | ||
); |
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.
lets change this to use optional chaining
/lgtm cancel |
c153f83
to
e532c33
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: christianvogt, debsmita1, jerolimov, rohitkrai03 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/kind feature |
JIRA Story:
https://issues.redhat.com/browse/ODC-4062
Solution Description:
HelmChart
(Referred the Helm docs: https://helm.sh/docs/topics/charts/ , section :The Chart.yaml File
)