Skip to content

Commit

Permalink
Version 1.0.24
Browse files Browse the repository at this point in the history
  • Loading branch information
zirkerc committed Mar 26, 2018
1 parent e932078 commit 74f2fd9
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Declare files that will always have LF line endings on checkout.
leo-cli.js text eol=lf
7 changes: 4 additions & 3 deletions lib/cloud-formation.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module.exports = {

cloudFormation.Resources = Object.assign(cloudFormation.Resources, microservice.config && microservice.config.leo && microservice.config.leo.Resources || {});
cloudFormation.Parameters = Object.assign({}, cloudFormation.Parameters, microservice.config && microservice.config.leo && microservice.config.leo.Parameters || {});
cloudFormation.Conditions = Object.assign({}, cloudFormation.Conditions, microservice.config && microservice.config.leo && microservice.config.leo.Conditions || {});

let scalable = function(tableName, throughput, type) {
let targetCapacity = throughput[`Target${type}Capacity`];
Expand Down Expand Up @@ -222,9 +223,9 @@ module.exports = {
processFiles.push(f);
if (leo.variations) {
leo.variations.forEach((v, i) => {
if (!v.name){
if (!v.name) {
// TODO: Add memory and time to name
v.name = i;
v.name = i + 1;
}
let name = pkg.name + "-var-" + v.name;
delete v.name;
Expand Down Expand Up @@ -1237,4 +1238,4 @@ function getSwagger(cloudFormation, microservice) {
}
}
};
}
}
31 changes: 30 additions & 1 deletion lib/wrappers/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ process.resources = process.env.Resources && JSON.parse(process.env.Resources) |
var config = require("leo-sdk/leoConfigure");
const refUtil = require("leo-sdk/lib/reference.js");

var leosdk = require("leo-sdk");
var kms = require("leo-sdk/lib/kms")(leosdk.configuration);
var async = require("async");
process.env.TZ = config.timezone;
require('source-map-support').install({
environment: 'node',
Expand All @@ -16,6 +19,32 @@ const botId = pkg.name;
const settings = pkg.config && pkg.config.leo && pkg.config.leo.cron && pkg.config.leo.cron.settings || {};


let decrypted = false;
let botHandler = function(event, context, callback) {
let tasks = [];
Object.keys(process.env).forEach(function(key) {
if (!decrypted && (key.toLowerCase().indexOf('kms') !== -1 || process.env[key].match(/^KMS:/)) && !key.match(/^npm_/)) {
tasks.push(function(done) {
kms.decryptString(process.env[key].replace(/^KMS:/, ""), function(err, value) {
if (err) {
return done(err);
}
process.env[key] = value;
done();
});
});
}
});

async.parallelLimit(tasks, 20, function(err, results) {
if (err) {
return callback(err);
}
decrypted = true;
require("____FILE____")[handler](event, context, callback);
});
};


function empty(obj) {
for (let k in obj) {
Expand Down Expand Up @@ -61,6 +90,6 @@ module.exports = {
config.registry.id = process.env.AWS_LAMBDA_FUNCTION_NAME;
}

require("____FILE____")[handler](event, context, callback);
botHandler(event, context, callback);
}
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "leo-cli",
"version": "1.0.23",
"version": "1.0.24",
"description": "",
"main": "index.js",
"directories": {
Expand Down Expand Up @@ -121,4 +121,4 @@
},
"author": "",
"license": "MIT"
}
}

0 comments on commit 74f2fd9

Please sign in to comment.