Merge pull request #18183 from RubenV-dev/config-custom-resources

Fix: Allow ConfigClusterLocator to load cluster specific customResources
This commit is contained in:
Jamie Klassen
2023-06-13 13:02:08 -04:00
committed by GitHub
4 changed files with 1233 additions and 864 deletions
@@ -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