Merge pull request #18183 from RubenV-dev/config-custom-resources
Fix: Allow ConfigClusterLocator to load cluster specific customResources
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-kubernetes-backend': patch
|
||||
---
|
||||
|
||||
Add ability for `configClusterLocator` to load cluster specific custom resources defined in your `app.config`.
|
||||
@@ -271,4 +271,47 @@ describe('ConfigClusterLocator', () => {
|
||||
|
||||
expect(result).toMatchObject([cluster]);
|
||||
});
|
||||
|
||||
it('has cluster level defined customResources returns clusterDetails with those CRDs', async () => {
|
||||
const config: Config = new ConfigReader({
|
||||
clusters: [
|
||||
{
|
||||
name: 'cluster1',
|
||||
url: 'http://localhost:8080',
|
||||
authProvider: 'serviceAccount',
|
||||
customResources: [
|
||||
{
|
||||
group: 'argoproj.io',
|
||||
apiVersion: 'v1alpha1',
|
||||
plural: 'rollouts',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
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,
|
||||
caFile: undefined,
|
||||
customResources: [
|
||||
{
|
||||
group: 'argoproj.io',
|
||||
apiVersion: 'v1alpha1',
|
||||
plural: 'rollouts',
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -40,6 +40,18 @@ export class ConfigClusterLocator implements KubernetesClustersSupplier {
|
||||
caFile: c.getOptionalString('caFile'),
|
||||
authProvider: authProvider,
|
||||
};
|
||||
|
||||
const customResources = c.getOptionalConfigArray('customResources');
|
||||
if (customResources) {
|
||||
clusterDetails.customResources = customResources.map(cr => {
|
||||
return {
|
||||
group: cr.getString('group'),
|
||||
apiVersion: cr.getString('apiVersion'),
|
||||
plural: cr.getString('plural'),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
const dashboardUrl = c.getOptionalString('dashboardUrl');
|
||||
if (dashboardUrl) {
|
||||
clusterDetails.dashboardUrl = dashboardUrl;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user