git2consul
Advanced tools
Comparing version 0.9.0 to 0.10.0
@@ -36,4 +36,6 @@ var _ = require('underscore'); | ||
var create_key_name = function(branch, file, ref) { | ||
// Start with repo name so that the subtree is properly namespaced in Consul | ||
// Add repo name so that the subtree is properly namespaced in Consul | ||
var key_parts = [branch.repo_name]; | ||
if (branch.mountpoint) key_parts.unshift(branch.mountpoint); | ||
// Optionally add the branch name | ||
@@ -40,0 +42,0 @@ if (branch.include_branch_name && !ref) { |
@@ -23,2 +23,3 @@ var fs = require('fs'); | ||
}); | ||
Object.defineProperty(this, 'mountpoint', {value: repo_config['mountpoint'] }); | ||
@@ -25,0 +26,0 @@ // Writable properties |
@@ -37,2 +37,8 @@ var _ = require('underscore'); | ||
if (repo_config.mountpoint) { | ||
if (repo_config.mountpoint[0] === '/' || repo_config.mountpoint[repo_config.mountpoint.length - 1] === '/') { | ||
throw new Error("mountpoint must not start or end with /."); | ||
} | ||
} | ||
// Check to make sure local_store is valid and writeable. | ||
@@ -39,0 +45,0 @@ utils.validate_writeable_directory(repo_config.local_store); |
{ | ||
"name": "git2consul", | ||
"description": "System for moving data from git to consul", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"contributors": [ | ||
@@ -6,0 +6,0 @@ { |
@@ -93,2 +93,3 @@ #### git2consul | ||
"include_branch_name" : false, | ||
"mountpoint": "/nested/root/for/keys", | ||
"branches" : ["development", "staging", "production"], | ||
@@ -118,3 +119,3 @@ "hooks": [{ | ||
The above example illustrates a 2 repo git2consul setup: one repo lives in an on-premises Git solution and the other is hosted at github. The hooks array under each repository defines how git2consul will be notified of changes. git2consul supports [Atlassian Stash](https://confluence.atlassian.com/display/STASH/POST+service+webhook+for+Stash), [Atlassian Bitbucket](https://confluence.atlassian.com/display/BITBUCKET/POST+hook+management), [GitHub](https://developer.github.com/v3/repos/hooks/), and [Gitlab](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/web_hooks/web_hooks.md) webhooks as well as a basic polling model. | ||
The above example illustrates a 2 repo git2consul setup: one repo lives in an on-premises Git solution and the other is hosted at Github. The hooks array under each repository defines how git2consul will be notified of changes. git2consul supports [Atlassian Stash](https://confluence.atlassian.com/display/STASH/POST+service+webhook+for+Stash), [Atlassian Bitbucket](https://confluence.atlassian.com/display/BITBUCKET/POST+hook+management), [GitHub](https://developer.github.com/v3/repos/hooks/), and [Gitlab](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/web_hooks/web_hooks.md) webhooks as well as a basic polling model. | ||
@@ -175,2 +176,14 @@ Note that multiple webhooks can share the same port. The only constraint is that webhooks for different repos do not share the same port and path. | ||
##### Options | ||
###### include_branch_name (default: true) | ||
`include_branch_name` is a repo-level option instructing git2consul to use the branch name as part of the key prefix. Setting this option to false will omit the branch name. | ||
###### mountpoint (default: undefined) | ||
A `mountpoint` is a repo-level option instructing git2consul to prepend a string to the key name. By default, git2consul creates keys at the root of the KV store with the repo name being a top-level key. By setting a mountpoint, you define a prefix of arbitrary depth that will serve as the root for your key names. When building the key name, git2consul will concatenate mountpoint, repo name, branch name (assuming `include_branch_name` is true), and the path of the file in your git repo. | ||
*Note*: mountpoints can neither begin or end in with the character '/'. git2consul will reject your repo config if that's the case. | ||
##### Clients | ||
@@ -177,0 +190,0 @@ |
@@ -71,2 +71,20 @@ var _ = require('underscore'); | ||
it ('should reject a repo with a bogus mountpoint', function() { | ||
try { | ||
var repo = new Repo({'name': 'busted_mountpoint_repo', 'url': 'http://www.github.com/', | ||
'local_store':'/tmp/', 'branches': ['master'], 'mountpoint': '/oops'}); | ||
should.fail("mountpoint must not start or end with /."); | ||
} catch(e) { | ||
e.message.should.equal('mountpoint must not start or end with /.'); | ||
} | ||
try { | ||
var repo = new Repo({'name': 'busted_mountpoint_repo', 'url': 'http://www.github.com/', | ||
'local_store':'/tmp/', 'branches': ['master'], 'mountpoint': 'oops/'}); | ||
should.fail("mountpoint must not start or end with /."); | ||
} catch(e) { | ||
e.message.should.equal('mountpoint must not start or end with /.'); | ||
} | ||
}); | ||
it ('should reject a repo with a non-existent local_store', function() { | ||
@@ -73,0 +91,0 @@ try { |
Sorry, the diff of this file is not supported yet
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
2696
207
1
137131
45