Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bln-ops-blueprint-library

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bln-ops-blueprint-library - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

src/utils/gen_config/index.js

61

bin/cli.js

@@ -5,15 +5,20 @@ #!/usr/bin/env node

const program = require('commander');
const {readdirSync, readFileSync} = require('fs');
const {readdirSync, readFileSync, writeFileSync} = require('fs');
const {AWSSecretsManagerStore} = require('bln-squrl-tool');
const {YamlPrinter} = require('../src/printers');
const blueprintFunctions = require('../src/helpers/functions');
const yamlMerger = require('../src/utils/yaml_merger');
const genConfig = require('../src/utils/gen_config');
const {version} = require('../package.json');
program
.command('render')
.description('render a yaml service configuration file based on a template')
.version('1.0.0')
.option('-c --config <config>', 'Configuration file that contains environment specific variables')
.option('-d --directory <directory>', 'Directory of templates that will be used for generating yaml files')
.option('-s --source <source>', 'Directory with existing yaml files that will be used as the source ')
.option('-o --output <output>', 'Output directory')
.action((opts) => {
const {config, directory, output} = opts;
.action(async (opts) => {
const {config, directory, output, source} = opts;
if (!config || !directory || !output) {

@@ -36,4 +41,15 @@ return process.stderr.write('Required options not defined');

let blueprints;
let blueprintsDirectory;
try {
blueprints = readdirSync(directory);
if (source) {
process.stdout.write(`Merging source files from ${source} with templates in ${directory}.\n`);
const mergedTemplates = yamlMerger({sourceDir: source, templateDir: directory});
blueprints = mergedTemplates.files;
blueprintsDirectory = mergedTemplates.directory;
}
else {
blueprints = readdirSync(directory);
blueprintsDirectory = directory;
}
}

@@ -43,5 +59,6 @@ catch (e) {

}
try {
return blueprints.forEach((blueprint) => new YamlPrinter({
blueprintPath: `${directory}/${blueprint}`,
blueprintPath: `${blueprintsDirectory}/${blueprint}`,
outputPath: `${output}/${blueprint.replace('.template', '')}`,

@@ -59,2 +76,34 @@ options,

program
.command('generate-config')
.description('generate a config file with secrets that can be used consumed by blueprint')
.option('-V, --vpc <vpc>', 'Name of the VPC/Cluster (e.g. zoo-ki3)')
.option('-E, --environment <environment>', 'Name of the Environment (e.g. pre-prod)')
.option('-o --output <output>', 'Output directory')
.action(async (opts) => {
const {vpc: clusterName, environment: envName, output} = opts;
if (!clusterName || !envName || !output) {
throw new Error('Required options not defined');
}
const {secretsmanager} = new AWSSecretsManagerStore({});
const {SecretString: cluster} = await secretsmanager.getSecretValue({
SecretId: `${clusterName}/data/vpc`,
}).promise();
const {SecretString: env} = await secretsmanager.getSecretValue({
SecretId: `${clusterName}/data/${envName}`,
}).promise();
const {SecretString: db} = await secretsmanager.getSecretValue({
SecretId: `${clusterName}/data/${clusterName}-${envName}`,
}).promise();
const data = {env: JSON.parse(env), cluster: JSON.parse(cluster), db: JSON.parse(db)};
const config = JSON.stringify(genConfig({envName, clusterName, data}));
writeFileSync(output, config);
});
program.version(version);
program.parse(process.argv);

10

package.json
{
"name": "bln-ops-blueprint-library",
"version": "1.0.2",
"version": "1.0.3",
"description": "Helper tool for parsing and rendering templates",

@@ -8,3 +8,3 @@ "main": "src/index.js",

"engines": {
"node": "^8.12.0",
"node": ">=8.12.0",
"npm": "^6.4.1"

@@ -22,3 +22,3 @@ },

"devDependencies": {
"bln-squrl-tool": "^1.0.8",
"bln-squrl-tool": "^1.1.0",
"eslint": "^5.12.0",

@@ -34,6 +34,6 @@ "eslint-config-bluedrop": "^5.0.0",

"commander": "^2.19.0",
"js-yaml": "^3.12.1",
"js-yaml": "^3.13.1",
"lodash": "^4.17.11",
"nunjucks": "^3.1.6"
"nunjucks": "^3.2.1"
}
}

@@ -5,4 +5,4 @@ 'use strict';

const randomString = (length) => crypto.randomBytes(length).toString('hex');
const randomString = (length) => crypto.randomBytes(Math.ceil(length / 2)).toString('hex').substring(0, length);
module.exports = randomString;

@@ -9,2 +9,5 @@ 'use strict';

const storeSecret = async (value) => {
if (!value) {
return undefined;
}
const squrl = new Squrl({store: 'aws', vault: SQURL_VAULT_NAME});

@@ -11,0 +14,0 @@ let secretKey;

@@ -8,3 +8,2 @@ 'use strict';

const awaitFilter = require('../filters/await');
const VARIABLE_START_PATTERN = '<$';

@@ -11,0 +10,0 @@ const VARIABLE_END_PATTERN = '$>';

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc