change dashboardParameters signature after code review
Signed-off-by: Morgan Martinet <morgan.martinet@montreal.ca>
This commit is contained in:
@@ -176,4 +176,76 @@ describe('ConfigClusterLocator', () => {
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('one cluster with dashboardParameters', async () => {
|
||||
const config: Config = new ConfigReader({
|
||||
clusters: [
|
||||
{
|
||||
name: 'cluster1',
|
||||
url: 'http://localhost:8080',
|
||||
authProvider: 'serviceAccount',
|
||||
dashboardApp: 'gke',
|
||||
dashboardParameters: {
|
||||
projectId: 'some-project',
|
||||
region: 'some-region',
|
||||
clusterName: 'cluster1',
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const sut = ConfigClusterLocator.fromConfig(config);
|
||||
|
||||
const result = await sut.getClusters();
|
||||
|
||||
expect(result).toStrictEqual([
|
||||
{
|
||||
name: 'cluster1',
|
||||
serviceAccountToken: undefined,
|
||||
url: 'http://localhost:8080',
|
||||
authProvider: 'serviceAccount',
|
||||
skipMetricsLookup: false,
|
||||
skipTLSVerify: false,
|
||||
caData: undefined,
|
||||
dashboardApp: 'gke',
|
||||
dashboardParameters: {
|
||||
projectId: 'some-project',
|
||||
region: 'some-region',
|
||||
clusterName: 'cluster1',
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('one cluster with dashboardUrl', async () => {
|
||||
const config: Config = new ConfigReader({
|
||||
clusters: [
|
||||
{
|
||||
name: 'cluster1',
|
||||
url: 'http://localhost:8080',
|
||||
authProvider: 'serviceAccount',
|
||||
dashboardApp: 'standard',
|
||||
dashboardUrl: 'http://someurl',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const sut = ConfigClusterLocator.fromConfig(config);
|
||||
|
||||
const result = await sut.getClusters();
|
||||
|
||||
expect(result).toStrictEqual([
|
||||
{
|
||||
name: 'cluster1',
|
||||
serviceAccountToken: undefined,
|
||||
url: 'http://localhost:8080',
|
||||
authProvider: 'serviceAccount',
|
||||
skipMetricsLookup: false,
|
||||
skipTLSVerify: false,
|
||||
caData: undefined,
|
||||
dashboardApp: 'standard',
|
||||
dashboardUrl: 'http://someurl',
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -47,9 +47,8 @@ export class ConfigClusterLocator implements KubernetesClustersSupplier {
|
||||
if (dashboardApp) {
|
||||
clusterDetails.dashboardApp = dashboardApp;
|
||||
}
|
||||
const dashboardParameters = c.getOptionalString('dashboardParameters');
|
||||
if (dashboardParameters) {
|
||||
clusterDetails.dashboardParameters = dashboardParameters;
|
||||
if (c.has('dashboardParameters')) {
|
||||
clusterDetails.dashboardParameters = c.get('dashboardParameters');
|
||||
}
|
||||
|
||||
switch (authProvider) {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
import { Logger } from 'winston';
|
||||
import type { JsonObject } from '@backstage/types';
|
||||
import type {
|
||||
FetchResponse,
|
||||
KubernetesFetchError,
|
||||
@@ -135,7 +136,7 @@ export interface ClusterDetails {
|
||||
* This is used by the GKE formatter which requires the project, region and cluster name.
|
||||
* @see dashboardApp
|
||||
*/
|
||||
dashboardParameters?: any;
|
||||
dashboardParameters?: JsonObject;
|
||||
}
|
||||
|
||||
export interface GKEClusterDetails extends ClusterDetails {}
|
||||
|
||||
Reference in New Issue
Block a user