diff --git a/plugins/catalog-backend-module-puppetdb/config.d.ts b/plugins/catalog-backend-module-puppetdb/config.d.ts index dc48695f04..e890584f41 100644 --- a/plugins/catalog-backend-module-puppetdb/config.d.ts +++ b/plugins/catalog-backend-module-puppetdb/config.d.ts @@ -31,25 +31,38 @@ export interface Config { /** * PuppetDB Entity Provider configuration. Uses "default" as default ID for the single config variant. */ - puppetdb?: ProviderConfig | Record; + puppetdb?: + | { + /** + * (Required) The host of PuppetDB API instance. + */ + host: string; + /** + * (Optional) PQL query to filter PuppetDB nodes. + */ + query?: string; + /** + * (Optional) Task schedule definition for the refresh. + */ + schedule?: TaskScheduleDefinition; + } + | Record< + string, + { + /** + * (Required) The host of PuppetDB API instance. + */ + host: string; + /** + * (Optional) PQL query to filter PuppetDB nodes. + */ + query?: string; + /** + * (Optional) Task schedule definition for the refresh. + */ + schedule?: TaskScheduleDefinition; + } + >; }; }; } - -/** - * Configuration of {@link PuppetDbEntityProvider}. - */ -interface ProviderConfig { - /** - * (Required) The host of PuppetDB API instance. - */ - host: string; - /** - * (Optional) PQL query to filter PuppetDB nodes. - */ - query?: string; - /** - * (Optional) Task schedule definition for the refresh. - */ - schedule?: TaskScheduleDefinition; -} diff --git a/plugins/catalog-backend-module-puppetdb/src/providers/PuppetDbEntityProvider.ts b/plugins/catalog-backend-module-puppetdb/src/providers/PuppetDbEntityProvider.ts index 5246c3373d..a3ac4b140e 100644 --- a/plugins/catalog-backend-module-puppetdb/src/providers/PuppetDbEntityProvider.ts +++ b/plugins/catalog-backend-module-puppetdb/src/providers/PuppetDbEntityProvider.ts @@ -192,15 +192,14 @@ export class PuppetDbEntityProvider implements EntityProvider { * @returns Entity with @{@link ANNOTATION_LOCATION} and @{@link ANNOTATION_ORIGIN_LOCATION} annotations. */ function withLocations(host: string, entity: Entity): Entity { - const location = new URL(host); - location.pathname = `${ENDPOINT_NODES}/${entity.metadata?.name}`; + const location = `${host}/${ENDPOINT_NODES}/${entity.metadata?.name}`; return merge( { metadata: { annotations: { - [ANNOTATION_LOCATION]: `url:${location.toString()}`, - [ANNOTATION_ORIGIN_LOCATION]: `url:${location.toString()}`, + [ANNOTATION_LOCATION]: `url:${location}`, + [ANNOTATION_ORIGIN_LOCATION]: `url:${location}`, }, }, }, diff --git a/plugins/catalog-backend-module-puppetdb/src/puppet/read.ts b/plugins/catalog-backend-module-puppetdb/src/puppet/read.ts index 8ecbb63d91..bbd7843ecc 100644 --- a/plugins/catalog-backend-module-puppetdb/src/puppet/read.ts +++ b/plugins/catalog-backend-module-puppetdb/src/puppet/read.ts @@ -44,9 +44,7 @@ export async function readPuppetNodes( } if (opts?.logger) { - opts.logger - .child({ url: url.toString() }) - .debug('Reading nodes from PuppetDB'); + opts.logger.debug('Reading nodes from PuppetDB', { url: url.toString() }); } const response = await fetch(url.toString(), { diff --git a/plugins/catalog-backend-module-puppetdb/src/puppet/transformers.ts b/plugins/catalog-backend-module-puppetdb/src/puppet/transformers.ts index 2062f8e828..9ec607b83e 100644 --- a/plugins/catalog-backend-module-puppetdb/src/puppet/transformers.ts +++ b/plugins/catalog-backend-module-puppetdb/src/puppet/transformers.ts @@ -32,13 +32,13 @@ export const defaultResourceTransformer: ResourceTransformer = async ( node, _config, ): Promise => { - const certName = node.certname.toLowerCase(); + const certName = node.certname.toLocaleLowerCase('en-US'); const type = node.facts?.data?.find(e => e.name === 'is_virtual')?.value ? 'virtual-machine' : 'physical-server'; const kernel = node.facts?.data?.find(e => e.name === 'kernel')?.value; - const entity: ResourceEntity = { + return { apiVersion: 'backstage.io/v1beta1', kind: 'Resource', metadata: { @@ -50,7 +50,7 @@ export const defaultResourceTransformer: ResourceTransformer = async ( description: node.facts?.data ?.find(e => e.name === 'ipaddress') ?.value?.toString(), - tags: kernel ? [kernel.toString().toLowerCase()] : [], + tags: kernel ? [kernel.toString().toLocaleLowerCase('en-US')] : [], }, spec: { type: type, @@ -59,6 +59,4 @@ export const defaultResourceTransformer: ResourceTransformer = async ( dependencyOf: [], }, }; - - return entity; }; diff --git a/plugins/catalog-backend-module-puppetdb/src/puppet/types.ts b/plugins/catalog-backend-module-puppetdb/src/puppet/types.ts index f71ba299bd..5bfac5c998 100644 --- a/plugins/catalog-backend-module-puppetdb/src/puppet/types.ts +++ b/plugins/catalog-backend-module-puppetdb/src/puppet/types.ts @@ -96,7 +96,7 @@ export type PuppetFact = { */ name: string; /** - * The value of the fact, in JSON format. + * The value of the fact. */ value: JsonValue; }; diff --git a/yarn.lock b/yarn.lock index 7b71cdff35..2b88e6ce8c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -30043,6 +30043,40 @@ __metadata: languageName: node linkType: hard +"msw@npm:^0.49.0": + version: 0.49.3 + resolution: "msw@npm:0.49.3" + dependencies: + "@mswjs/cookies": ^0.2.2 + "@mswjs/interceptors": ^0.17.5 + "@open-draft/until": ^1.0.3 + "@types/cookie": ^0.4.1 + "@types/js-levenshtein": ^1.1.1 + chalk: 4.1.1 + chokidar: ^3.4.2 + cookie: ^0.4.2 + graphql: ^15.0.0 || ^16.0.0 + headers-polyfill: ^3.1.0 + inquirer: ^8.2.0 + is-node-process: ^1.0.1 + js-levenshtein: ^1.1.6 + node-fetch: ^2.6.7 + outvariant: ^1.3.0 + path-to-regexp: ^6.2.0 + strict-event-emitter: ^0.4.3 + type-fest: ^2.19.0 + yargs: ^17.3.1 + peerDependencies: + typescript: ">= 4.4.x <= 4.9.x" + peerDependenciesMeta: + typescript: + optional: true + bin: + msw: cli/index.js + checksum: 8322cd42cd69f289c05517d02bde22fc2f10e86fc2d0d209d9df54bd03d10b8123723c5587a2654dcd2cd0f314a016f9eccac88cffa30fafd1f9fead16db639e + languageName: node + linkType: hard + "msw@npm:^1.0.0, msw@npm:^1.0.1": version: 1.0.1 resolution: "msw@npm:1.0.1"