From f20c4563689465f42c44ecaa826448af71e8d166 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 16 Nov 2024 02:17:42 +0000 Subject: [PATCH 1/2] build(deps): bump consul from 1.2.0 to 2.0.1 Bumps [consul](https://github.com/silas/node-consul) from 1.2.0 to 2.0.1. - [Release notes](https://github.com/silas/node-consul/releases) - [Commits](https://github.com/silas/node-consul/compare/1.2.0...2.0.1) --- updated-dependencies: - dependency-name: consul dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- package-lock.json | 23 ++++++++++++++++++----- package.json | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index de23b032e..3400be2f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@open-amt-cloud-toolkit/wsman-messages": "^5.6.10", "body-parser": "^1.20.2", - "consul": "^1.2.0", + "consul": "^2.0.1", "cors": "^2.8.5", "crypto-random-string": "^3.3.1", "exponential-backoff": "^3.1.1", @@ -2948,11 +2948,12 @@ } }, "node_modules/consul": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/consul/-/consul-1.2.0.tgz", - "integrity": "sha512-xWMEDRszShfzKI7XQKq12gr3359VUHUFOrAC2ETNpNe8PFO6AUnY0sbscB7JW5WhUEfuveDcI5ScYqM//20bow==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/consul/-/consul-2.0.1.tgz", + "integrity": "sha512-91ExUUelOJ1yyB0etYAR0w1p6Ues1VosEyBVxPcWJdnQDTKqAEFzL0MHfOqZWYI2d4HZ4FgotHZkAPW2A/xahA==", "dependencies": { - "papi": "^1.1.0" + "papi": "^1.1.0", + "uuid": "^10.0.0" } }, "node_modules/content-disposition": { @@ -7954,6 +7955,18 @@ "node": ">= 0.4.0" } }, + "node_modules/uuid": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz", + "integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/v8-compile-cache-lib": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", diff --git a/package.json b/package.json index fe9ccd71c..6ceb1bb6c 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "dependencies": { "@open-amt-cloud-toolkit/wsman-messages": "^5.6.10", "body-parser": "^1.20.2", - "consul": "^1.2.0", + "consul": "^2.0.1", "cors": "^2.8.5", "crypto-random-string": "^3.3.1", "exponential-backoff": "^3.1.1", From d1b37b685f1f00930b2a2453968b6fa6504330e0 Mon Sep 17 00:00:00 2001 From: Mike Date: Mon, 16 Dec 2024 12:51:43 -0700 Subject: [PATCH 2/2] refactor: move to consul v2 --- src/Index.ts | 2 +- src/consulService.test.ts | 4 ++-- src/consulService.ts | 4 ++-- src/serviceManager.test.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Index.ts b/src/Index.ts index 5ee239690..43aeaf084 100644 --- a/src/Index.ts +++ b/src/Index.ts @@ -130,7 +130,7 @@ export const startItUp = (): void => { } export async function setupServiceManager(config: RPSConfig): Promise { - const consul: IServiceManager = new ConsulService(config.consul_host, config.consul_port) + const consul: IServiceManager = new ConsulService(config.consul_host, parseInt(config.consul_port, 10)) await waitForServiceManager(consul, 'consul') await processServiceConfigs(consul, config) } diff --git a/src/consulService.test.ts b/src/consulService.test.ts index 86e32f6a3..33decdd35 100644 --- a/src/consulService.test.ts +++ b/src/consulService.test.ts @@ -13,7 +13,7 @@ let serviceName: string let consul: ConsulService describe('consul', () => { beforeEach(() => { - consul = new ConsulService('localhost', '8500') + consul = new ConsulService('localhost', 8500) jest.clearAllMocks() jest.restoreAllMocks() @@ -41,7 +41,7 @@ describe('consul', () => { expect(consul.consul.kv.set).toHaveBeenCalledWith(componentName + '/config', JSON.stringify(config, null, 2)) }) it('seed Consul failure', async () => { - consul.consul.kv.set = spyOn(consul.consul.kv, 'set').mockResolvedValue(Promise.reject(new Error())) as any + consul.consul.kv.set = spyOn(consul.consul.kv, 'set').mockRejectedValue(new Error()) as any const result = await consul.seed(componentName, config) expect(result).toBe(false) }) diff --git a/src/consulService.ts b/src/consulService.ts index e6b839044..d180e2110 100644 --- a/src/consulService.ts +++ b/src/consulService.ts @@ -10,9 +10,9 @@ import type { IServiceManager } from './interfaces/IServiceManager.js' import { Environment } from './utils/Environment.js' export class ConsulService implements IServiceManager { - consul: Consul.Consul + consul: Consul log = new Logger('ConsulService') - constructor(host: string, port: string) { + constructor(host: string, port: number) { this.consul = new Consul({ host, port, diff --git a/src/serviceManager.test.ts b/src/serviceManager.test.ts index 93deb447f..ace9b7dbe 100644 --- a/src/serviceManager.test.ts +++ b/src/serviceManager.test.ts @@ -11,7 +11,7 @@ import { jest } from '@jest/globals' const { processServiceConfigs, waitForServiceManager } = await import('./serviceManager.js') -const consul: IServiceManager = new ConsulService('consul', '8500') +const consul: IServiceManager = new ConsulService('consul', 8500) let componentName: string let config: any