@backstage/plugin-catalog-backend-module-puppetdb 0.1.15-next.1 → 0.1.15-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @backstage/plugin-catalog-backend-module-puppetdb
2
2
 
3
+ ## 0.1.15-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 9aac2b0: Use `--cwd` as the first `yarn` argument
8
+ - bc644fb: Added `latest_report_status` parameter from the PuppetDB node api and added it as a tag to the nodes. The status is valuable information as it displays which nodes are compliant to your configuration and which ones are failing are making changes.
9
+ - Updated dependencies
10
+ - @backstage/backend-common@0.21.0-next.2
11
+ - @backstage/backend-plugin-api@0.6.10-next.2
12
+ - @backstage/backend-tasks@0.5.15-next.2
13
+ - @backstage/plugin-catalog-node@1.6.2-next.2
14
+ - @backstage/config@1.1.1
15
+ - @backstage/catalog-model@1.4.4-next.0
16
+ - @backstage/errors@1.2.3
17
+ - @backstage/types@1.1.1
18
+
3
19
  ## 0.1.15-next.1
4
20
 
5
21
  ### Patch Changes
package/README.md CHANGED
@@ -12,7 +12,7 @@ to your backend package:
12
12
 
13
13
  ```bash
14
14
  # From your Backstage root directory
15
- yarn add --cwd packages/backend @backstage/plugin-catalog-backend-module-puppetdb
15
+ yarn --cwd packages/backend add @backstage/plugin-catalog-backend-module-puppetdb
16
16
  ```
17
17
 
18
18
  Update the catalog plugin initialization in your backend to add the provider and schedule it:
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-backend-module-puppetdb",
3
- "version": "0.1.15-next.1",
3
+ "version": "0.1.15-next.2",
4
4
  "main": "../dist/alpha.cjs.js",
5
5
  "types": "../dist/alpha.d.ts"
6
6
  }
package/dist/alpha.cjs.js CHANGED
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var backendPluginApi = require('@backstage/backend-plugin-api');
6
6
  var backendCommon = require('@backstage/backend-common');
7
7
  var alpha = require('@backstage/plugin-catalog-node/alpha');
8
- var PuppetDbEntityProvider = require('./cjs/PuppetDbEntityProvider-41a6e77d.cjs.js');
8
+ var PuppetDbEntityProvider = require('./cjs/PuppetDbEntityProvider-f784910b.cjs.js');
9
9
  require('@backstage/backend-tasks');
10
10
  require('uuid');
11
11
  require('@backstage/catalog-model');
