Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support new status option when registering checks #14

Merged
merged 1 commit into from
Sep 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ Options
* internal (String): interval to run check, requires script (ex: `15s`)
* ttl (String): time to live before check must be updated, instead of script and interval (ex: `60s`)
* notes (String, optional): human readable description of check
* status (String, optional): initial service status

Usage

Expand Down Expand Up @@ -629,6 +630,7 @@ Options
* internal (String): interval to run check, requires script (ex: `15s`)
* ttl (String): time to live before check must be updated, instead of script and interval (ex: `60s`)
* notes (String, optional): human readable description of check
* status (String, optional): initial service status

Usage

Expand Down
1 change: 1 addition & 0 deletions lib/agent/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ AgentCheck.prototype.register = function(opts, callback) {
errors.Validation('http or script and interval, or ttl required'), req));
}
if (opts.hasOwnProperty('notes')) req.body.Notes = opts.notes;
if (opts.hasOwnProperty('status')) req.body.Status = opts.status;

utils.options(req, opts);

Expand Down
1 change: 1 addition & 0 deletions lib/agent/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ AgentService.prototype.register = function(opts, callback) {
errors.Validation('http or script and interval, or ttl required'), req));
}
if (check.hasOwnProperty('notes')) req.body.Check.Notes = check.notes;
if (check.hasOwnProperty('status')) req.body.Check.Status = check.status;
}

utils.options(req, opts);
Expand Down
4 changes: 4 additions & 0 deletions test/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ describe('Agent', function() {
HTTP: 'http://example.org/',
Interval: '5s',
Notes: 'http check',
Status: 'critical',
})
.reply(200);

Expand All @@ -100,6 +101,7 @@ describe('Agent', function() {
http: 'http://example.org/',
interval: '5s',
notes: 'http check',
status: 'critical',
};

this.consul.agent.check.register(opts, function(err) {
Expand Down Expand Up @@ -410,6 +412,7 @@ describe('Agent', function() {
HTTP: 'http://example.org/',
Interval: '5s',
Notes: 'http service check',
Status: 'critical',
},
Address: '10.0.0.1',
Port: 80,
Expand All @@ -424,6 +427,7 @@ describe('Agent', function() {
http: 'http://example.org/',
interval: '5s',
notes: 'http service check',
status: 'critical',
},
address: '10.0.0.1',
port: 80,
Expand Down