From e20d596429491e14924689522cfce82f08211f29 Mon Sep 17 00:00:00 2001 From: youreddy Date: Thu, 17 Oct 2024 22:26:18 -0700 Subject: [PATCH] add support for consul admin partition query param --- README.md | 1 + lib/constants.js | 1 + lib/consul.d.ts | 1 + lib/utils.js | 1 + test/utils.js | 2 ++ 5 files changed, 6 insertions(+) diff --git a/README.md b/README.md index bbd9d39..14aa970 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ const consul = new Consul(); These options can be included with any method call, although only certain endpoints support them. See the [HTTP API][consul-docs-api] for more information. - dc (String, optional): datacenter (defaults to local for agent) +- partition (String, optional): partition (defaults to 'default' partition) - wan (Boolean, default: false): return WAN members instead of LAN members - consistent (Boolean, default: false): require strong consistency - stale (Boolean, default: false): use whatever is available, can be arbitrarily stale diff --git a/lib/constants.js b/lib/constants.js index f1895a0..5a1009b 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -1,6 +1,7 @@ exports.DEFAULT_OPTIONS = [ "consistent", "dc", + "partition", "stale", "timeout", "token", diff --git a/lib/consul.d.ts b/lib/consul.d.ts index f8b1f7b..cb1b9fa 100644 --- a/lib/consul.d.ts +++ b/lib/consul.d.ts @@ -18,6 +18,7 @@ export interface CommonOptions { interface DefaultOptions extends CommonOptions { dc?: string; + partition?: string; wan?: boolean; consistent?: boolean; stale?: boolean; diff --git a/lib/utils.js b/lib/utils.js index 54fb3ed..3f0c822 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -178,6 +178,7 @@ function options(req, opts, ignore) { if (!req.query) req.query = {}; if (opts.dc && !ignore.dc) req.query.dc = opts.dc; + if (opts.partition && !ignore.partition) req.query.partition = opts.partition; if (opts.wan && !ignore.wan) req.query.wan = "1"; if (opts.consistent && !ignore.consistent) { diff --git a/test/utils.js b/test/utils.js index 7afa6ba..d21bebf 100644 --- a/test/utils.js +++ b/test/utils.js @@ -149,6 +149,7 @@ describe("utils", function () { should( test({ dc: "dc1", + partition: "partition1", wan: true, consistent: true, index: 10, @@ -166,6 +167,7 @@ describe("utils", function () { }, query: { dc: "dc1", + partition: "partition1", wan: "1", consistent: "1", index: 10,