1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix HelmChart validator requiring digest field (#4920)

* Fix HelmChart validator requiring digest field

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* fix tests

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-03-10 07:06:47 -05:00 committed by GitHub
parent 65ba094d97
commit 8b6f8e5dc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 14 deletions

View File

@ -36,13 +36,6 @@ describe("HelmChart tests", () => {
version: "!",
repo: "!",
} as any)).toThrowError('"created" is required');
expect(() => HelmChart.create({
apiVersion: "!",
name: "!",
version: "!",
repo: "!",
created: "!",
} as any)).toThrowError('"digest" is required');
});
it("should throw on fields being wrong type", () => {
@ -62,6 +55,14 @@ describe("HelmChart tests", () => {
created: "!",
digest: "!",
} as any)).toThrowError('"name" must be a string');
expect(() => HelmChart.create({
apiVersion: "!",
name: "!",
version: "!",
repo: "!",
created: "!",
digest: 1,
} as any)).toThrowError('"digest" must be a string');
expect(() => HelmChart.create({
apiVersion: "1",
name: "",

View File

@ -75,7 +75,7 @@ export interface RawHelmChart {
version: string;
repo: string;
created: string;
digest: string;
digest?: string;
kubeVersion?: string;
description?: string;
home?: string;
@ -142,7 +142,7 @@ const helmChartValidator = Joi.object<HelmChart, true, RawHelmChart>({
.required(),
digest: Joi
.string()
.required(),
.optional(),
kubeVersion: Joi
.string()
.optional(),
@ -247,22 +247,22 @@ export interface HelmChart {
name: string;
version: string;
repo: string;
kubeVersion?: string;
created: string;
description: string;
digest: string;
keywords: string[];
home?: string;
sources: string[];
urls: string[];
annotations: Record<string, string>;
dependencies: HelmChartDependency[];
maintainers: HelmChartMaintainer[];
deprecated: boolean;
kubeVersion?: string;
digest?: string;
home?: string;
engine?: string;
icon?: string;
appVersion?: string;
type?: string;
deprecated: boolean;
tillerVersion?: string;
}
@ -324,7 +324,11 @@ export class HelmChart {
}
getId(): string {
return `${this.repo}:${this.apiVersion}/${this.name}@${this.getAppVersion()}+${this.digest}`;
const digestPart = this.digest
? `+${this.digest}`
: "";
return `${this.repo}:${this.apiVersion}/${this.name}@${this.getAppVersion()}${digestPart}`;
}
getName(): string {