ConfigClusterLocator reads title
Signed-off-by: Jamie Klassen <jamie.klassen@broadcom.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-kubernetes-backend': patch
|
||||
---
|
||||
|
||||
Clusters in the app-config can now specify a `title` property for human readability.
|
||||
+2
@@ -43,6 +43,8 @@ export interface Config {
|
||||
url: string;
|
||||
/** @visibility frontend */
|
||||
name: string;
|
||||
/** @visibility frontend */
|
||||
title?: string;
|
||||
/** @visibility secret */
|
||||
serviceAccountToken?: string;
|
||||
/** @visibility frontend */
|
||||
|
||||
@@ -21,8 +21,8 @@ import {
|
||||
ANNOTATION_KUBERNETES_AWS_ASSUME_ROLE,
|
||||
ANNOTATION_KUBERNETES_AWS_EXTERNAL_ID,
|
||||
} from '@backstage/plugin-kubernetes-common';
|
||||
import { ClusterDetails } from '@backstage/plugin-kubernetes-node';
|
||||
import { ConfigClusterLocator } from './ConfigClusterLocator';
|
||||
import { ClusterDetails } from '../types/types';
|
||||
import { AuthenticationStrategy } from '../auth';
|
||||
|
||||
describe('ConfigClusterLocator', () => {
|
||||
@@ -78,6 +78,28 @@ describe('ConfigClusterLocator', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('reads `title` property', async () => {
|
||||
const sut = ConfigClusterLocator.fromConfig(
|
||||
new ConfigReader({
|
||||
clusters: [
|
||||
{
|
||||
name: 'cluster-name',
|
||||
title: 'cluster-title',
|
||||
url: 'url',
|
||||
authMetadata: { 'kubernetes.io/auth-provider': 'serviceAccount' },
|
||||
},
|
||||
],
|
||||
}),
|
||||
authStrategy,
|
||||
);
|
||||
|
||||
const result = await sut.getClusters();
|
||||
|
||||
expect(result).toEqual([
|
||||
expect.objectContaining({ title: 'cluster-title' }),
|
||||
]);
|
||||
});
|
||||
|
||||
it('two clusters returns two cluster details', async () => {
|
||||
const config: Config = new ConfigReader({
|
||||
clusters: [
|
||||
|
||||
@@ -56,8 +56,10 @@ export class ConfigClusterLocator implements KubernetesClustersSupplier {
|
||||
`'authMetadata.${ANNOTATION_KUBERNETES_AUTH_PROVIDER}' parameter`,
|
||||
);
|
||||
}
|
||||
const title = c.getOptionalString('title');
|
||||
const clusterDetails: ClusterDetails = {
|
||||
name,
|
||||
...(title && { title }),
|
||||
url: c.getString('url'),
|
||||
skipTLSVerify: c.getOptionalBoolean('skipTLSVerify') ?? false,
|
||||
skipMetricsLookup: c.getOptionalBoolean('skipMetricsLookup') ?? false,
|
||||
|
||||
Reference in New Issue
Block a user