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

View File

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