Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ssmirr committed May 6, 2019
2 parents 92e9c20 + 8576163 commit 8203715
Show file tree
Hide file tree
Showing 24 changed files with 3,714 additions and 1,594 deletions.
16 changes: 16 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ You can use GitHub issue tracker to submit an enhancement suggestions for Baker.

If you want to contribute to Baker source code but you are not sure where to start, see #enhancement and #bug issues that you might be able to address. If you have an idea for enhancement, before you start implementing the enhancement, make sure to open an issue and discuss about the idea with organizers. This will help make sure the enhancement that you want to work on is a right addition in accordance with goals of this project.

### Commit messages

We use [conventional commit message format](https://www.conventionalcommits.org/en/v1.0.0-beta.2/) to be able to auto-generate our changelog. Conventional commit message format is `<type>[optional scope]: <description>`. The type can be `fix | feat | BREAKING CHANGE | chore | docs | style | refactor | build` and the _optional_ scope can be `bakelet | module` or anything else that would make sense. A simple example for updating a dependency is `build(deps): Bump X from 1.2.0 to 1.3.0`.

You can also use multiple types, for example if adding a `feat` that is also a `BREAKING CHANGE`, your commit message can be:

```
feat: allow provided config object to extend other configs
BREAKING CHANGE: `extends` key in config file is now used for extending other config files
fixes #12
```

To help with writing these longer commit messages and for consistency, we have a dev-dependency ([commitizen](https://github.com/commitizen/cz-cli)). If you choose to use commitizen for writing your commit messages, simply run `npm run commit` and it will ask you to fill in some information and then commits your changes for you!

### Pull Request

Implemented a feature enhacement or fixed a bug? Open a PR and make sure to complete the PR template with as much details as possible. One of the organizers will review your proposed changes and respond to your PR.
Expand Down
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Change Log

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [0.7.0](https://github.com/ottomatica/Baker/compare/v0.6.15...v0.7.0) (2019-05-05)


### Bug Fixes

* Upgrade node-virtualbox to add VirtBox 6 support ([ottomatica/node-virtualbox#27](https://github.com/ottomatica/node-virtualbox/pull/27)) ([faeb715](https://github.com/ottomatica/node-virtualbox/commit/faeb715f7a59b831511bedacb329f5c86d818d00)), closes [#119](https://github.com/ottomatica/Baker/issues/119)
* Fixed invalid imports ([#91](https://github.com/ottomatica/Baker/issues/91)) ([ebda70c](https://github.com/ottomatica/Baker/commit/ebda70c)), closes [#90](https://github.com/ottomatica/Baker/issues/90)
* Update node-virtualbox to enable symlinks in shared folder ([85fa44b](https://github.com/ottomatica/Baker/commit/85fa44b))
* Update validator logic to not need drivelist dependency ([8af6f89](https://github.com/ottomatica/Baker/commit/8af6f89))


### Features

* Better error message + suggestion for invalid Bakelet names ([145ece9](https://github.com/ottomatica/Baker/commit/145ece9)), closes [#101](https://github.com/ottomatica/Baker/issues/101)
* Arch Linux PKGBUILD ([#120](https://github.com/ottomatica/Baker/pull/120)) ([59f5e81](https://github.com/ottomatica/Baker/commit/59f5e81)), closes [#115](https://github.com/ottomatica/Baker/issues/115)


<a name="0.6.15"></a>
## 0.6.15 (2018-11-26)

### Features

* Add python3.6 Bakelet ([2e52f01](https://github.com/ottomatica/Baker/commit/2e52f01))

<a name="0.6.14"></a>
## 0.6.14 (2018-11-25)

### Bug Fixes

* **bakelets:** Fix R Bakelet to work when no packages are provided ([b07c20e](https://github.com/ottomatica/Baker/commit/b07c20e)), closes [#69](https://github.com/ottomatica/Baker/issues/69)
* **providers:** Virtualbox stop command now stops instead of save state ([edde1a6](https://github.com/ottomatica/Baker/commit/edde1a6))

### Features

* Introducing _Vault_ ([235f144](https://github.com/ottomatica/Baker/commit/235f144))
* Add python3.6 Bakelet ([2e52f01](https://github.com/ottomatica/Baker/commit/2e52f01))
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### Baker community survey 🍞⁉️
If you have time, please answer few short questions to help us improve Baker: [community survey](https://goo.gl/forms/ffEyDVwQcI96Nt5c2)

# Baker 🍞
# Baker 🍞 | [![dependencies Status](https://david-dm.org/ottomatica/Baker/status.svg)](https://david-dm.org/ottomatica/Baker)

Meet Baker! -- a simple tool for provisioning virtual machines and containers. With Baker you can quickly create development environments and run your code. With one tool, you have the functionality of vagrant, docker, ansible, and task runners like grunt.

Expand Down
3 changes: 2 additions & 1 deletion global-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = {
envIndexPath: path.join(boxes, 'data', 'index.json'),
bakerForMacPath,
bakerSSHConfig,
privateKey
privateKey,
// spinnerDot : 'dots'
version: require('./package.json').version
};
35 changes: 35 additions & 0 deletions installers/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Maintainer: Samim Mirhosseini <samim@ottomatica.io>
pkgname="baker"
pkgver=0.7.0
pkgrel=1
pkgdesc="Quick and easy baking of computing environments."
arch=('x86_64')
url="https://github.com/ottomatica/Baker"
license=('Apache')
provides=('baker')
makedepends=('npm' 'jq' 'python2')
optdepends=('virtualbox: virtual machine support')
source=($pkgname-$pkgver.tar.gz::https://github.com/ottomatica/Baker/archive/v$pkgver.tar.gz)
md5sums=('63a02cc6837a64b917558c763dff1341')

package() {
npm install -g \
--user root \
--prefix "$pkgdir"/usr \
--cache "${srcdir}/npm-cache" \
"$srcdir"/$pkgname-$pkgver.tar.gz

# Non-deterministic race in npm gives 777 permissions to random directories.
# See https://github.com/npm/npm/issues/9359 for details.
find "${pkgdir}"/usr -type d -exec chmod 755 {} +

# Remove dependency references to $pkgdir
find "$pkgdir" -name package.json -print0 | xargs -0 sed -i '/_where/d'

# Remove package references to $pkgdir
local tmppackage="$(mktemp)"
local pkgjson="$pkgdir/usr/lib/node_modules/$pkgname/package.json"
jq '.|=with_entries(select(.key|test("_.+")|not))' "$pkgjson" > "$tmppackage"
mv "$tmppackage" "$pkgjson"
chmod 644 "$pkgjson"
}
4 changes: 4 additions & 0 deletions installers/build-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ sed -i "" -e "s/Version: .*/Version: ${BAKER_RELEASE}/" "linux/deb-template/bake
echo "Updating AppVersion in win/scripts/baker.iss to be $BAKER_RELEASE";
sed -i "" -e "s/AppVersion=.*/AppVersion=${BAKER_RELEASE}/" "win/scripts/baker.iss"

echo "Updating pkgver in PKGBUILD to be $BAKER_RELEASE";
sed -i "" -e "s/^pkgver=.*$/pkgver=${BAKER_RELEASE}/" "PKGBUILD"

# clean any old files
rm -f macos/bin/*

Expand Down Expand Up @@ -50,6 +53,7 @@ echo "Version: ${BAKER_RELEASE}"

echo "You are not done, yet"
echo "You need to upload the .tar.gz, .pkg, and .deb on github."
echo "You also need to update the md5sums field in PKGBUILD to the md5 sum of the source .tar.gz."
echo "Then you need to switch to a windows machine and run 'grunt'"
echo "Then you need to rename win/bin/baker-setup.exe to baker-windows-latest.exe and upload too"
echo "Finally, you need to update the sha to $SHA and VERSION to ${BAKER_RELEASE} in ottomatica/homebrew"
2 changes: 1 addition & 1 deletion installers/linux/deb-template/baker/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: Baker
Version: 0.6.13
Version: 0.7.0
Section: base
Priority: optional
Architecture: amd64
Expand Down
2 changes: 1 addition & 1 deletion installers/macos/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ PACKAGEREL="installers/macos"
IDENTIFIER="io.ottomatica.$NAME"

# Package version number.
VERSION="0.6.13"
VERSION="0.7.0"

# The location to copy the contents of files.
INSTALL_LOCATION="/opt/baker/bin"
Expand Down
2 changes: 1 addition & 1 deletion installers/win/scripts/baker.iss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{FF82CC8F-9CAD-4210-97AA-2C5F955DB742}
AppName=Baker
AppVersion=0.6.13
AppVersion=0.7.0
;AppVerName=Baker 0.4.3
AppPublisher=Ottomatica LLC
AppPublisherURL=https://getbaker.io/
Expand Down
75 changes: 75 additions & 0 deletions lib/bakelets/config/vault.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
const Bakelet = require('../bakelet');
const path = require('path');

const { privateKey } = require('../../../global-vars');
const conf = require('../../modules/configstore')

const Ansible = require('../../modules/configuration/ansible');
const VaultLib = require('../../modules/vault');
const Ssh = require('../../modules/ssh');

class Vault extends Bakelet {

constructor(name,ansibleSSHConfig, version) {
super(ansibleSSHConfig);

this.name = name;
this.version = version;
}


async load(obj, variables)
{

let passphraseKey = `vault:${this.bakePath}`;
let passphrase = '';
if (conf.has(passphraseKey))
{
passphrase = conf.get(passphraseKey);
}
else
{
// should be set in baking process.
throw new Error("Vault pass has not been correctly set.")
}
let vault = new VaultLib();

if( Array.isArray(obj.vault) )
{
this.vault = obj.vault;
this.variables = variables || {};

for (let entry of obj.vault)
{
let file = path.join(this.bakePath, entry.file);
let content = vault.retrieve(file, passphrase);

await Ssh.writeContentToDest(content,
`/home/vagrant/baker/${this.name}/templates/${entry.file}`,
this.ansibleSSHConfig,
false
);
}
}
}

async install()
{
if( this.vault )
{
for (let entry of this.vault)
{
await Ansible.createDirectory({name: this.name}, path.dirname(entry.dest), "0755", this.ansibleSSHConfig, this.verbose );

await Ansible.runAnsibleTemplateCmd(
{name: this.name}, `/home/vagrant/baker/${this.name}/templates/${entry.file}`,
entry.dest, this.variables, this.ansibleSSHConfig, this.verbose);
}
}
}


}

module.exports = Vault;

5 changes: 3 additions & 2 deletions lib/bakelets/lang/R.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ class R extends Bakelet {
this.packages = obj.R.packages.trim().split(/\s*,\s*/g);
else if(type = 'object')
this.packages = obj.R.packages;
} else {
this.packages = []
}
}
else {
this.packages = [];
}

let packagesObj = {'cran': this.packages.length!=0 ? true : false, 'packages': this.packages.map(p => `'${p}'`).join() };
let playbookTemplate = path.resolve(
Expand Down
24 changes: 23 additions & 1 deletion lib/bakelets/resolve.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const fs = require('fs-extra');
const path = require('path');
const Promise = require('bluebird');
const Spinner = require('../modules/spinner');
Expand Down Expand Up @@ -201,7 +202,15 @@ async function resolve(vmName, bakerScriptPath, remotesPath, dir, bakelet, extra

if (verbose) console.log("Found", bakeletName, version, extra_vars);

let classFoo = require(mod)
let classFoo = null;
try {
classFoo = require(mod);
} catch (error) {
let correctPath = (await getSupportedBakeletList(path.join(dir, '..'))).filter(bakelet => bakelet.name === info.bakeletName)[0];
let errorMessage = `Cannot find ${info.bakeletName} in ${path.join(info.mod, '..').split('/').pop()} Bakelets. `;
if (correctPath) errorMessage += `Did you mean ${correctPath.dir}:${info.bakeletName}?`
throw Error(errorMessage);
}

const boxes = path.join(require('os').homedir(), '.baker');
const ansible = path.join(boxes, 'ansible-srv');
Expand All @@ -217,3 +226,16 @@ async function resolve(vmName, bakerScriptPath, remotesPath, dir, bakelet, extra
await Spinner.spinPromise(j.load(bakelet, extra_vars), `Preparing ${bakeletName}`, spinnerDot);
await Spinner.spinPromise(j.install(), `Installing ${bakeletName}`, spinnerDot);
}

async function getSupportedBakeletList(bakeletsPath) {
let bakeletDirs = (await fs.readdir(bakeletsPath))
bakeletDirs = bakeletDirs.filter(dir => (fs.statSync(path.join(bakeletsPath, dir))).isDirectory());
let bakeletList = [];
for (let dir of bakeletDirs) {
let names = (await fs.readdir(path.join(bakeletsPath, dir))).map(dir => dir.split('.js')[0]);
for (let name of names) {
bakeletList.push({ name, dir });
}
}
return bakeletList;
}
46 changes: 45 additions & 1 deletion lib/commands/bake.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ const path = require('path');
const Print = require('../modules/print');
const Servers = require('../modules/servers');
const Spinner = require('../modules/spinner');
const VaultLib = require('../modules/vault');

const prompt = require('prompt');
const _ = require('underscore');

const { bakerSSHConfig } = require('../../global-vars');

Expand Down Expand Up @@ -107,8 +111,25 @@ exports.handler = async function(argv) {
}
}

const {provider, BakerObj} = await Baker.chooseProvider(bakePath, useContainer, useVM);
const {provider, BakerObj, doc} = await Baker.chooseProvider(bakePath, useContainer, useVM);

if( doc.config )
{
if( doc.config.some(element => element.vault) )
{
let passphraseKey = `vault:${bakePath}`;
if( !conf.has(passphraseKey) )
{
let pass = await promptPass();
let vault = new VaultLib();

console.log(passphraseKey, pass);
conf.set(passphraseKey, pass);
}
}
}


if(box)
await provider.bakeBox(bakerSSHConfig, ansibleVM, bakePath, verbose);
else if(remote)
Expand All @@ -127,3 +148,26 @@ exports.handler = async function(argv) {
Print.error(err);
}
}

async function promptPass()
{
return new Promise(function(resolve,reject)
{
var properties = [
{
name: 'password',
hidden: true
}
];

prompt.start();

prompt.get(properties, function (err, result) {
if (err) { reject(err); }
else
{
resolve(result.password)
}
});
});
}
Loading

0 comments on commit 8203715

Please sign in to comment.