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

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-02-22 10:37:59 -05:00
parent 625b00c247
commit e939968470
2 changed files with 37 additions and 7 deletions

View File

@ -0,0 +1,26 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { HelmChart } from "../endpoints/helm-charts.api";
describe("Helm Charts", () => {
it("should accept a helm chart without a digest field", () => {
expect(() => HelmChart.create({
apiVersion: "foo",
name: "bar",
version: "1.0.0",
repo: "localhost:9090",
created: "yesterday",
description: "my bar chart",
keywords: ["test"],
sources: [],
urls: [],
annotations: {},
dependencies: [],
maintainers: [],
deprecated: false,
})).not.toThrowError();
});
});

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 {