Skip to content

Commit

Permalink
feat: Add pending-configuration annotation to resources in debug mode (
Browse files Browse the repository at this point in the history
…#254)

* feat: Add pending-configuration annotation to resources in debug mode

* Update lib/BaseController.js

Co-authored-by: Alex Lewitt <48691328+alewitt2@users.noreply.github.com>

Co-authored-by: Alex Lewitt <48691328+alewitt2@users.noreply.github.com>
  • Loading branch information
gregswift and alewitt2 authored Aug 24, 2021
1 parent 5296c8a commit 319d897
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/BaseController.js
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,15 @@ module.exports = class BaseController {
let debug = objectPath.get(liveResource, ['metadata', 'labels', 'deploy.razee.io/debug']) ||
objectPath.get(liveResource, ['metadata', 'labels', 'kapitan.razee.io/debug'], 'false');
if (debug.toLowerCase() === 'true') {
return { statusCode: 200, body: liveResource };
this.log.warn(`${uri}: Debug enabled on resource: skipping modifying resource - adding annotation deploy.razee.io/pending-configuration.`);
let patchObject = { metadata: { annotations: { 'deploy.razee.io/pending-configuration': JSON.stringify(file) } } };
let res = await krm.mergePatch(name, namespace, patchObject);
return { statusCode: 200, body: res };
} else {
let pendingApply = objectPath.get(liveResource, ['metadata', 'annotations', 'deploy.razee.io/pending-configuration']);
if (pendingApply) {
objectPath.set(file, ['metadata', 'annotations', 'deploy.razee.io/pending-configuration'], null);
}
}
let lastApplied = objectPath.get(liveResource, ['metadata', 'annotations', 'deploy.razee.io/last-applied-configuration']) ||
objectPath.get(liveResource, ['metadata', 'annotations', 'kapitan.razee.io/last-applied-configuration']);
Expand Down

0 comments on commit 319d897

Please sign in to comment.