ConfigClusterLocator reads title

Signed-off-by: Jamie Klassen <jamie.klassen@broadcom.com>
This commit is contained in:
Jamie Klassen
2024-01-22 10:47:12 -05:00
parent 043cf88a63
commit 7ee5b30ba7
4 changed files with 32 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-kubernetes-backend': patch
---
Clusters in the app-config can now specify a `title` property for human readability.
+2
View File
@@ -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,