api version overrides

Signed-off-by: Andrew Tran <atran@brex.com>
This commit is contained in:
Andrew Tran
2021-11-22 12:55:25 -06:00
parent dd1faa49eb
commit bb6c03001d
2 changed files with 24 additions and 0 deletions
+9
View File
@@ -63,5 +63,14 @@ export interface Config {
apiVersion: string;
plural: string;
}>;
apiVersionOverrides?: {
pods?: string;
services?: string;
configmaps?: string;
deployments?: string;
replicasets?: string;
horizontalpodautoscalers?: string;
ingresses?: string;
};
};
}
@@ -243,6 +243,10 @@ export class KubernetesBuilder {
'kubernetes.objectTypes',
) as KubernetesObjectTypes[];
const apiVersionOverrides = this.env.config.getOptionalConfig(
'kubernetes.apiVersionOverrides',
);
let objectTypesToFetch;
if (objectTypesToFetchStrings) {
@@ -250,6 +254,17 @@ export class KubernetesBuilder {
objectTypesToFetchStrings.includes(obj.objectType),
);
}
if (apiVersionOverrides) {
objectTypesToFetch = objectTypesToFetch ?? DEFAULT_OBJECTS;
for (const obj of objectTypesToFetch) {
if (apiVersionOverrides.getOptionalString(obj.objectType)) {
obj.apiVersion = apiVersionOverrides.getString(obj.objectType);
}
}
}
return objectTypesToFetch;
}
}