@@ -68,6 +68,7 @@ const defaultResourceTransformer = async (node, _config) => {
68
68
  const certName = node.certname.toLocaleLowerCase("en-US");
69
69
  const type = ((_c = (_b = (_a = node.facts) == null ? void 0 : _a.data) == null ? void 0 : _b.find((e) => e.name === "is_virtual")) == null ? void 0 : _c.value) ? "virtual-machine" : "physical-server";
70
70
  const kernel = (_f = (_e = (_d = node.facts) == null ? void 0 : _d.data) == null ? void 0 : _e.find((e) => e.name === "kernel")) == null ? void 0 : _f.value;
71
+ const latest_report_status = node.latest_report_status;
71
72
  return {
72
73
  apiVersion: "backstage.io/v1beta1",
73
74
  kind: "Resource",
@@ -78,7 +79,10 @@ const defaultResourceTransformer = async (node, _config) => {
78
79
  },
79
80
  namespace: catalogModel.DEFAULT_NAMESPACE,
80
81
  description: (_j = (_i = (_h = (_g = node.facts) == null ? void 0 : _g.data) == null ? void 0 : _h.find((e) => e.name === "ipaddress")) == null ? void 0 : _i.value) == null ? void 0 : _j.toString(),
81
- tags: kernel ? [kernel.toString().toLocaleLowerCase("en-US")] : []
82
+ tags: kernel ? [
83
+ kernel.toString().toLocaleLowerCase("en-US"),
84
+ latest_report_status.toString().toLocaleLowerCase("en-US")
85
+ ] : []
82
86
  },
83
87
  spec: {
84
88
  type,
@@ -283,4 +287,4 @@ exports.ANNOTATION_PUPPET_CERTNAME = ANNOTATION_PUPPET_CERTNAME;
283
287
  exports.DEFAULT_PROVIDER_ID = DEFAULT_PROVIDER_ID;
284
288
  exports.PuppetDbEntityProvider = PuppetDbEntityProvider;
285
289
  exports.defaultResourceTransformer = defaultResourceTransformer;
286
- //# sourceMappingURL=PuppetDbEntityProvider-41a6e77d.cjs.js.map
290
+ //# sourceMappingURL=PuppetDbEntityProvider-f784910b.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PuppetDbEntityProvider-f784910b.cjs.js","sources":["../../src/providers/constants.ts","../../src/providers/PuppetDbEntityProviderConfig.ts","../../src/puppet/constants.ts","../../src/puppet/transformers.ts","../../src/puppet/read.ts","../../src/providers/PuppetDbEntityProvider.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Name of the default provider when a using a simple configuration.\n *\n * @public\n */\nexport const DEFAULT_PROVIDER_ID = 'default';\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n readTaskScheduleDefinitionFromConfig,\n TaskScheduleDefinition,\n} from '@backstage/backend-tasks';\nimport { Config } from '@backstage/config';\nimport { DEFAULT_PROVIDER_ID } from './constants';\n\n/**\n * Configuration of {@link PuppetDbEntityProvider}.\n *\n * @public\n */\nexport type PuppetDbEntityProviderConfig = {\n /**\n * ID of the provider.\n */\n id: string;\n /**\n * (Required) The base URL of PuppetDB API instance.\n */\n baseUrl: string;\n /**\n * (Optional) PQL query to filter PuppetDB nodes.\n */\n query?: string;\n /**\n * (Optional) Task schedule definition for the refresh.\n */\n schedule?: TaskScheduleDefinition;\n};\n\n/**\n * Reads the configuration of the PuppetDB Entity Providers.\n *\n * @param config - The application configuration.\n *\n * @returns PuppetDB Entity Provider configurations list.\n */\nexport function readProviderConfigs(\n config: Config,\n): PuppetDbEntityProviderConfig[] {\n const providersConfig = config.getOptionalConfig(\n 'catalog.providers.puppetdb',\n );\n if (!providersConfig) {\n return [];\n }\n\n if (providersConfig.has('baseUrl')) {\n return [readProviderConfig(DEFAULT_PROVIDER_ID, providersConfig)];\n }\n\n return providersConfig.keys().map(id => {\n return readProviderConfig(id, providersConfig.getConfig(id));\n });\n}\n\n/**\n * Reads the configuration for the PuppetDB Entity Provider.\n *\n * @param id - ID of the provider.\n * @param config - The application configuration.\n *\n * @returns The PuppetDB Entity Provider configuration.\n */\nfunction readProviderConfig(\n id: string,\n config: Config,\n): PuppetDbEntityProviderConfig {\n const baseUrl = config.getString('baseUrl').replace(/\\/+$/, '');\n const query = config.getOptionalString('query');\n\n const schedule = config.has('schedule')\n ? readTaskScheduleDefinitionFromConfig(config.getConfig('schedule'))\n : undefined;\n\n return {\n id,\n baseUrl,\n query,\n schedule,\n };\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Annotation for specifying the certificate name of a node in PuppetDB.\n *\n * @public\n */\nexport const ANNOTATION_PUPPET_CERTNAME = 'puppet.com/certname';\n\n/**\n * Path of PuppetDB FactSets endpoint.\n */\nexport const ENDPOINT_FACTSETS = 'pdb/query/v4/factsets';\n\n/**\n * Path of PuppetDB Nodes endpoint.\n */\nexport const ENDPOINT_NODES = 'pdb/query/v4/nodes';\n\n/**\n * Default owner for entities created by the PuppetDB provider.\n *\n * @public\n */\nexport const DEFAULT_ENTITY_OWNER = 'unknown';\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ResourceTransformer } from './types';\nimport { DEFAULT_NAMESPACE, ResourceEntity } from '@backstage/catalog-model';\nimport { ANNOTATION_PUPPET_CERTNAME, DEFAULT_ENTITY_OWNER } from './constants';\n\n/**\n * A default implementation of the {@link ResourceTransformer}.\n *\n * @param node - The found PuppetDB node entry in its source format. This is the entry that you want to transform.\n * @param _config - The configuration for the entity provider.\n *\n * @returns A `ResourceEntity`.\n *\n * @public\n */\nexport const defaultResourceTransformer: ResourceTransformer = async (\n node,\n _config,\n): Promise<ResourceEntity | undefined> => {\n const certName = node.certname.toLocaleLowerCase('en-US');\n const type = node.facts?.data?.find(e => e.name === 'is_virtual')?.value\n ? 'virtual-machine'\n : 'physical-server';\n const kernel = node.facts?.data?.find(e => e.name === 'kernel')?.value;\n const latest_report_status = node.latest_report_status;\n\n return {\n apiVersion: 'backstage.io/v1beta1',\n kind: 'Resource',\n metadata: {\n name: certName,\n annotations: {\n [ANNOTATION_PUPPET_CERTNAME]: certName,\n },\n namespace: DEFAULT_NAMESPACE,\n description: node.facts?.data\n ?.find(e => e.name === 'ipaddress')\n ?.value?.toString(),\n tags: kernel\n ? [\n kernel.toString().toLocaleLowerCase('en-US'),\n latest_report_status.toString().toLocaleLowerCase('en-US'),\n ]\n : [],\n },\n spec: {\n type: type,\n owner: DEFAULT_ENTITY_OWNER,\n dependsOn: [],\n dependencyOf: [],\n },\n };\n};\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { PuppetDbEntityProviderConfig } from '../providers';\nimport { PuppetNode, ResourceTransformer } from './types';\nimport { ResourceEntity } from '@backstage/catalog-model';\nimport { defaultResourceTransformer } from './transformers';\nimport fetch from 'node-fetch';\nimport { ResponseError } from '@backstage/errors';\nimport { ENDPOINT_FACTSETS } from './constants';\nimport { Logger } from 'winston';\n\n/**\n * Reads nodes and their facts from PuppetDB.\n *\n * @param config - The provider configuration.\n * @param opts - Additional options.\n */\nexport async function readPuppetNodes(\n config: PuppetDbEntityProviderConfig,\n opts?: {\n transformer?: ResourceTransformer;\n logger?: Logger;\n },\n): Promise<ResourceEntity[]> {\n const transformFn = opts?.transformer ?? defaultResourceTransformer;\n const url = new URL(ENDPOINT_FACTSETS, config.baseUrl);\n\n if (config.query) {\n url.searchParams.set('query', config.query);\n }\n\n if (opts?.logger) {\n opts.logger.debug('Reading nodes from PuppetDB', { url: url.toString() });\n }\n\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n },\n });\n\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n const nodes = (await response.json()) as PuppetNode[];\n const entities: ResourceEntity[] = [];\n\n for (const node of nodes) {\n const entity = await transformFn(node, config);\n if (entity) {\n entities.push(entity);\n }\n }\n\n return entities;\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n EntityProvider,\n EntityProviderConnection,\n} from '@backstage/plugin-catalog-node';\nimport { Logger } from 'winston';\nimport {\n PuppetDbEntityProviderConfig,\n readProviderConfigs,\n} from './PuppetDbEntityProviderConfig';\nimport { Config } from '@backstage/config';\nimport { PluginTaskScheduler, TaskRunner } from '@backstage/backend-tasks';\nimport * as uuid from 'uuid';\nimport { ResourceTransformer, defaultResourceTransformer } from '../puppet';\nimport {\n ANNOTATION_LOCATION,\n ANNOTATION_ORIGIN_LOCATION,\n Entity,\n} from '@backstage/catalog-model';\nimport { merge } from 'lodash';\nimport { readPuppetNodes } from '../puppet/read';\nimport { ENDPOINT_NODES } from '../puppet/constants';\n\n/**\n * Reads nodes from [PuppetDB](https://www.puppet.com/docs/puppet/6/puppetdb_overview.html)\n * based on the provided query and registers them as Resource entities in the catalog.\n *\n * @public\n */\nexport class PuppetDbEntityProvider implements EntityProvider {\n private readonly config: PuppetDbEntityProviderConfig;\n private readonly logger: Logger;\n private readonly scheduleFn: () => Promise<void>;\n private readonly transformer: ResourceTransformer;\n private connection?: EntityProviderConnection;\n\n /**\n * Creates instances of {@link PuppetDbEntityProvider} from a configuration.\n *\n * @param config - The configuration to read provider information from.\n * @param deps - The dependencies for {@link PuppetDbEntityProvider}.\n *\n * @returns A list of {@link PuppetDbEntityProvider} instances.\n */\n static fromConfig(\n config: Config,\n deps: {\n logger: Logger;\n schedule?: TaskRunner;\n scheduler?: PluginTaskScheduler;\n transformer?: ResourceTransformer;\n },\n ): PuppetDbEntityProvider[] {\n if (!deps.schedule && !deps.scheduler) {\n throw new Error('Either schedule or scheduler must be provided.');\n }\n\n return readProviderConfigs(config).map(providerConfig => {\n if (!deps.schedule && !providerConfig.schedule) {\n throw new Error(\n `No schedule provided neither via code nor config for puppet-provider:${providerConfig.id}.`,\n );\n }\n\n const taskRunner =\n deps.schedule ??\n deps.scheduler!.createScheduledTaskRunner(providerConfig.schedule!);\n\n const transformer = deps.transformer ?? defaultResourceTransformer;\n\n return new PuppetDbEntityProvider(\n providerConfig,\n deps.logger,\n taskRunner,\n transformer,\n );\n });\n }\n\n /**\n * Creates an instance of {@link PuppetDbEntityProvider}.\n *\n * @param config - Configuration of the provider.\n * @param logger - The instance of a {@link Logger}.\n * @param taskRunner - The instance of {@link TaskRunner}.\n * @param transformer - A {@link ResourceTransformer} function.\n *\n * @private\n */\n private constructor(\n config: PuppetDbEntityProviderConfig,\n logger: Logger,\n taskRunner: TaskRunner,\n transformer: ResourceTransformer,\n ) {\n this.config = config;\n this.logger = logger.child({\n target: this.getProviderName(),\n });\n this.scheduleFn = this.createScheduleFn(taskRunner);\n this.transformer = transformer;\n }\n\n /** {@inheritdoc @backstage/plugin-catalog-node#EntityProvider.connect} */\n async connect(connection: EntityProviderConnection): Promise<void> {\n this.connection = connection;\n await this.scheduleFn();\n }\n\n /** {@inheritdoc @backstage/plugin-catalog-node#EntityProvider.getProviderName} */\n getProviderName(): string {\n return `puppetdb-provider:${this.config.id}`;\n }\n\n /**\n * Creates a function that can be used to schedule a refresh of the catalog.\n *\n * @param taskRunner - The instance of {@link TaskRunner}.\n *\n * @private\n */\n private createScheduleFn(taskRunner: TaskRunner): () => Promise<void> {\n return async () => {\n const taskId = `${this.getProviderName()}:refresh`;\n return taskRunner.run({\n id: taskId,\n fn: async () => {\n const logger = this.logger.child({\n class: PuppetDbEntityProvider.prototype.constructor.name,\n taskId,\n taskInstanceId: uuid.v4(),\n });\n try {\n await this.refresh(logger);\n } catch (error) {\n logger.error(\n `${this.getProviderName()} refresh failed, ${error}`,\n error,\n );\n }\n },\n });\n };\n }\n\n /**\n * Refreshes the catalog by reading nodes from PuppetDB and registering them as Resource Entities.\n *\n * @param logger - The instance of a Logger.\n */\n async refresh(logger: Logger) {\n if (!this.connection) {\n throw new Error('Not initialized');\n }\n\n const { markReadComplete } = trackProgress(logger);\n const entities = await readPuppetNodes(this.config, {\n logger,\n transformer: this.transformer,\n });\n const { markCommitComplete } = markReadComplete(entities);\n\n await this.connection.applyMutation({\n type: 'full',\n entities: [...entities].map(entity => ({\n locationKey: this.getProviderName(),\n entity: withLocations(this.config.baseUrl, entity),\n })),\n });\n markCommitComplete(entities);\n }\n}\n\n/**\n * Ensures the entities have required annotation data.\n *\n * @param baseUrl - The base URL of the PuppetDB instance.\n * @param entity - The entity to add the annotations to.\n *\n * @returns Entity with @{@link ANNOTATION_LOCATION} and @{@link ANNOTATION_ORIGIN_LOCATION} annotations.\n */\nfunction withLocations(baseUrl: string, entity: Entity): Entity {\n const location = `${baseUrl}/${ENDPOINT_NODES}/${entity.metadata?.name}`;\n\n return merge(\n {\n metadata: {\n annotations: {\n [ANNOTATION_LOCATION]: `url:${location}`,\n [ANNOTATION_ORIGIN_LOCATION]: `url:${location}`,\n },\n },\n },\n entity,\n ) as Entity;\n}\n\n/**\n * Tracks the progress of the PuppetDB read and commit operations.\n *\n * @param logger - The instance of a {@link Logger}.\n */\nfunction trackProgress(logger: Logger) {\n let timestamp = Date.now();\n\n function markReadComplete(entities: Entity[]) {\n const readDuration = ((Date.now() - timestamp) / 1000).toFixed(1);\n timestamp = Date.now();\n logger.info(\n `Read ${entities?.length ?? 0} in ${readDuration} seconds. Committing...`,\n );\n return { markCommitComplete };\n }\n\n function markCommitComplete(entities: Entity[]) {\n const commitDuration = ((Date.now() - timestamp) / 1000).toFixed(1);\n logger.info(\n `Committed ${entities?.length ?? 0} in ${commitDuration} seconds.`,\n );\n }\n\n return { markReadComplete };\n}\n"],"names":["readTaskScheduleDefinitionFromConfig","DEFAULT_NAMESPACE","fetch","ResponseError","uuid","merge","ANNOTATION_LOCATION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AAiB,EAAA,CAAA;AAC5B;;;;;;;"}
package/dist/index.cjs.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var PuppetDbEntityProvider = require('./cjs/PuppetDbEntityProvider-41a6e77d.cjs.js');
5
+ var PuppetDbEntityProvider = require('./cjs/PuppetDbEntityProvider-f784910b.cjs.js');
6
6
  require('@backstage/backend-tasks');
7
7
  require('uuid');
8
8
  require('@backstage/catalog-model');
package/dist/index.d.ts CHANGED
@@ -64,6 +64,10 @@ type PuppetNode = {
64
64
  /**
65
65
  * A hash of the factset's certname, environment, timestamp, facts, and producer_timestamp.
66
66
  */
67
+ latest_report_status: string;
68
+ /**
69
+ * The status of the latest report. Possible values come from Puppet's report status failed, changed, or unchanged.
70
+ */
67
71
  hash: string;
68
72
  /**
69
73
  * The most recent time of fact submission for the relevant certname from the Puppet Server.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-backend-module-puppetdb",
3
3
  "description": "A Backstage catalog backend module that helps integrate towards PuppetDB",
4
- "version": "0.1.15-next.1",
4
+ "version": "0.1.15-next.2",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -45,13 +45,13 @@
45
45
  "postpack": "backstage-cli package postpack"
46
46
  },
47
47
  "dependencies": {
48
- "@backstage/backend-common": "^0.21.0-next.1",
49
- "@backstage/backend-plugin-api": "^0.6.10-next.1",
50
- "@backstage/backend-tasks": "^0.5.15-next.1",
48
+ "@backstage/backend-common": "^0.21.0-next.2",
49
+ "@backstage/backend-plugin-api": "^0.6.10-next.2",
50
+ "@backstage/backend-tasks": "^0.5.15-next.2",
51
51
  "@backstage/catalog-model": "^1.4.4-next.0",
52
52
  "@backstage/config": "^1.1.1",
53
53
  "@backstage/errors": "^1.2.3",
54
- "@backstage/plugin-catalog-node": "^1.6.2-next.1",
54
+ "@backstage/plugin-catalog-node": "^1.6.2-next.2",
55
55
  "@backstage/types": "^1.1.1",
56
56
  "lodash": "^4.17.21",
57
57
  "luxon": "^3.0.0",
@@ -60,8 +60,8 @@
60
60
  "winston": "^3.2.1"
61
61
  },
62
62
  "devDependencies": {
63
- "@backstage/backend-test-utils": "^0.3.0-next.1",
64
- "@backstage/cli": "^0.25.2-next.1",
63
+ "@backstage/backend-test-utils": "^0.3.0-next.2",
64
+ "@backstage/cli": "^0.25.2-next.2",
65
65
  "@types/lodash": "^4.14.151",
66
66
  "msw": "^1.0.0"
67
67
  },
@@ -1 +0,0 @@
1
- {"version":3,"file":"PuppetDbEntityProvider-41a6e77d.cjs.js","sources":["../../src/providers/constants.ts","../../src/providers/PuppetDbEntityProviderConfig.ts","../../src/puppet/constants.ts","../../src/puppet/transformers.ts","../../src/puppet/read.ts","../../src/providers/PuppetDbEntityProvider.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Name of the default provider when a using a simple configuration.\n *\n * @public\n */\nexport const DEFAULT_PROVIDER_ID = 'default';\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n readTaskScheduleDefinitionFromConfig,\n TaskScheduleDefinition,\n} from '@backstage/backend-tasks';\nimport { Config } from '@backstage/config';\nimport { DEFAULT_PROVIDER_ID } from './constants';\n\n/**\n * Configuration of {@link PuppetDbEntityProvider}.\n *\n * @public\n */\nexport type PuppetDbEntityProviderConfig = {\n /**\n * ID of the provider.\n */\n id: string;\n /**\n * (Required) The base URL of PuppetDB API instance.\n */\n baseUrl: string;\n /**\n * (Optional) PQL query to filter PuppetDB nodes.\n */\n query?: string;\n /**\n * (Optional) Task schedule definition for the refresh.\n */\n schedule?: TaskScheduleDefinition;\n};\n\n/**\n * Reads the configuration of the PuppetDB Entity Providers.\n *\n * @param config - The application configuration.\n *\n * @returns PuppetDB Entity Provider configurations list.\n */\nexport function readProviderConfigs(\n config: Config,\n): PuppetDbEntityProviderConfig[] {\n const providersConfig = config.getOptionalConfig(\n 'catalog.providers.puppetdb',\n );\n if (!providersConfig) {\n return [];\n }\n\n if (providersConfig.has('baseUrl')) {\n return [readProviderConfig(DEFAULT_PROVIDER_ID, providersConfig)];\n }\n\n return providersConfig.keys().map(id => {\n return readProviderConfig(id, providersConfig.getConfig(id));\n });\n}\n\n/**\n * Reads the configuration for the PuppetDB Entity Provider.\n *\n * @param id - ID of the provider.\n * @param config - The application configuration.\n *\n * @returns The PuppetDB Entity Provider configuration.\n */\nfunction readProviderConfig(\n id: string,\n config: Config,\n): PuppetDbEntityProviderConfig {\n const baseUrl = config.getString('baseUrl').replace(/\\/+$/, '');\n const query = config.getOptionalString('query');\n\n const schedule = config.has('schedule')\n ? readTaskScheduleDefinitionFromConfig(config.getConfig('schedule'))\n : undefined;\n\n return {\n id,\n baseUrl,\n query,\n schedule,\n };\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Annotation for specifying the certificate name of a node in PuppetDB.\n *\n * @public\n */\nexport const ANNOTATION_PUPPET_CERTNAME = 'puppet.com/certname';\n\n/**\n * Path of PuppetDB FactSets endpoint.\n */\nexport const ENDPOINT_FACTSETS = 'pdb/query/v4/factsets';\n\n/**\n * Path of PuppetDB Nodes endpoint.\n */\nexport const ENDPOINT_NODES = 'pdb/query/v4/nodes';\n\n/**\n * Default owner for entities created by the PuppetDB provider.\n *\n * @public\n */\nexport const DEFAULT_ENTITY_OWNER = 'unknown';\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ResourceTransformer } from './types';\nimport { DEFAULT_NAMESPACE, ResourceEntity } from '@backstage/catalog-model';\nimport { ANNOTATION_PUPPET_CERTNAME, DEFAULT_ENTITY_OWNER } from './constants';\n\n/**\n * A default implementation of the {@link ResourceTransformer}.\n *\n * @param node - The found PuppetDB node entry in its source format. This is the entry that you want to transform.\n * @param _config - The configuration for the entity provider.\n *\n * @returns A `ResourceEntity`.\n *\n * @public\n */\nexport const defaultResourceTransformer: ResourceTransformer = async (\n node,\n _config,\n): Promise<ResourceEntity | undefined> => {\n const certName = node.certname.toLocaleLowerCase('en-US');\n const type = node.facts?.data?.find(e => e.name === 'is_virtual')?.value\n ? 'virtual-machine'\n : 'physical-server';\n const kernel = node.facts?.data?.find(e => e.name === 'kernel')?.value;\n\n return {\n apiVersion: 'backstage.io/v1beta1',\n kind: 'Resource',\n metadata: {\n name: certName,\n annotations: {\n [ANNOTATION_PUPPET_CERTNAME]: certName,\n },\n namespace: DEFAULT_NAMESPACE,\n description: node.facts?.data\n ?.find(e => e.name === 'ipaddress')\n ?.value?.toString(),\n tags: kernel ? [kernel.toString().toLocaleLowerCase('en-US')] : [],\n },\n spec: {\n type: type,\n owner: DEFAULT_ENTITY_OWNER,\n dependsOn: [],\n dependencyOf: [],\n },\n };\n};\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { PuppetDbEntityProviderConfig } from '../providers';\nimport { PuppetNode, ResourceTransformer } from './types';\nimport { ResourceEntity } from '@backstage/catalog-model';\nimport { defaultResourceTransformer } from './transformers';\nimport fetch from 'node-fetch';\nimport { ResponseError } from '@backstage/errors';\nimport { ENDPOINT_FACTSETS } from './constants';\nimport { Logger } from 'winston';\n\n/**\n * Reads nodes and their facts from PuppetDB.\n *\n * @param config - The provider configuration.\n * @param opts - Additional options.\n */\nexport async function readPuppetNodes(\n config: PuppetDbEntityProviderConfig,\n opts?: {\n transformer?: ResourceTransformer;\n logger?: Logger;\n },\n): Promise<ResourceEntity[]> {\n const transformFn = opts?.transformer ?? defaultResourceTransformer;\n const url = new URL(ENDPOINT_FACTSETS, config.baseUrl);\n\n if (config.query) {\n url.searchParams.set('query', config.query);\n }\n\n if (opts?.logger) {\n opts.logger.debug('Reading nodes from PuppetDB', { url: url.toString() });\n }\n\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n },\n });\n\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n const nodes = (await response.json()) as PuppetNode[];\n const entities: ResourceEntity[] = [];\n\n for (const node of nodes) {\n const entity = await transformFn(node, config);\n if (entity) {\n entities.push(entity);\n }\n }\n\n return entities;\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n EntityProvider,\n EntityProviderConnection,\n} from '@backstage/plugin-catalog-node';\nimport { Logger } from 'winston';\nimport {\n PuppetDbEntityProviderConfig,\n readProviderConfigs,\n} from './PuppetDbEntityProviderConfig';\nimport { Config } from '@backstage/config';\nimport { PluginTaskScheduler, TaskRunner } from '@backstage/backend-tasks';\nimport * as uuid from 'uuid';\nimport { ResourceTransformer, defaultResourceTransformer } from '../puppet';\nimport {\n ANNOTATION_LOCATION,\n ANNOTATION_ORIGIN_LOCATION,\n Entity,\n} from '@backstage/catalog-model';\nimport { merge } from 'lodash';\nimport { readPuppetNodes } from '../puppet/read';\nimport { ENDPOINT_NODES } from '../puppet/constants';\n\n/**\n * Reads nodes from [PuppetDB](https://www.puppet.com/docs/puppet/6/puppetdb_overview.html)\n * based on the provided query and registers them as Resource entities in the catalog.\n *\n * @public\n */\nexport class PuppetDbEntityProvider implements EntityProvider {\n private readonly config: PuppetDbEntityProviderConfig;\n private readonly logger: Logger;\n private readonly scheduleFn: () => Promise<void>;\n private readonly transformer: ResourceTransformer;\n private connection?: EntityProviderConnection;\n\n /**\n * Creates instances of {@link PuppetDbEntityProvider} from a configuration.\n *\n * @param config - The configuration to read provider information from.\n * @param deps - The dependencies for {@link PuppetDbEntityProvider}.\n *\n * @returns A list of {@link PuppetDbEntityProvider} instances.\n */\n static fromConfig(\n config: Config,\n deps: {\n logger: Logger;\n schedule?: TaskRunner;\n scheduler?: PluginTaskScheduler;\n transformer?: ResourceTransformer;\n },\n ): PuppetDbEntityProvider[] {\n if (!deps.schedule && !deps.scheduler) {\n throw new Error('Either schedule or scheduler must be provided.');\n }\n\n return readProviderConfigs(config).map(providerConfig => {\n if (!deps.schedule && !providerConfig.schedule) {\n throw new Error(\n `No schedule provided neither via code nor config for puppet-provider:${providerConfig.id}.`,\n );\n }\n\n const taskRunner =\n deps.schedule ??\n deps.scheduler!.createScheduledTaskRunner(providerConfig.schedule!);\n\n const transformer = deps.transformer ?? defaultResourceTransformer;\n\n return new PuppetDbEntityProvider(\n providerConfig,\n deps.logger,\n taskRunner,\n transformer,\n );\n });\n }\n\n /**\n * Creates an instance of {@link PuppetDbEntityProvider}.\n *\n * @param config - Configuration of the provider.\n * @param logger - The instance of a {@link Logger}.\n * @param taskRunner - The instance of {@link TaskRunner}.\n * @param transformer - A {@link ResourceTransformer} function.\n *\n * @private\n */\n private constructor(\n config: PuppetDbEntityProviderConfig,\n logger: Logger,\n taskRunner: TaskRunner,\n transformer: ResourceTransformer,\n ) {\n this.config = config;\n this.logger = logger.child({\n target: this.getProviderName(),\n });\n this.scheduleFn = this.createScheduleFn(taskRunner);\n this.transformer = transformer;\n }\n\n /** {@inheritdoc @backstage/plugin-catalog-node#EntityProvider.connect} */\n async connect(connection: EntityProviderConnection): Promise<void> {\n this.connection = connection;\n await this.scheduleFn();\n }\n\n /** {@inheritdoc @backstage/plugin-catalog-node#EntityProvider.getProviderName} */\n getProviderName(): string {\n return `puppetdb-provider:${this.config.id}`;\n }\n\n /**\n * Creates a function that can be used to schedule a refresh of the catalog.\n *\n * @param taskRunner - The instance of {@link TaskRunner}.\n *\n * @private\n */\n private createScheduleFn(taskRunner: TaskRunner): () => Promise<void> {\n return async () => {\n const taskId = `${this.getProviderName()}:refresh`;\n return taskRunner.run({\n id: taskId,\n fn: async () => {\n const logger = this.logger.child({\n class: PuppetDbEntityProvider.prototype.constructor.name,\n taskId,\n taskInstanceId: uuid.v4(),\n });\n try {\n await this.refresh(logger);\n } catch (error) {\n logger.error(\n `${this.getProviderName()} refresh failed, ${error}`,\n error,\n );\n }\n },\n });\n };\n }\n\n /**\n * Refreshes the catalog by reading nodes from PuppetDB and registering them as Resource Entities.\n *\n * @param logger - The instance of a Logger.\n */\n async refresh(logger: Logger) {\n if (!this.connection) {\n throw new Error('Not initialized');\n }\n\n const { markReadComplete } = trackProgress(logger);\n const entities = await readPuppetNodes(this.config, {\n logger,\n transformer: this.transformer,\n });\n const { markCommitComplete } = markReadComplete(entities);\n\n await this.connection.applyMutation({\n type: 'full',\n entities: [...entities].map(entity => ({\n locationKey: this.getProviderName(),\n entity: withLocations(this.config.baseUrl, entity),\n })),\n });\n markCommitComplete(entities);\n }\n}\n\n/**\n * Ensures the entities have required annotation data.\n *\n * @param baseUrl - The base URL of the PuppetDB instance.\n * @param entity - The entity to add the annotations to.\n *\n * @returns Entity with @{@link ANNOTATION_LOCATION} and @{@link ANNOTATION_ORIGIN_LOCATION} annotations.\n */\nfunction withLocations(baseUrl: string, entity: Entity): Entity {\n const location = `${baseUrl}/${ENDPOINT_NODES}/${entity.metadata?.name}`;\n\n return merge(\n {\n metadata: {\n annotations: {\n [ANNOTATION_LOCATION]: `url:${location}`,\n [ANNOTATION_ORIGIN_LOCATION]: `url:${location}`,\n },\n },\n },\n entity,\n ) as Entity;\n}\n\n/**\n * Tracks the progress of the PuppetDB read and commit operations.\n *\n * @param logger - The instance of a {@link Logger}.\n */\nfunction trackProgress(logger: Logger) {\n let timestamp = Date.now();\n\n function markReadComplete(entities: Entity[]) {\n const readDuration = ((Date.now() - timestamp) / 1000).toFixed(1);\n timestamp = Date.now();\n logger.info(\n `Read ${entities?.length ?? 0} in ${readDuration} seconds. Committing...`,\n );\n return { markCommitComplete };\n }\n\n function markCommitComplete(entities: Entity[]) {\n const commitDuration = ((Date.now() - timestamp) / 1000).toFixed(1);\n logger.info(\n `Committed ${entities?.length ?? 0} in ${commitDuration} seconds.`,\n );\n }\n\n return { markReadComplete };\n}\n"],"names":["readTaskScheduleDefinitionFromConfig","DEFAULT_NAMESPACE","fetch","ResponseError","uuid","merge","ANNOTATION_LOCATION","ANNOTATION_ORIGIN_LOCATION"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBO,MAAM,mBAAsB,GAAA;;ACiC5B,SAAS,oBACd,MACgC,EAAA;AAChC,EAAA,MAAM,kBAAkB,MAAO,CAAA,iBAAA;AAAA,IAC7B,4BAAA;AAAA,GACF,CAAA;AACA,EAAA,IAAI,CAAC,eAAiB,EAAA;AACpB,IAAA,OAAO,EAAC,CAAA;AAAA,GACV;AAEA,EAAI,IAAA,eAAA,CAAgB,GAAI,CAAA,SAAS,CAAG,EAAA;AAClC,IAAA,OAAO,CAAC,kBAAA,CAAmB,mBAAqB,EAAA,eAAe,CAAC,CAAA,CAAA;AAAA,GAClE;AAEA,EAAA,OAAO,eAAgB,CAAA,IAAA,EAAO,CAAA,GAAA,CAAI,CAAM,EAAA,KAAA;AACtC,IAAA,OAAO,kBAAmB,CAAA,EAAA,EAAI,eAAgB,CAAA,SAAA,CAAU,EAAE,CAAC,CAAA,CAAA;AAAA,GAC5D,CAAA,CAAA;AACH,CAAA;AAUA,SAAS,kBAAA,CACP,IACA,MAC8B,EAAA;AAC9B,EAAA,MAAM,UAAU,MAAO,CAAA,SAAA,CAAU,SAAS,CAAE,CAAA,OAAA,CAAQ,QAAQ,EAAE,CAAA,CAAA;AAC9D,EAAM,MAAA,KAAA,GAAQ,MAAO,CAAA,iBAAA,CAAkB,OAAO,CAAA,CAAA;AAE9C,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,GAAA,CAAI,UAAU,CAAA,GAClCA,kDAAqC,MAAO,CAAA,SAAA,CAAU,UAAU,CAAC,CACjE,GAAA,KAAA,CAAA,CAAA;AAE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