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

Fix upgrade not showing when an RC is deployed #513

Merged
merged 8 commits into from
Oct 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Version } from './helm-release-helper.service';

describe('HelmReleaseHelperService', () => {

describe('Version', () => {

const v10 = new Version('1.0.0');
const v11 = new Version('1.1.0');
const v11rc1 = new Version('1.0.0-rc.1');
const v11rc2 = new Version('1.0.0-rc.2');
const v201 = new Version('2.0.1');
const v101 = new Version('1.0.1');

it('version comparisons', () => {
expect(v11.isNewer(v10)).toBe(true);
expect(v11rc1.isNewer(v11)).toBe(false);
expect(v11rc2.isNewer(v11rc1)).toBe(true);
expect(v201.isNewer(v11)).toBe(true);
expect(v201.isNewer(v11rc1)).toBe(true);
expect(v10.isNewer(v11)).toBe(false);
expect(v101.isNewer(v11)).toBe(false);
expect(v101.isNewer(v10)).toBe(true);

expect(v11rc1.isNewer(v10)).toBe(false);

});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,26 @@ import {
import { workloadsEntityCatalog } from '../../workloads-entity-catalog';

// Simple class to represent MAJOR.MINOR.REVISION version
class Version {
export class Version {

public major: number;
public minor: number;
public revision: number;

public prerelease: string;

public valid: boolean;

constructor(v: string) {
this.valid = false;
if (typeof v === 'string') {
const parts = v.split('.');
let version = v;
const pre = v.split('-');
if (pre.length > 1) {
version = pre[0];
this.prerelease = pre[1];
}
const parts = version.split('.');
if (parts.length === 3) {
this.major = parseInt(parts[0], 10);
this.minor = parseInt(parts[1], 10);
Expand All @@ -55,6 +63,19 @@ class Version {
return true;
}
if (this.minor === other.minor) {
if (this.revision === other.revision) {
// Same version numbers
if (this.prerelease && !other.prerelease) {
return false;
}
if(!this.prerelease && other.prerelease) {
return true;
}
if (this.prerelease && other.prerelease) {
return this.prerelease > other.prerelease;
}
return false;
}
return this.revision > other.revision;
}
}
Expand Down