minor refactorings after code review
Signed-off-by: Morgan Martinet <morgan@mmm-experts.com>
This commit is contained in:
committed by
Morgan Martinet
parent
891d2bec18
commit
c80f53a4b5
@@ -49,7 +49,6 @@ describe('ConfigClusterLocator', () => {
|
||||
expect(result).toStrictEqual([
|
||||
{
|
||||
name: 'cluster1',
|
||||
dashboardUrl: undefined,
|
||||
serviceAccountToken: undefined,
|
||||
url: 'http://localhost:8080',
|
||||
authProvider: 'serviceAccount',
|
||||
@@ -93,7 +92,6 @@ describe('ConfigClusterLocator', () => {
|
||||
},
|
||||
{
|
||||
name: 'cluster2',
|
||||
dashboardUrl: undefined,
|
||||
serviceAccountToken: undefined,
|
||||
url: 'http://localhost:8081',
|
||||
authProvider: 'google',
|
||||
@@ -137,7 +135,6 @@ describe('ConfigClusterLocator', () => {
|
||||
expect(result).toStrictEqual([
|
||||
{
|
||||
assumeRole: undefined,
|
||||
dashboardUrl: undefined,
|
||||
name: 'cluster1',
|
||||
serviceAccountToken: 'token',
|
||||
externalId: undefined,
|
||||
@@ -147,7 +144,6 @@ describe('ConfigClusterLocator', () => {
|
||||
},
|
||||
{
|
||||
assumeRole: 'SomeRole',
|
||||
dashboardUrl: undefined,
|
||||
name: 'cluster2',
|
||||
externalId: undefined,
|
||||
serviceAccountToken: undefined,
|
||||
|
||||
@@ -30,14 +30,17 @@ export class ConfigClusterLocator implements KubernetesClustersSupplier {
|
||||
return new ConfigClusterLocator(
|
||||
config.getConfigArray('clusters').map(c => {
|
||||
const authProvider = c.getString('authProvider');
|
||||
const clusterDetails = {
|
||||
const clusterDetails: ClusterDetails = {
|
||||
name: c.getString('name'),
|
||||
url: c.getString('url'),
|
||||
dashboardUrl: c.getOptionalString('dashboardUrl'),
|
||||
serviceAccountToken: c.getOptionalString('serviceAccountToken'),
|
||||
skipTLSVerify: c.getOptionalBoolean('skipTLSVerify') ?? false,
|
||||
authProvider: authProvider,
|
||||
};
|
||||
const dashboardUrl = c.getOptionalString('dashboardUrl');
|
||||
if (dashboardUrl) {
|
||||
clusterDetails.dashboardUrl = dashboardUrl;
|
||||
}
|
||||
|
||||
switch (authProvider) {
|
||||
case 'google': {
|
||||
|
||||
@@ -50,7 +50,6 @@ describe('getCombinedClusterDetails', () => {
|
||||
expect(result).toStrictEqual([
|
||||
{
|
||||
name: 'cluster1',
|
||||
dashboardUrl: undefined,
|
||||
serviceAccountToken: 'token',
|
||||
url: 'http://localhost:8080',
|
||||
authProvider: 'serviceAccount',
|
||||
@@ -58,7 +57,6 @@ describe('getCombinedClusterDetails', () => {
|
||||
},
|
||||
{
|
||||
name: 'cluster2',
|
||||
dashboardUrl: undefined,
|
||||
serviceAccountToken: undefined,
|
||||
url: 'http://localhost:8081',
|
||||
authProvider: 'google',
|
||||
|
||||
@@ -165,7 +165,6 @@ describe('handleGetKubernetesObjectsForService', () => {
|
||||
items: [
|
||||
{
|
||||
cluster: {
|
||||
dashboardUrl: undefined,
|
||||
name: 'test-cluster',
|
||||
},
|
||||
errors: [],
|
||||
@@ -301,7 +300,6 @@ describe('handleGetKubernetesObjectsForService', () => {
|
||||
},
|
||||
{
|
||||
cluster: {
|
||||
dashboardUrl: undefined,
|
||||
name: 'other-cluster',
|
||||
},
|
||||
errors: [],
|
||||
@@ -400,7 +398,6 @@ describe('handleGetKubernetesObjectsForService', () => {
|
||||
items: [
|
||||
{
|
||||
cluster: {
|
||||
dashboardUrl: undefined,
|
||||
name: 'test-cluster',
|
||||
},
|
||||
errors: [],
|
||||
@@ -439,7 +436,6 @@ describe('handleGetKubernetesObjectsForService', () => {
|
||||
},
|
||||
{
|
||||
cluster: {
|
||||
dashboardUrl: undefined,
|
||||
name: 'other-cluster',
|
||||
},
|
||||
errors: [],
|
||||
@@ -542,7 +538,6 @@ describe('handleGetKubernetesObjectsForService', () => {
|
||||
items: [
|
||||
{
|
||||
cluster: {
|
||||
dashboardUrl: undefined,
|
||||
name: 'test-cluster',
|
||||
},
|
||||
errors: [],
|
||||
@@ -581,7 +576,6 @@ describe('handleGetKubernetesObjectsForService', () => {
|
||||
},
|
||||
{
|
||||
cluster: {
|
||||
dashboardUrl: undefined,
|
||||
name: 'other-cluster',
|
||||
},
|
||||
errors: [],
|
||||
@@ -620,7 +614,6 @@ describe('handleGetKubernetesObjectsForService', () => {
|
||||
},
|
||||
{
|
||||
cluster: {
|
||||
dashboardUrl: undefined,
|
||||
name: 'error-cluster',
|
||||
},
|
||||
errors: ['some random cluster error'],
|
||||
|
||||
@@ -22,7 +22,10 @@ import {
|
||||
KubernetesObjectTypes,
|
||||
KubernetesServiceLocator,
|
||||
} from '../types/types';
|
||||
import { KubernetesRequestBody } from '@backstage/plugin-kubernetes-common';
|
||||
import {
|
||||
ClusterObjects,
|
||||
KubernetesRequestBody,
|
||||
} from '@backstage/plugin-kubernetes-common';
|
||||
import { KubernetesAuthTranslator } from '../kubernetes-auth-translator/types';
|
||||
import { KubernetesAuthTranslatorGenerator } from '../kubernetes-auth-translator/KubernetesAuthTranslatorGenerator';
|
||||
|
||||
@@ -111,14 +114,17 @@ export class KubernetesFanOutHandler {
|
||||
customResources: this.customResources,
|
||||
})
|
||||
.then(result => {
|
||||
return {
|
||||
const objects: ClusterObjects = {
|
||||
cluster: {
|
||||
name: clusterDetailsItem.name,
|
||||
dashboardUrl: clusterDetailsItem.dashboardUrl,
|
||||
},
|
||||
resources: result.responses,
|
||||
errors: result.errors,
|
||||
};
|
||||
if (clusterDetailsItem.dashboardUrl) {
|
||||
objects.cluster.dashboardUrl = clusterDetailsItem.dashboardUrl;
|
||||
}
|
||||
return objects;
|
||||
});
|
||||
}),
|
||||
).then(r => ({
|
||||
|
||||
Reference in New Issue
Block a user