Introduce annotations relevant to resource view during deploy

This commit is contained in:
Koushik Dey
2020-07-15 16:24:50 +05:30
parent b4bc3003e8
commit 15e04b8f7e
15 changed files with 362 additions and 67 deletions
+28
View File
@@ -90,6 +90,34 @@ export function updateObjectLabels(inputObject: any, newLabels: Map<string, stri
}
}
export function updateObjectAnnotations(inputObject: any, newAnnotations: Map<string, string>, override: boolean) {
if (!inputObject) {
throw ('NullInputObject');
}
if (!inputObject.metadata) {
throw ('NullInputObjectMetadata');
}
if (!newAnnotations) {
return;
}
if (override) {
inputObject.metadata.annotations = newAnnotations;
} else {
let existingAnnotations = inputObject.metadata.annotations;
if (!existingAnnotations) {
existingAnnotations = new Map<string, string>();
}
Object.keys(newAnnotations).forEach(function (key) {
existingAnnotations[key] = newAnnotations[key];
});
inputObject.metadata.annotations = existingAnnotations;
}
}
export function updateImagePullSecrets(inputObject: any, newImagePullSecrets: string[], override: boolean) {
if (!inputObject || !inputObject.spec || !newImagePullSecrets) {
return;