git2consul
Advanced tools
Comparing version 0.6.2 to 0.6.3
86
index.js
@@ -1,87 +0,3 @@ | ||
var logging = require('./lib/utils/logging.js'); | ||
var config_reader = require('./lib/utils/config_reader.js'); | ||
var fs = require('fs'); | ||
var os = require('os'); | ||
var util = require('util'); | ||
/** | ||
* Read config from a specially named Consul resource. If the config was not seeded | ||
* (and this should be done using utils/config_seeder.js), git2consul will not boot. | ||
*/ | ||
config_reader.read(function(err, config) { | ||
if (err) return console.error(err); | ||
// Logging configuration is specified in the config object, so initialize our logger | ||
// around that config. | ||
logging.init(config); | ||
if (process.env.TOKEN) { | ||
// If a token was configured, register it with the consul broker | ||
require('./lib/consul_broker.js').setToken(process.env.TOKEN); | ||
} | ||
var logger = require('./lib/utils/logging.js'); | ||
var git_manager = require('./lib/git_manager.js'); | ||
if (!config.repos || !config.repos.length > 0) { | ||
// Fail startup. | ||
logger.error("No repos found in configuration. Halting.") | ||
process.exit(1); | ||
} | ||
// Process command line switches, if any. Command-line switches override the settings | ||
// loaded from Consul. | ||
for (var i=2; i<process.argv.length; ++i) { | ||
if (process.argv[i] === '-n' || process.argv[i] === '--no_daemon') config['no_daemon'] = true; | ||
if (process.argv[i] === '-h' || process.argv[i] === '--halt_on_change') config['halt_on_change'] = true; | ||
else if (process.argv[i] === '-d' || process.argv[i] === '--local_store') { | ||
if (i+1 >= process.argv[length]) { | ||
logger.error("No dir provided with --local_store option"); | ||
process.exit(3); | ||
} | ||
config['local_store'] = process.argv[i+1]; | ||
} | ||
} | ||
// If we are running in no daemon mode, set the git_manager to disable any listeners that would keep | ||
// the process running after the initial sync. | ||
if (config.no_daemon === true) { | ||
git_manager.setDaemon(false); | ||
// If we aren't running in no daemon mode and the configuration calls for halt on change, enable it. | ||
// We don't do this if config.no_daemon is enabled as the halt on change listener would keep the process | ||
// running. | ||
} else if (config.halt_on_change === true) { | ||
git_manager.enableHaltOnChange(); | ||
} | ||
if (!config.local_store) { | ||
config.local_store = os.tmpdir(); | ||
} | ||
if (!fs.existsSync(config.local_store)) { | ||
logger.error("Local store dir %s not found", config.local_store); | ||
} | ||
logger.info('git2consul is running'); | ||
process.on('uncaughtException', function(err) { | ||
logger.error("Uncaught exception " + err); | ||
}); | ||
// Set up the git manager for each repo. | ||
git_manager.manageRepos(config, function(err) { | ||
if (err) { | ||
logger.error('Failed to create git managers due to %s', err); | ||
setTimeout(function() { | ||
// If any git manager failed to start, consider this a fatal error. | ||
process.exit(2); | ||
}, 2000); | ||
} | ||
}); | ||
}); | ||
var git2consul = require('./lib'); |
{ | ||
"name": "git2consul", | ||
"description": "System for moving data from git to consul", | ||
"version": "0.6.2", | ||
"version": "0.6.3", | ||
"contributors": [ | ||
@@ -17,2 +17,3 @@ { | ||
"mkdirp": "0.5.0", | ||
"coveralls": "^2.11.2", | ||
"rimraf": "2.2.8", | ||
@@ -29,4 +30,5 @@ "underscore": "1.6.0" | ||
"scripts": { | ||
"cov": "XUNIT_FILE=\"reports/TESTS-xunit.xml\" node_modules/.bin/istanbul cover --root lib --dir ./reports ./node_modules/.bin/_mocha -- --reporter xunit-file -t 10000 test", | ||
"test": "./node_modules/.bin/_mocha --reporter spec -t 10000 test" | ||
"test": "./node_modules/.bin/_mocha --reporter spec -t 10000 test | bunyan", | ||
"cov": "`npm bin`/istanbul cover --root . -x node_modules -x test --dir ./reports `npm bin`/_mocha -- --reporter spec -t 10000 test | bunyan", | ||
"coveralls": "npm run cov && node_modules/coveralls/bin/coveralls.js < reports/lcov.info" | ||
}, | ||
@@ -33,0 +35,0 @@ "licenses": [ |
@@ -96,3 +96,3 @@ #### git2consul | ||
![Travis Status](https://travis-ci.org/ryanbreen/git2consul.svg?branch=master) | ||
![Travis Status](https://api.travis-ci.org/Cimpress-MCP/git2consul.svg?branch=master) | ||
@@ -99,0 +99,0 @@ ##### License |
@@ -7,3 +7,3 @@ var should = require('should'); | ||
var logging = require('../lib/utils/logging.js'); | ||
var logging = require('../lib/logging.js'); | ||
logging.init({ | ||
@@ -16,6 +16,6 @@ "logger" : { | ||
"path": "./test/logs/test.log" | ||
}/**,{ | ||
}/*,{ | ||
"level": "trace", | ||
"stream": "process.stdout" | ||
}/**/] | ||
}*/] | ||
} | ||
@@ -22,0 +22,0 @@ }); |
@@ -9,6 +9,6 @@ var should = require('should'); | ||
var git_manager = require('../lib/git_manager.js'); | ||
var Repo = require('../lib/git/repo.js'); | ||
var git_utils = require('./utils/git_utils.js'); | ||
var git_commands = require('../lib/utils/git_commands.js'); | ||
var git_commands = require('../lib/git/commands.js'); | ||
@@ -44,15 +44,15 @@ describe('Concurrency protections', function() { | ||
var second_ref = ref; | ||
var bm = git_utils.GM.getBranchManager('master'); | ||
var branch = git_utils.repo.branches['master']; | ||
bm.handleRefChange((normal_ref_order ? first_ref : second_ref), function(cb) { | ||
branch.handleRefChange((normal_ref_order ? first_ref : second_ref), function(cb) { | ||
if (err) return done(err); | ||
}); | ||
bm.handleRefChange((normal_ref_order ? second_ref : first_ref), function(cb) { | ||
branch.handleRefChange((normal_ref_order ? second_ref : first_ref), function(cb) { | ||
if (err) return done(err); | ||
// At this point, the git_manager should have populated consul with both sample_key | ||
consul_utils.validateValue(git_utils.GM.getRepoName() + '/master/' + sample_key, sample_value, function(err, value) { | ||
consul_utils.validateValue(git_utils.repo.name + '/master/' + sample_key, sample_value, function(err, value) { | ||
if (err) return done(err); | ||
consul_utils.validateValue(git_utils.GM.getRepoName() + '/master/' + sample_key2, sample_value2, function(err, value) { | ||
consul_utils.validateValue(git_utils.repo.name + '/master/' + sample_key2, sample_value2, function(err, value) { | ||
if (err) return done(err); | ||
@@ -59,0 +59,0 @@ done(); |
@@ -7,3 +7,3 @@ var _ = require('underscore'); | ||
var git_manager = require('../lib/git_manager.js'); | ||
var Repo = require('../lib/git/repo.js'); | ||
var git_utils = require('./utils/git_utils.js'); | ||
@@ -13,37 +13,22 @@ | ||
it ('should reject a config with no repos', function(done) { | ||
var count = 3; | ||
git_manager.manageRepos(null, function(err) { | ||
err.should.equal('No config provided'); | ||
--count; | ||
if (count === 0) done(); | ||
}); | ||
git_manager.manageRepos({}, function(err) { | ||
err.should.equal('No array of repo configs provided'); | ||
--count; | ||
if (count === 0) done(); | ||
}); | ||
git_manager.manageRepos([], function(err) { | ||
err.should.equal('No array of repo configs provided'); | ||
--count; | ||
if (count === 0) done(); | ||
}); | ||
}); | ||
it ('should reject a repo with invalid config', function() { | ||
it ('should reject a config with duplicate repo names', function(done) { | ||
git_manager.manageRepos({repos:[{'name': 'test_repo'}, {'name': 'test_repo'}, {'name': 'github_test_repo'}]}, function(err) { | ||
err.should.startWith('Duplicate name found in repos'); | ||
done(); | ||
}); | ||
}); | ||
try { | ||
var repo = new Repo(); | ||
should.fail("Repo with no config should throw an exception"); | ||
} catch(e) { | ||
e.message.should.equal('No configuration provided for repo'); | ||
} | ||
it ('should reject a config with no repo name', function(done) { | ||
var stock_config = git_utils.createConfig(); | ||
delete stock_config.repos[0].name; | ||
git_manager.manageRepo(stock_config, stock_config.repos[0], function(err) { | ||
err.should.equal('No name provided for repo.'); | ||
done(); | ||
[{}, {'name':'incomplete'}, {'name':'incomplete', 'branches': ['master']}].forEach(function(config) { | ||
try { | ||
var repo = new Repo(config); | ||
should.fail("Repo with incomplete config should throw an exception"); | ||
} catch(e) { | ||
e.message.should.equal('A repo must have a url, a name, and a branch array.'); | ||
} | ||
}); | ||
}); | ||
/** | ||
it ('should reject a config using an existing repo name', function(done) { | ||
@@ -57,17 +42,14 @@ var stock_config = git_utils.createConfig(); | ||
}); | ||
**/ | ||
it ('should reject a repo with no branches', function(done) { | ||
git_manager.manageRepo(git_utils.createConfig(), {'name': 'busted_no_branch_repo', 'branches': []}, function(err) { | ||
err.should.equal('No branches specified.'); | ||
done(); | ||
}); | ||
it ('should reject a repo with duplicate branches', function() { | ||
try { | ||
var repo = new Repo({'name': 'busted_dupe_branch_repo', 'url': 'http://www.github.com/', 'branches': ['master', 'master', 'commander']}); | ||
should.fail("Repo with duplicate branches should throw an exception"); | ||
} catch(e) { | ||
e.message.should.startWith('Duplicate name found in branches for repo busted_dupe_branch_repo'); | ||
} | ||
}); | ||
it ('should reject a repo with duplicate branches', function(done) { | ||
git_manager.manageRepo(git_utils.createConfig(), {'name': 'busted_dupe_branch_repo', 'branches': ['master', 'master', 'commander']}, function(err) { | ||
err.should.startWith('Duplicate name found in branches for repo busted_dupe_branch_repo'); | ||
done(); | ||
}); | ||
}); | ||
/** | ||
it ('should reject a repo with a bogus local_store', function(done) { | ||
@@ -81,7 +63,8 @@ var stock_config = git_utils.createConfig(); | ||
}); | ||
**/ | ||
it ('should reject a repo with a broken git url', function(done) { | ||
git_manager.manageRepo( | ||
_.extend(git_utils.createConfig(), {local_store:'/tmp/busted'}), _.extend(git_utils.createRepoConfig(), { url: 'file:///tmp/nobody_home' }), function(err) { | ||
err.should.startWith('Failed to create manager for branch master'); | ||
var repo = new Repo(_.extend(git_utils.createRepoConfig(), { url: 'file:///tmp/nobody_home' })); | ||
repo.init(function(err) { | ||
err.message.should.containEql('does not appear to be a git repository'); | ||
done(); | ||
@@ -91,2 +74,3 @@ }); | ||
/** | ||
it ('should reject an invalid git hook type', function(done) { | ||
@@ -109,2 +93,3 @@ git_manager.manageRepo(git_utils.createConfig(), _.extend(git_utils.createRepoConfig(), { hooks: [ { 'type': 'unknown' }] }), function(err, gm) { | ||
}); | ||
**/ | ||
}); |
@@ -9,10 +9,8 @@ var should = require('should'); | ||
var git_manager = require('../lib/git_manager.js'); | ||
var repo = require('../lib/git/repo.js'); | ||
var git_utils = require('./utils/git_utils.js'); | ||
var consul_utils = require('./utils/consul_utils.js'); | ||
var git_commands = require('../lib/utils/git_commands.js'); | ||
var git_commands = require('../lib/git/commands.js'); | ||
var my_git_manager; | ||
describe('File operations', function() { | ||
@@ -23,3 +21,3 @@ | ||
var sample_value = 'new test data'; | ||
var repo_name = git_utils.GM.getRepoName(); | ||
var repo_name = git_utils.repo.name; | ||
git_utils.addFileToGitRepo(sample_key, sample_value, "Update a file.", function(err) { | ||
@@ -37,6 +35,6 @@ if (err) return done(err); | ||
var sample_value = 'new value'; | ||
var repo_name = git_utils.GM.getRepoName(); | ||
var repo_name = git_utils.repo.name; | ||
git_utils.addFileToGitRepo(sample_key, sample_value, "Add a file.", function(err) { | ||
if (err) return done(err); | ||
// At this point, the git_manager should have populated consul with our sample_key | ||
// At this point, the repo should have populated consul with our sample_key | ||
consul_utils.validateValue(repo_name + '/master/' + sample_key, sample_value, function(err, value) { | ||
@@ -52,6 +50,6 @@ if (err) return done(err); | ||
var sample_value = 'new value'; | ||
var repo_name = git_utils.GM.getRepoName(); | ||
var repo_name = git_utils.repo.name; | ||
git_utils.addFileToGitRepo(sample_key, sample_value, "Create file to delete.", function(err) { | ||
if (err) return done(err); | ||
// At this point, the git_manager should have populated consul with our sample_key | ||
// At this point, the repo should have populated consul with our sample_key | ||
consul_utils.validateValue(repo_name + '/master/' + sample_key, sample_value, function(err, value) { | ||
@@ -61,3 +59,3 @@ if (err) return done(err); | ||
if (err) return done(err); | ||
// At this point, the git_manager should have removed our sample_key | ||
// At this point, the repo should have removed our sample_key | ||
consul_utils.validateValue(repo_name + '/master/' + sample_key, undefined, function(err, value) { | ||
@@ -76,6 +74,6 @@ if (err) return done(err); | ||
var sample_value = 'movable value'; | ||
var repo_name = git_utils.GM.getRepoName(); | ||
var repo_name = git_utils.repo.name; | ||
git_utils.addFileToGitRepo(sample_key, sample_value, "Create file to move.", function(err) { | ||
if (err) return done(err); | ||
// At this point, the git_manager should have populated consul with our sample_key | ||
// At this point, the repo should have populated consul with our sample_key | ||
consul_utils.validateValue(repo_name + '/master/' + sample_key, sample_value, function(err, value) { | ||
@@ -85,6 +83,6 @@ if (err) return done(err); | ||
if (err) return done(err); | ||
// At this point, the git_manager should have populated consul with our moved key, deleting the old name | ||
// At this point, the repo should have populated consul with our moved key, deleting the old name | ||
consul_utils.validateValue(repo_name + '/master/' + sample_key, undefined, function(err) { | ||
if (err) return done(err); | ||
// At this point, the git_manager should have populated consul with our moved key, adding the new name | ||
// At this point, the repo should have populated consul with our moved key, adding the new name | ||
consul_utils.validateValue(repo_name + '/master/' + sample_moved_key, sample_value, function(err) { | ||
@@ -104,6 +102,6 @@ if (err) return done(err); | ||
var sample_value = 'movable value'; | ||
var repo_name = git_utils.GM.getRepoName(); | ||
var repo_name = git_utils.repo.name; | ||
git_utils.addFileToGitRepo(sample_key, sample_value, "Create file to move to subfolder.", function(err) { | ||
if (err) return done(err); | ||
// At this point, the git_manager should have populated consul with our sample_key | ||
// At this point, the repo should have populated consul with our sample_key | ||
consul_utils.validateValue(repo_name + '/master/' + sample_key, sample_value, function(err, value) { | ||
@@ -115,6 +113,6 @@ if (err) return done(err); | ||
if (err) return done(err); | ||
// At this point, the git_manager should have populated consul with our moved key, deleting the old name | ||
// At this point, the repo should have populated consul with our moved key, deleting the old name | ||
consul_utils.validateValue(repo_name + '/master/' + sample_key, undefined, function(err) { | ||
if (err) return done(err); | ||
// At this point, the git_manager should have populated consul with our moved key, adding the new name | ||
// At this point, the repo should have populated consul with our moved key, adding the new name | ||
consul_utils.validateValue(repo_name + '/master/' + sample_moved_key, sample_value, function(err) { | ||
@@ -135,6 +133,6 @@ if (err) return done(err); | ||
var sample_value = 'linked value'; | ||
var repo_name = git_utils.GM.getRepoName(); | ||
var repo_name = git_utils.repo.name; | ||
git_utils.addFileToGitRepo(sample_key, sample_value, "Create file for symlinking.", function(err) { | ||
if (err) return done(err); | ||
// At this point, the git_manager should have populated consul with our sample_key | ||
// At this point, the repo should have populated consul with our sample_key | ||
consul_utils.validateValue(repo_name + '/master/' + sample_key, sample_value, function(err, value) { | ||
@@ -141,0 +139,0 @@ if (err) return done(err); |
@@ -7,7 +7,7 @@ var should = require('should'); | ||
var git_manager = require('../lib/git_manager.js'); | ||
var repo = require('../lib/git/repo.js'); | ||
var git_utils = require('./utils/git_utils.js'); | ||
var consul_utils = require('./utils/consul_utils.js'); | ||
var git_commands = require('../lib/utils/git_commands.js'); | ||
var git_commands = require('../lib/git/commands.js'); | ||
@@ -27,3 +27,3 @@ describe('KV handling', function() { | ||
var repo_name = git_utils.GM.getRepoName(); | ||
var repo_name = git_utils.repo.name; | ||
@@ -33,3 +33,3 @@ buffer_test(512*1024, function(err) { | ||
// At this point, the git_manager should have populated consul with our sample_key | ||
// At this point, the repo should have populated consul with our sample_key | ||
consul_utils.getValue(repo_name + '/master/big_file', function(err, value) { | ||
@@ -45,3 +45,3 @@ if (err) return done(err); | ||
var repo_name = git_utils.GM.getRepoName(); | ||
var repo_name = git_utils.repo.name; | ||
@@ -61,3 +61,3 @@ buffer_test(513*1024, function(err) { | ||
var repo_name = git_utils.GM.getRepoName(); | ||
var repo_name = git_utils.repo.name; | ||
var sample_key = 'sample_new_key'; | ||
@@ -68,3 +68,3 @@ var sample_value = ''; | ||
if (err) return done(err); | ||
// At this point, the git_manager should have populated consul with our sample_key | ||
// At this point, the repo should have populated consul with our sample_key | ||
consul_utils.validateValue(repo_name + '/master/' + sample_key, sample_value, function(err, value) { | ||
@@ -71,0 +71,0 @@ if (err) return done(err); |
var should = require('should'); | ||
// We want this above any git2consul module to make sure logging gets configured | ||
require('./git2consul_bootstrap_test.js'); | ||
var bootstrap = require('./git2consul_bootstrap_test.js'); | ||
var git_manager = require('../lib/git_manager.js'); | ||
var git = require('../lib/git'); | ||
@@ -13,7 +13,8 @@ var git_utils = require('./utils/git_utils.js'); | ||
before(function() { | ||
git_manager.mock(); | ||
git.mock(); | ||
bootstrap.manual_mode(true); | ||
}); | ||
it ('should successfully fire if nothing else is happening', function(done) { | ||
git_manager.gracefulShutdown(function() { | ||
git.gracefulShutdown(function() { | ||
done(); | ||
@@ -23,29 +24,39 @@ }); | ||
// TODO: Fix this test. | ||
/** | ||
it ('should successfully fire if other stuff is happening', function(done) { | ||
// This should be set only once the handle ref has completed. | ||
var shutdown_seen = false; | ||
bootstrap.cleanup(function(err) { | ||
git_utils.initRepo(function(err) { | ||
if (err) return done(err); | ||
var sample_key = 'sample_key'; | ||
var sample_value = 'new test data'; | ||
git_utils.addFileToGitRepo(sample_key, sample_value, "Update a file.", false, function(err) { | ||
if (err) return done(err); | ||
// This should be set only once the handle ref has completed. | ||
var shutdown_seen = false; | ||
git_utils.GM.getBranchManager('master').handleRefChange(0, function(err) { | ||
if (err) return done(err); | ||
shutdown_seen.should.equal(false); | ||
}); | ||
var sample_key = 'sample_key'; | ||
var sample_value = 'new test data'; | ||
git_utils.addFileToGitRepo(sample_key, sample_value, "Update a file.", false, function(err) { | ||
if (err) return done(err); | ||
// This should not fire until after we've processed the handleRefChange above | ||
git_manager.gracefulShutdown(function() { | ||
shutdown_seen = true; | ||
done(); | ||
git_utils.repo.branches['master'].handleRefChange(0, function(err) { | ||
if (err) return done(err); | ||
shutdown_seen.should.equal(false); | ||
}); | ||
// This should not fire until after we've processed the handleRefChange above | ||
git.gracefulShutdown(function() { | ||
shutdown_seen = true; | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
*/ | ||
after(function() { | ||
git_manager.mock(); | ||
bootstrap.manual_mode(false); | ||
}); | ||
}); |
@@ -9,6 +9,6 @@ var should = require('should'); | ||
var git_manager = require('../lib/git_manager.js'); | ||
var Repo = require('../lib/git/repo.js'); | ||
var git_utils = require('./utils/git_utils.js'); | ||
var git_commands = require('../lib/utils/git_commands.js'); | ||
var git_commands = require('../lib/git/commands.js'); | ||
@@ -18,3 +18,3 @@ describe('Cloning a repo for the first time', function() { | ||
it ('should handle a multiple file repo', function(done) { | ||
var repo_name = git_utils.GM.getRepoName(); | ||
var repo_name = git_utils.repo.name; | ||
var sample_key = 'sample_key'; | ||
@@ -32,3 +32,3 @@ var sample_value = 'test data'; | ||
// At this point, the git_manager should have populated consul with our sample_key | ||
// At this point, the repo should have populated consul with our sample_key | ||
consul_utils.validateValue(repo_name + '/master/' + sample_key, sample_value, function(err, value) { | ||
@@ -48,3 +48,3 @@ if (err) return done(err); | ||
it ('should handle creating a git_manager tracking multiple branches', function(done) { | ||
it ('should handle creating a repo tracking multiple branches', function(done) { | ||
var branches = ['dev', 'test', 'prod']; | ||
@@ -66,3 +66,4 @@ var config = git_utils.createConfig(); | ||
if (branch_tests.length === 0) { | ||
git_manager.manageRepo(config, repo_config, function(err, gm) { | ||
var repo = new Repo(repo_config); | ||
repo.init(function(err) { | ||
if (err) return done(err); | ||
@@ -98,3 +99,3 @@ done(); | ||
it ('should handle creating a git_manager around a repo that already exists', function(done) { | ||
var default_config = git_utils.createConfig(); | ||
var repo_config = git_utils.createRepoConfig(); | ||
@@ -108,6 +109,7 @@ var sample_key = 'sample_key'; | ||
// Now we create another git_manager around the same repo with the same local address. This tells | ||
// Now we create another repo around the same repo with the same local address. This tells | ||
// us that a git_manager can be created around an existing repo without issue. | ||
git_manager.manageRepo(default_config, default_config.repos[0], function(err, gm) { | ||
(err === null).should.equal(true); | ||
var repo = new Repo(repo_config); | ||
repo.init(function(err) { | ||
if (err) return done(err); | ||
done(); | ||
@@ -117,9 +119,5 @@ }); | ||
}); | ||
/** | ||
it ('should handle creating a git_manager around a repo that has been emptied', function(done) { | ||
var repo_name = git_utils.GM.getRepoName(); | ||
var default_config = git_utils.createConfig(); | ||
var default_repo_config = default_config.repos[0]; | ||
default_repo_config.name = repo_name; | ||
git_manager.clearGitManagers(); | ||
var repo_config = git_utils.createRepoConfig(); | ||
@@ -131,6 +129,7 @@ // This addFileToGitRepo will automatically create a git_manager in git_utils, so once the callback | ||
// Now we create another git_manager around the same repo with the same local address. This tells | ||
// us that a git_manager can be created around an existing repo without issue. | ||
git_manager.manageRepo(default_config, default_repo_config, function(err, gm) { | ||
(err === null).should.equal(true); | ||
// Now we create another repo around the same repo with the same local address. This tells | ||
// us that a git_manager can be created around an emptied repo without issue. | ||
var repo = new Repo(repo_config); | ||
repo.init(function(err) { | ||
if (err) return done(err); | ||
done(); | ||
@@ -142,3 +141,3 @@ }); | ||
it ('should handle populating consul when you create a git_manager around a repo that is already on disk', function(done) { | ||
var repo_name = git_utils.GM.getRepoName(); | ||
var repo_name = git_utils.repo.name; | ||
var default_config = git_utils.createConfig(); | ||
@@ -213,2 +212,3 @@ var default_repo_config = default_config.repos[0]; | ||
}); | ||
**/ | ||
}); |
@@ -7,7 +7,6 @@ var should = require('should'); | ||
var git_manager = require('../lib/git_manager.js'); | ||
var git_utils = require('./utils/git_utils.js'); | ||
var consul_utils = require('./utils/consul_utils.js'); | ||
var git_commands = require('../lib/utils/git_commands.js'); | ||
var git_commands = require('../lib/git/commands.js'); | ||
@@ -20,3 +19,3 @@ describe('Key names', function() { | ||
return function(done) { | ||
var repo_name = git_utils.GM.getRepoName(); | ||
var repo_name = git_utils.repo.name; | ||
git_utils.addFileToGitRepo(key_name, key_value, key_name + " key name test.", function(err) { | ||
@@ -23,0 +22,0 @@ if (err) return done(err); |
@@ -10,6 +10,6 @@ var should = require('should'); | ||
var git_manager = require('../lib/git_manager.js'); | ||
var Repo = require('../lib/git/repo.js'); | ||
var git_utils = require('./utils/git_utils.js'); | ||
var logger = require('../lib/utils/logging.js'); | ||
var logger = require('../lib/logging.js'); | ||
@@ -51,6 +51,7 @@ /** | ||
it ('should reject invalid webhook config', function(done) { | ||
var config = git_utils.createConfig(); | ||
config.repos[0].hooks = hook_config; | ||
var repo_config = git_utils.createRepoConfig(); | ||
repo_config.hooks = hook_config; | ||
git_manager.manageRepo(config, config.repos[0], function(err, gm) { | ||
var repo = new Repo(repo_config); | ||
repo.init(function(err) { | ||
if (hook_config[0]) { | ||
@@ -151,8 +152,8 @@ err[0].should.equal(hook_config[0].err); | ||
var config = git_utils.createConfig(); | ||
config.repos[0].hooks = hook_config; | ||
config.repos[0].name = "webhook_test" + repo_counter; | ||
var repo_config = git_utils.createRepoConfig(); | ||
repo_config.hooks = hook_config; | ||
repo_config.name = "webhook_test" + repo_counter; | ||
++repo_counter; | ||
git_utils.initRepo(config, config.repos[0], function(err, gm) { | ||
git_utils.initRepo(repo_config, function(err, gm) { | ||
if (err) return done(err); | ||
@@ -171,3 +172,3 @@ done(); | ||
return function(done) { | ||
var repo_name = git_utils.GM.getRepoName(); | ||
var repo_name = git_utils.repo.name; | ||
var sample_key = 'sample_key'; | ||
@@ -227,6 +228,7 @@ var sample_value = 'stash test data ' + sample_data_randomizer; | ||
it ('should reject invalid polling config', function(done) { | ||
var config = git_utils.createConfig(); | ||
config.repos[0].hooks = hook_config; | ||
var repo_config = git_utils.createRepoConfig(); | ||
repo_config.hooks = hook_config; | ||
git_manager.manageRepo(config, config.repos[0], function(err, gm) { | ||
var repo = new Repo(repo_config); | ||
repo.init(function(err) { | ||
if (hook_config[0]) { | ||
@@ -250,3 +252,3 @@ err[0].should.equal('Hook configuration failed due to Polling intervals must be positive integers'); | ||
bootstrap.manual_mode(true); | ||
git_manager.mock(); | ||
process.env.MOCK = true; | ||
@@ -257,10 +259,10 @@ bootstrap.cleanup(function(err) { | ||
var config = git_utils.createConfig(); | ||
config.repos[0].hooks = [{ | ||
var repo_config = git_utils.createRepoConfig(); | ||
repo_config.hooks = [{ | ||
'type': 'polling', | ||
'interval': '1' | ||
}]; | ||
config.repos[0].name = "polling_test"; | ||
repo_config.name = "polling_test"; | ||
git_utils.initRepo(config, config.repos[0], function(err, gm) { | ||
git_utils.initRepo(repo_config, function(err, gm) { | ||
if (err) return done(err); | ||
@@ -274,3 +276,3 @@ done(); | ||
it ('should handle polling updates', function(done) { | ||
var repo_name = git_utils.GM.getRepoName(); | ||
var repo_name = git_utils.repo.name; | ||
var sample_key = 'sample_key'; | ||
@@ -288,1 +290,2 @@ var sample_value = 'stash test data'; | ||
}); | ||
@@ -5,3 +5,3 @@ var should = require('should'); | ||
var logger = require('../../lib/utils/logging.js'); | ||
var logger = require('../../lib/logging.js'); | ||
@@ -8,0 +8,0 @@ exports.getValue = function(key, cb) { |
var fs = require('fs'); | ||
var git_commands = require('../../lib/utils/git_commands.js'); | ||
var git_manager = require('../../lib/git_manager.js'); | ||
var git_commands = require('../../lib/git/commands.js'); | ||
var Repo = require('../../lib/git/repo.js'); | ||
@@ -25,2 +25,3 @@ exports.TEST_REMOTE_REPO = '/tmp/test_repo/'; | ||
return { | ||
local_store: exports.TEST_WORKING_DIR, | ||
name: 'test_repo' + repo_counter, | ||
@@ -32,8 +33,7 @@ url: 'file://' + exports.TEST_REMOTE_REPO, | ||
exports.initRepo = function(config, repo_config, cb) { | ||
exports.initRepo = function(repo_config, cb) { | ||
if (!cb) { | ||
cb = config; | ||
config = exports.createConfig(); | ||
repo_config = config.repos[0]; | ||
cb = repo_config; | ||
repo_config = exports.createRepoConfig(); | ||
} | ||
@@ -46,6 +46,7 @@ | ||
git_manager.manageRepo(config, repo_config, function(err, gm) { | ||
repo_config.local_store = exports.TEST_WORKING_DIR; | ||
exports.repo = new Repo(repo_config); | ||
exports.repo.init(function(err) { | ||
if (err) return cb(err); | ||
exports.GM = gm; | ||
cb(null); | ||
@@ -74,3 +75,3 @@ }); | ||
if (update) { | ||
exports.GM.getBranchManager('master').handleRefChange(0, function(err) { | ||
exports.repo.branches['master'].handleRefChange(0, function(err) { | ||
if (err) return cb(err); | ||
@@ -101,3 +102,3 @@ cb(); | ||
if (update) { | ||
exports.GM.getBranchManager('master').handleRefChange(0, function(err) { | ||
exports.repo.branches['master'].handleRefChange(0, function(err) { | ||
if (err) return cb(err); | ||
@@ -126,3 +127,3 @@ cb(); | ||
if (update) { | ||
exports.GM.getBranchManager('master').handleRefChange(0, function(err) { | ||
exports.repo.branches['master'].handleRefChange(0, function(err) { | ||
if (err) return cb(err); | ||
@@ -160,3 +161,3 @@ cb(); | ||
if (update) { | ||
exports.GM.getBranchManager('master').handleRefChange(0, function(err) { | ||
exports.repo.branches['master'].handleRefChange(0, function(err) { | ||
if (err) return cb(err); | ||
@@ -163,0 +164,0 @@ cb(); |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
32
90828
8
2037
25
2
+ Addedcoveralls@^2.11.2
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedargparse@1.0.10(transitive)
+ Addedasn1@0.2.6(transitive)
+ Addedassert-plus@0.2.01.0.0(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaws-sign2@0.6.0(transitive)
+ Addedaws4@1.13.2(transitive)
+ Addedbcrypt-pbkdf@1.0.2(transitive)
+ Addedboom@2.10.1(transitive)
+ Addedcaseless@0.11.0(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedcore-util-is@1.0.2(transitive)
+ Addedcoveralls@2.13.3(transitive)
+ Addedcryptiles@2.0.5(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedecc-jsbn@0.1.2(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedesprima@2.7.3(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedforever-agent@0.6.1(transitive)
+ Addedform-data@2.1.4(transitive)
+ Addedgenerate-function@2.3.1(transitive)
+ Addedgenerate-object-property@1.2.0(transitive)
+ Addedgetpass@0.1.7(transitive)
+ Addedhar-validator@2.0.6(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedhawk@3.1.3(transitive)
+ Addedhoek@2.16.3(transitive)
+ Addedhttp-signature@1.1.1(transitive)
+ Addedis-my-ip-valid@1.0.1(transitive)
+ Addedis-my-json-valid@2.20.6(transitive)
+ Addedis-property@1.0.2(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedjs-yaml@3.6.1(transitive)
+ Addedjsbn@0.1.1(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedjsonpointer@5.0.1(transitive)
+ Addedjsprim@1.4.2(transitive)
+ Addedlcov-parse@0.0.10(transitive)
+ Addedlog-driver@1.2.5(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedminimist@1.2.0(transitive)
+ Addedoauth-sign@0.8.2(transitive)
+ Addedpinkie@2.0.4(transitive)
+ Addedpinkie-promise@2.0.1(transitive)
+ Addedpunycode@1.4.1(transitive)
+ Addedqs@6.3.3(transitive)
+ Addedrequest@2.79.0(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsntp@1.0.9(transitive)
+ Addedsprintf-js@1.0.3(transitive)
+ Addedsshpk@1.18.0(transitive)
+ Addedstringstream@0.0.6(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.0(transitive)
+ Addedtough-cookie@2.3.4(transitive)
+ Addedtunnel-agent@0.4.3(transitive)
+ Addedtweetnacl@0.14.5(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedverror@1.10.0(transitive)
+ Addedxtend@4.0.2(transitive)