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

filter incompatible helm charts from dev catalog #5767

Merged
merged 1 commit into from Jun 22, 2020

Conversation

debsmita1
Copy link
Contributor

@debsmita1 debsmita1 commented Jun 17, 2020

JIRA Story:
https://issues.redhat.com/browse/ODC-4062

Solution Description:

  • filters the helm charts in the dev-catalog that are incompatible with the Kubernetes Version
  • filters helm chart versions in the Chart Version dropdown that are incompatible with the Kubernetes Version
  • Fixed the type of HelmChart (Referred the Helm docs: https://helm.sh/docs/topics/charts/ , section : The Chart.yaml File )
  • Added tests
    test

@openshift-ci-robot openshift-ci-robot added the component/core Related to console core functionality label Jun 17, 2020
@debsmita1
Copy link
Contributor Author

/assign @rohitkrai03

@debsmita1 debsmita1 changed the title filter incompatible helm charts from dev catalog [WIP] filter incompatible helm charts from dev catalog Jun 17, 2020
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 17, 2020
@debsmita1 debsmita1 changed the title [WIP] filter incompatible helm charts from dev catalog filter incompatible helm charts from dev catalog Jun 18, 2020
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 18, 2020
@abhi-kn
Copy link
Contributor

abhi-kn commented Jun 18, 2020

/retest

_.forEach(helmCharts, (obj: HelmChart) => {
if (obj?.kubeVersion && semver.valid(kubernetesVersion)) {
if (semver.satisfies(kubernetesVersion, obj.kubeVersion)) {
arr = [...arr, obj];
Copy link
Contributor

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?

Copy link
Member

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];
Copy link
Contributor

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

Copy link
Member

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

Copy link
Contributor Author

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) => {
Copy link
Member

@jerolimov jerolimov Jun 18, 2020

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.

Copy link
Contributor Author

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

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

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? :)

Copy link
Member

@jerolimov jerolimov left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 18, 2020
@debsmita1
Copy link
Contributor Author

/test images

Comment on lines 441 to 446
try {
const response = await k8sVersion();
kubernetesVersion = getK8sGitVersion(response) || '-';
} catch {
kubernetesVersion = 'unknown';
}
Copy link
Contributor

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.

Comment on lines 447 to 450
const filteredHelmChartEntries = filterIncompatibleHelmCharts(
json.entries,
kubernetesVersion,
);
Copy link
Contributor

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.

Copy link
Contributor

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

@openshift-ci-robot openshift-ci-robot added component/dev-console Related to dev-console and removed lgtm Indicates that a PR is ready to be merged. labels Jun 19, 2020
Copy link
Contributor

@rohitkrai03 rohitkrai03 left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 19, 2020
@debsmita1
Copy link
Contributor Author

/assign @christianvogt

Comment on lines 90 to 93
setHelmChartEntries(_.get(json, ['entries', chartName]));
setHelmChartVersions(getChartVersions(_.get(json, ['entries', chartName])));
setHelmChartVersions(
getChartVersions(_.get(json, ['entries', chartName]), kubernetesVersion),
);
Copy link
Contributor

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

@christianvogt
Copy link
Contributor

/lgtm cancel

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Jun 22, 2020
@christianvogt
Copy link
Contributor

/lgtm
/approve

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 22, 2020
@openshift-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 22, 2020
@openshift-merge-robot openshift-merge-robot merged commit 55c7ea0 into openshift:master Jun 22, 2020
@spadgett spadgett added this to the v4.6 milestone Jun 24, 2020
@debsmita1
Copy link
Contributor Author

/kind feature

@openshift-ci-robot openshift-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality component/dev-console Related to dev-console kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants