feat(kubernetes): support rancher with path prefix
Signed-off-by: Jeff Stein <jeff@jeffvstein.org>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-kubernetes': patch
|
||||
---
|
||||
|
||||
Support Rancher urls with an existing path component
|
||||
@@ -99,4 +99,19 @@ describe('clusterLinks - rancher formatter', () => {
|
||||
'https://k8s.foo.com/explorer/autoscaling.horizontalpodautoscaler/bar/foobar',
|
||||
);
|
||||
});
|
||||
it('should support subpaths in dashboardUrl', () => {
|
||||
const url = rancherFormatter({
|
||||
dashboardUrl: new URL('https://k8s.foo.com/dashboard/c/c-28a4b/'),
|
||||
object: {
|
||||
metadata: {
|
||||
name: 'foobar',
|
||||
namespace: 'bar',
|
||||
},
|
||||
},
|
||||
kind: 'Deployment',
|
||||
});
|
||||
expect(url.href).toBe(
|
||||
'https://k8s.foo.com/dashboard/c/c-28a4b/explorer/apps.deployment/bar/foobar',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -28,9 +28,9 @@ export function rancherFormatter(options: ClusterLinksFormatterOptions): URL {
|
||||
const namespace = options.object.metadata?.namespace;
|
||||
const validKind = kindMappings[options.kind.toLocaleLowerCase('en-US')];
|
||||
if (validKind && name && namespace) {
|
||||
result.pathname = `explorer/${validKind}/${namespace}/${name}`;
|
||||
result.pathname += `explorer/${validKind}/${namespace}/${name}`;
|
||||
} else if (namespace) {
|
||||
result.pathname = 'explorer/workload';
|
||||
result.pathname += 'explorer/workload';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user