mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Switch to using injectable to setup route for get chart
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
9aefdf3dc6
commit
6729f46542
@ -183,7 +183,6 @@ export class Router {
|
|||||||
this.router.add({ method: "delete", path: `${apiPrefix}/pods/port-forward/{namespace}/{resourceType}/{resourceName}` }, PortForwardRoute.routeCurrentPortForwardStop);
|
this.router.add({ method: "delete", path: `${apiPrefix}/pods/port-forward/{namespace}/{resourceType}/{resourceName}` }, PortForwardRoute.routeCurrentPortForwardStop);
|
||||||
|
|
||||||
// Helm API
|
// Helm API
|
||||||
this.router.add({ method: "get", path: `${apiPrefix}/v2/charts/{repo}/{chart}` }, HelmApiRoute.getChart);
|
|
||||||
this.router.add({ method: "get", path: `${apiPrefix}/v2/charts/{repo}/{chart}/values` }, HelmApiRoute.getChartValues);
|
this.router.add({ method: "get", path: `${apiPrefix}/v2/charts/{repo}/{chart}/values` }, HelmApiRoute.getChartValues);
|
||||||
|
|
||||||
this.router.add({ method: "post", path: `${apiPrefix}/v2/releases` }, HelmApiRoute.installChart);
|
this.router.add({ method: "post", path: `${apiPrefix}/v2/releases` }, HelmApiRoute.installChart);
|
||||||
|
|||||||
35
src/main/routes/helm/charts/get-chart-route.injectable.ts
Normal file
35
src/main/routes/helm/charts/get-chart-route.injectable.ts
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import { routeInjectionToken } from "../../../router/router.injectable";
|
||||||
|
import type { LensApiRequest } from "../../../router";
|
||||||
|
import { helmService } from "../../../helm/helm-service";
|
||||||
|
import { respondJson, respondText } from "../../../utils/http-responses";
|
||||||
|
import { apiPrefix } from "../../../../common/vars";
|
||||||
|
|
||||||
|
const getChartRouteInjectable = getInjectable({
|
||||||
|
id: "get-chart-route",
|
||||||
|
|
||||||
|
instantiate: () => ({
|
||||||
|
method: "get",
|
||||||
|
path: `${apiPrefix}/v2/charts/{repo}/{chart}`,
|
||||||
|
|
||||||
|
handler: async (request: LensApiRequest) => {
|
||||||
|
const { params, query, response } = request;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const chart = await helmService.getChart(params.repo, params.chart, query.get("version"));
|
||||||
|
|
||||||
|
respondJson(response, chart);
|
||||||
|
} catch (error) {
|
||||||
|
respondText(response, error?.toString() || "Error getting chart", 422);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
|
injectionToken: routeInjectionToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default getChartRouteInjectable;
|
||||||
Loading…
Reference in New Issue
Block a user