Skip to content

Commit

Permalink
fix: Add test as repro, and fix bug about kube API details not opening
Browse files Browse the repository at this point in the history
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
  • Loading branch information
jansav committed May 10, 2023
1 parent 786e0e8 commit bb400ae
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
14 changes: 14 additions & 0 deletions packages/core/src/common/k8s-api/__tests__/kube-api-parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ const tests: KubeApiParseTestData[] = [
name: "kube-public",
namespace: undefined,
}],

[
"/apis/apps/v1/namespaces/default/deployments/some-deployment",
{
apiBase: "/apis/apps/v1/deployments",
apiGroup: "apps",
apiPrefix: "/apis",
apiVersion: "v1",
apiVersionWithGroup: "apps/v1",
name: "some-deployment",
namespace: "default",
resource: "deployments",
},
],
];

const invalidTests = [
Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/common/k8s-api/kube-api-parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ export function parseKubeApi(path: string): IKubeApiParsed | undefined {
break;
}

let rest: string[];
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
apiVersion = left.at(-1)!;
const rest = left.slice(0, -1);

[apiVersion, ...rest] = left;
apiGroup = rest.join("/");
} else {
if (left.length === 0) {
Expand Down

0 comments on commit bb400ae

Please sign in to comment.