<commit_before>'use strict';

/**
 * Kalabox lib -> engine -> docker module.
 * @module docker
 */

var async = require('async');
var core = require('../core.js');
var exec = require('child_process').exec;
var fs = require('fs');
var path = require('path');
var _ = require('lodash');
var Dockerode = require('dockerode');
var S = require('string');

var docker = null;
var dockerConfig = null;

exports.init = function(globalConfig) {
  core.env.ifElseLinux(
    function() {
      dockerConfig = globalConfig.dockerConfigLinux;
    },
    function() {
      dockerConfig = globalConfig.dockerConfig;
    }
  );
  docker = new Dockerode(dockerConfig);
};

exports.teardown = function() {
  docker = null;
};

var get = function(cid) {
  return docker.getContainer(cid);
};
exports.get = get;

exports.getProviderModule = function() {
  // @todo: Change this to check platform.
  return require('./provider/b2d.js');
};

var inspect = function(container, callback) {
  container.inspect(callback);
};
exports.inspect = inspect;

var parseDockerContainerName = function(dockerContainerName) {
  var parts = dockerContainerName.split('_');
  if (parts.length !== 3) {<commit_msg>Fixing lib/engine/docker.js#init() bug<commit_after>'use strict';

/**
 * Kalabox lib -> engine -> docker module.
 * @module docker
 */

var async = require('async');
var core = require('../core.js');
var exec = require('child_process').exec;
var fs = require('fs');
var path = require('path');
var _ = require('lodash');
var Dockerode = require('dockerode');
var S = require('string');

var docker = null;
var dockerConfig = null;

exports.init = function(engineConfig) {
  dockerConfig = engineConfig;
  docker = new Dockerode(dockerConfig);
};

exports.teardown = function() {
  docker = null;
};

var get = function(cid) {
  return docker.getContainer(cid);
};
exports.get = get;

exports.getProviderModule = function() {
  // @todo: Change this to check platform.
  return require('./provider/b2d.js');
};

var inspect = function(container, callback) {
  container.inspect(callback);
};
exports.inspect = inspect;

var parseDockerContainerName = function(dockerContainerName) {
  var parts = dockerContainerName.split('_');
  if (parts.length !== 3) {
{'fraction_non_alphanumeric': 0.15763546798029557, 'fraction_numerical': 0.0017913121361397223, 'mean_word_length': 4.435523114355231, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2184109', 'n_tokens_mistral': 722, 'n_tokens_neox': 686, 'n_words': 171}