Skip to content

Commit

Permalink
fix: check artifacthub version undefined before comparing
Browse files Browse the repository at this point in the history
Signed-off-by: Jakob Steiner <jakob.steiner@glasskube.eu>
  • Loading branch information
kosmoz committed May 24, 2024
1 parent c6989dc commit 6c55321
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/commands/package/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,21 @@ export default class Package extends Command {
const latestChartVersion = new SemVer(latestChart.version!);
if (latestChartVersion.compare(currentChartVersion) > 0) {
this.log(`new release on Artifact Hub: ${latestChartVersion} (old: ${currentChartVersion.format()})`);
// download the current chart and determine whether this package uses the chart version or app version for
// the package version.
// Versions from artifacthub are null-checked first, because SemVer.compare(undefined) returns 0 (equal)!
const currentChart = await getArtifactPackageVersion(referenceUrl, currentChartVersion.format());
if (currentAppVersion.compare(currentChart.version!) === 0) {
if (currentChart.version && currentAppVersion.compare(currentChart.version) === 0) {
this.log(`using chart version as package version for ${flags.name}: ${latestChartVersion}`);
newAppVersion = latestChartVersion;
newPackageManifestAvailable = true;
} else if (currentAppVersion.compare(currentChart.appVersion!) === 0) {
} else if (
currentChart.appVersion &&
latestChart.appVersion &&
currentAppVersion.compare(currentChart.appVersion) === 0
) {
this.log(`using app version as package version for ${flags.name}: ${latestChart.appVersion}`);
newAppVersion = new SemVer(latestChart.appVersion!);
newAppVersion = new SemVer(latestChart.appVersion);
newPackageManifestAvailable = true;
} else {
this.warn(`can not determine version to use for ${flags.name}`);
Expand Down

0 comments on commit 6c55321

Please sign in to comment.