Address review
Signed-off-by: Tomas Dabasinskas <tomas@dabasinskas.net>
This commit is contained in:
+32
-19
@@ -31,25 +31,38 @@ export interface Config {
|
||||
/**
|
||||
* PuppetDB Entity Provider configuration. Uses "default" as default ID for the single config variant.
|
||||
*/
|
||||
puppetdb?: ProviderConfig | Record<string, ProviderConfig>;
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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}`,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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(), {
|
||||
|
||||
@@ -32,13 +32,13 @@ export const defaultResourceTransformer: ResourceTransformer = async (
|
||||
node,
|
||||
_config,
|
||||
): Promise<ResourceEntity | undefined> => {
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -96,7 +96,7 @@ export type PuppetFact = {
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* The value of the fact, in JSON format.
|
||||
* The value of the fact.
|
||||
*/
|
||||
value: JsonValue;
|
||||
};
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user