Skip to content

Commit

Permalink
Added missing CheckID, Name & Notes check parameters (#160)
Browse files Browse the repository at this point in the history
Co-authored-by: Ruben van der Heyde <[email protected]>
  • Loading branch information
CogitoGroupDevTeam and Ruben van der Heyde authored Oct 21, 2024
1 parent 7f61af5 commit 00bd8c6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/agent/check.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type ListResult = Record<string, Check>;

export interface CheckOptions {
name: string;
id?: string;
checkid?: string;
serviceid?: string;
http?: string;
body?: string;
Expand Down
9 changes: 4 additions & 5 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,13 @@ function _createTaggedAddresses(src) {
/**
* Create node/server-level check object
* Corresponds to CheckType in Consul Agent Endpoint:
* https://github.com/hashicorp/consul/blob/master/command/agent/check.go#L43
* Corresponds to AgentServiceCheck in Consul Go API (which currently omits Notes):
* https://github.com/hashicorp/consul/blob/master/api/agent.go#L66
* Currently omits ID and Name fields:
* https://github.com/hashicorp/consul/issues/2223
* https://developer.hashicorp.com/consul/docs/services/usage/checks
*/
function _createServiceCheck(src) {
const dst = {};
if (src.hasOwnProperty("checkid")) dst.CheckID = src.checkid;
if (src.hasOwnProperty("name")) dst.Name = src.name;
if (src.hasOwnProperty("notes")) dst.Notes = src.notes;

if (
(src.grpc ||
Expand Down
12 changes: 12 additions & 0 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,12 @@ describe("utils", function () {
name: "service",
checks: [
{ ttl: "10s" },
{
ttl: "10s",
name: "service-check-name-1",
checkid: "service-check-id-1",
notes: "service-check-notes-1",
},
{ http: "http://127.0.0.1:8000", interval: "60s" },
],
}),
Expand All @@ -818,6 +824,12 @@ describe("utils", function () {
Name: "service",
Checks: [
{ TTL: "10s" },
{
TTL: "10s",
Name: "service-check-name-1",
CheckID: "service-check-id-1",
Notes: "service-check-notes-1",
},
{ HTTP: "http://127.0.0.1:8000", Interval: "60s" },
],
});
Expand Down

0 comments on commit 00bd8c6

Please sign in to comment.