git2consul
Advanced tools
Comparing version 0.12.1 to 0.12.2
@@ -1,1 +0,1 @@ | ||
["172.17.6.204:8300"] | ||
["172.17.4.199:8300"] |
@@ -239,3 +239,5 @@ var _ = require('underscore'); | ||
// If we have a source_root set but this file is not within source_root, skip it. | ||
if (branch.source_root && record.path.indexOf(branch.source_root) !== 0) return; | ||
if (branch.source_root && record.path.indexOf(branch.source_root) !== 0) { | ||
return check_pending(); | ||
}; | ||
@@ -248,2 +250,11 @@ switch (record.type) { | ||
// Store added/modified file | ||
if (record.path === branch.common_properties) { | ||
branch.listAdditionalPropertyFiles(records, function(err, additionRecords) { | ||
process_records(branch, additionRecords, function(errs) { | ||
if (errs) { | ||
return cb("Some consul updates failed:\n" + errs.join('\n')); | ||
} | ||
}); | ||
}); | ||
} | ||
++pending_records; | ||
@@ -306,3 +317,3 @@ file_modified(branch, record.path, check_pending); | ||
} | ||
// Note: This is a bit dangerous. We only update most recent ref is all consul writes are successful. | ||
// Note: This is a bit dangerous. We only update most recent ref if all consul writes are successful. | ||
// If there's a bug that causes a certain consul write to always fail, we will always create our diffs | ||
@@ -309,0 +320,0 @@ // from the ref before that file was added. |
@@ -25,2 +25,3 @@ var fs = require('fs'); | ||
Object.defineProperty(this, 'mountpoint', {value: repo_config['mountpoint'] }); | ||
if (repo_config['source_root'] && | ||
@@ -97,2 +98,6 @@ repo_config.source_root.length > 0 && | ||
Branch.prototype.listAdditionalPropertyFiles = function(modifiedRecords, cb) { | ||
git_commands.listAdditionalPropertyFiles(modifiedRecords, this.branch_directory, cb); | ||
}; | ||
Branch.prototype.getCurrentRef = function(cb) { | ||
@@ -99,0 +104,0 @@ git_commands.getCurrentRef(this.branch_directory, cb); |
@@ -121,4 +121,28 @@ var exec = require('child_process').exec; | ||
exports.listAdditionalPropertyFiles = function(modifiedRecords, cwd, cb) { | ||
function is_properties_not_modified(modifiedRecords, file) { | ||
return file.substr(file.lastIndexOf('.') + 1) == "properties" && modifiedRecords.filter(function(record) { | ||
return record.path == file; | ||
}).length <= 0; | ||
} | ||
run_command('git ls-tree --name-status -r HEAD', cwd, function(err, output) { | ||
/* istanbul ignore if */ | ||
if (err) return cb(err); | ||
var records = []; | ||
var files = output.split('\n'); | ||
files.forEach(function(file) { | ||
if(is_properties_not_modified(modifiedRecords, file)) { | ||
records.push({'type': 'M', 'path': file}); | ||
} | ||
}); | ||
cb(null, records); | ||
}); | ||
}; | ||
exports.getCurrentRef = function(cwd, cb) { | ||
run_command('git log -n 1 --pretty=format:"%H"', cwd, cb); | ||
}; |
@@ -73,4 +73,3 @@ var _ = require('underscore'); | ||
// Report the error to cb but also gracefully shutdown. | ||
exports.gracefulShutdown(); | ||
cb(err); | ||
exports.gracefulShutdown(cb(err)); | ||
}; | ||
@@ -77,0 +76,0 @@ |
{ | ||
"name": "git2consul", | ||
"description": "System for moving data from git to consul", | ||
"version": "0.12.1", | ||
"version": "0.12.2", | ||
"contributors": [ | ||
@@ -6,0 +6,0 @@ { |
@@ -18,2 +18,3 @@ ### git2consul | ||
* git2consul does most of its Git work by shelling out to git. Git must be installed and on your path. | ||
* Remote git repos must be world-readable or you need to use an ssh URL: git2consul has no mechanism to present HTTP credentials to git. | ||
* git2consul does the rest of its work by calling Consul's REST API. | ||
@@ -150,2 +151,10 @@ * git2consul requires write access to the KV store of its Consul agent. | ||
##### Alternate Config Locations | ||
By default, git2consul looks for its configuration at the Consul Key `git2consul/config`. You can override this with a `-c` of `--config_key` command line switch, like so: | ||
```sh | ||
node . -c git2consul/alternative_config | ||
``` | ||
##### No Daemon | ||
@@ -152,0 +161,0 @@ |
@@ -386,2 +386,45 @@ var should = require('should'); | ||
it('should update the dependent properties file if common is updated', function(done) { | ||
var common_file = 'common.properties'; | ||
var common_kv = 'bar=bar'; | ||
var sample_file = 'simple.properties'; | ||
var sample_kv = 'foo=${bar}'; | ||
var updated_common_kv = 'bar=bar_updated'; | ||
git_utils.addFileToGitRepo(common_file, common_kv, "Add a file.", function(err) { | ||
if (err) return done(err); | ||
branch.handleRefChange(0, function(err) { | ||
git_utils.addFileToGitRepo(sample_file, sample_kv, "Add a file.", function(err) { | ||
if (err) return done(err); | ||
branch.handleRefChange(0, function(err) { | ||
if (err) return done(err); | ||
consul_utils.validateValue('test_repo/master/simple.properties/foo', 'bar', function(err, value) { | ||
if (err) return done(err); | ||
git_utils.addFileToGitRepo(common_file, updated_common_kv, "Add a file.", function(err) { | ||
if (err) return done(err); | ||
branch.handleRefChange(0, function(err) { | ||
if (err) return done(err); | ||
consul_utils.validateValue('test_repo/master/simple.properties/foo', 'bar_updated', function(err, value) { | ||
if (err) return done(err); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
@@ -388,0 +431,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
28409166
61
3672
388