Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow env overrides to merge data #258

Merged
merged 4 commits into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/BaseController.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,9 @@ module.exports = class BaseController {
} else {
this._logger.debug(`Post ${uri}`);
// Add last-applied to be used in future apply reconciles
if (objectPath.get(file, ['metadata', 'annotations']) === null) {
objectPath.set(file, ['metadata', 'annotations'], {});
}
objectPath.set(file, ['metadata', 'annotations', 'deploy.razee.io/last-applied-configuration'], JSON.stringify(file));
let post = await krm.post(file, opt);
if (!(post.statusCode === 200 || post.statusCode === 201 || post.statusCode === 202)) {
Expand Down
10 changes: 8 additions & 2 deletions lib/FetchEnvs.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

const objectPath = require('object-path');
const clone = require('clone');
const merge = require('deepmerge');
const log = require('./bunyan-api').createLogger('fetchEnvs');

module.exports = class FetchEnvs {
Expand Down Expand Up @@ -111,7 +112,7 @@ module.exports = class FetchEnvs {
result = result.slice(1, result.length - 1);
break;
case 'base64':
result = new Buffer(result).toString('base64');
result = Buffer.from(result).toString('base64');
break;
}
}
Expand Down Expand Up @@ -261,7 +262,12 @@ module.exports = class FetchEnvs {
env = await this._processEnv(env);
env.forEach((e) => {
if (e.value !== undefined) {
result[e.name] = e.value;
if (e.overrideStrategy === 'merge' && typeof result[e.name] === 'object' && typeof e.value === 'object') {
const merged = merge(result[e.name], e.value);
result[e.name] = merged;
} else {
result[e.name] = e.value;
}
}
});
return result;
Expand Down