@backstage/plugin-catalog-backend-module-gerrit 0.1.2-next.2 → 0.1.3

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,39 @@
1
1
  # @backstage/plugin-catalog-backend-module-gerrit
2
2
 
3
+ ## 0.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/backend-common@0.15.0
9
+ - @backstage/integration@1.3.0
10
+ - @backstage/backend-tasks@0.3.4
11
+ - @backstage/plugin-catalog-backend@1.3.1
12
+
13
+ ## 0.1.3-next.0
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies
18
+ - @backstage/backend-common@0.15.0-next.0
19
+ - @backstage/integration@1.3.0-next.0
20
+ - @backstage/backend-tasks@0.3.4-next.0
21
+ - @backstage/plugin-catalog-backend@1.3.1-next.0
22
+
23
+ ## 0.1.2
24
+
25
+ ### Patch Changes
26
+
27
+ - a70869e775: Updated dependency `msw` to `^0.43.0`.
28
+ - 8006d0f9bf: Updated dependency `msw` to `^0.44.0`.
29
+ - Updated dependencies
30
+ - @backstage/plugin-catalog-backend@1.3.0
31
+ - @backstage/backend-common@0.14.1
32
+ - @backstage/catalog-model@1.1.0
33
+ - @backstage/integration@1.2.2
34
+ - @backstage/backend-tasks@0.3.3
35
+ - @backstage/errors@1.1.0
36
+
3
37
  ## 0.1.2-next.2
4
38
 
5
39
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -63,9 +63,18 @@ class GerritEntityProvider {
63
63
  providerConfigs.forEach((providerConfig) => {
64
64
  const integration = integrations.byHost(providerConfig.host);
65
65
  if (!integration) {
66
- throw new errors.InputError(`No gerrit integration found that matches host ${providerConfig.host}`);
66
+ throw new errors.InputError(
67
+ `No gerrit integration found that matches host ${providerConfig.host}`
68
+ );
67
69
  }
68
- providers.push(new GerritEntityProvider(providerConfig, integration, options.logger, options.schedule));
70
+ providers.push(
71
+ new GerritEntityProvider(
72
+ providerConfig,
73
+ integration,
74
+ options.logger,
75
+ options.schedule
76
+ )
77
+ );
69
78
  });
70
79
  return providers;
71
80
  }
@@ -117,9 +126,13 @@ class GerritEntityProvider {
117
126
  ...integration.getGerritRequestOptions(this.integration.config)
118
127
  });
119
128
  } catch (e) {
120
- throw new Error(`Failed to list Gerrit projects for query ${this.config.query}, ${e}`);
129
+ throw new Error(
130
+ `Failed to list Gerrit projects for query ${this.config.query}, ${e}`
131
+ );
121
132
  }
122
- const gerritProjectsResponse = await integration.parseGerritJsonResponse(response);
133
+ const gerritProjectsResponse = await integration.parseGerritJsonResponse(
134
+ response
135
+ );
123
136
  const projects = Object.keys(gerritProjectsResponse);
124
137
  const locations = projects.map((project) => this.createLocationSpec(project));
125
138
  await this.connection.applyMutation({
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/providers/config.ts","../src/providers/GerritEntityProvider.ts"],"sourcesContent":["/*\n * Copyright 2022 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 { Config } from '@backstage/config';\nimport { GerritProviderConfig } from './types';\n\nfunction readGerritConfig(id: string, config: Config): GerritProviderConfig {\n const branch = config.getOptionalString('branch') ?? 'master';\n const host = config.getString('host');\n const query = config.getString('query');\n\n return {\n branch,\n host,\n id,\n query,\n };\n}\n\nexport function readGerritConfigs(config: Config): GerritProviderConfig[] {\n const configs: GerritProviderConfig[] = [];\n\n const providerConfigs = config.getOptionalConfig('catalog.providers.gerrit');\n\n if (!providerConfigs) {\n return configs;\n }\n\n for (const id of providerConfigs.keys()) {\n configs.push(readGerritConfig(id, providerConfigs.getConfig(id)));\n }\n\n return configs;\n}\n","/*\n * Copyright 2022 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 { TaskRunner } from '@backstage/backend-tasks';\nimport { Config } from '@backstage/config';\nimport { InputError } from '@backstage/errors';\nimport {\n EntityProvider,\n EntityProviderConnection,\n LocationSpec,\n locationSpecToLocationEntity,\n} from '@backstage/plugin-catalog-backend';\nimport fetch, { Response } from 'node-fetch';\nimport {\n GerritIntegration,\n getGerritProjectsApiUrl,\n getGerritRequestOptions,\n parseGerritJsonResponse,\n ScmIntegrations,\n} from '@backstage/integration';\nimport * as uuid from 'uuid';\nimport { Logger } from 'winston';\n\nimport { readGerritConfigs } from './config';\nimport { GerritProjectQueryResult, GerritProviderConfig } from './types';\n\n/** @public */\nexport class GerritEntityProvider implements EntityProvider {\n private readonly config: GerritProviderConfig;\n private readonly integration: GerritIntegration;\n private readonly logger: Logger;\n private readonly scheduleFn: () => Promise<void>;\n private connection?: EntityProviderConnection;\n\n static fromConfig(\n configRoot: Config,\n options: {\n logger: Logger;\n schedule: TaskRunner;\n },\n ): GerritEntityProvider[] {\n const providerConfigs = readGerritConfigs(configRoot);\n const integrations = ScmIntegrations.fromConfig(configRoot).gerrit;\n const providers: GerritEntityProvider[] = [];\n\n providerConfigs.forEach(providerConfig => {\n const integration = integrations.byHost(providerConfig.host);\n if (!integration) {\n throw new InputError(\n `No gerrit integration found that matches host ${providerConfig.host}`,\n );\n }\n providers.push(\n new GerritEntityProvider(\n providerConfig,\n integration,\n options.logger,\n options.schedule,\n ),\n );\n });\n return providers;\n }\n\n private constructor(\n config: GerritProviderConfig,\n integration: GerritIntegration,\n logger: Logger,\n schedule: TaskRunner,\n ) {\n this.config = config;\n this.integration = integration;\n this.logger = logger.child({\n target: this.getProviderName(),\n });\n this.scheduleFn = this.createScheduleFn(schedule);\n }\n\n getProviderName(): string {\n return `gerrit-provider:${this.config.id}`;\n }\n\n async connect(connection: EntityProviderConnection): Promise<void> {\n this.connection = connection;\n await this.scheduleFn();\n }\n\n private createScheduleFn(schedule: TaskRunner): () => Promise<void> {\n return async () => {\n const taskId = `${this.getProviderName()}:refresh`;\n return schedule.run({\n id: taskId,\n fn: async () => {\n const logger = this.logger.child({\n class: GerritEntityProvider.prototype.constructor.name,\n taskId,\n taskInstanceId: uuid.v4(),\n });\n\n try {\n await this.refresh(logger);\n } catch (error) {\n logger.error(error);\n }\n },\n });\n };\n }\n\n async refresh(logger: Logger): Promise<void> {\n if (!this.connection) {\n throw new Error('Gerrit discovery connection not initialized');\n }\n\n let response: Response;\n\n const baseProjectApiUrl = getGerritProjectsApiUrl(this.integration.config);\n const projectQueryUrl = `${baseProjectApiUrl}?${this.config.query}`;\n try {\n response = await fetch(projectQueryUrl, {\n method: 'GET',\n ...getGerritRequestOptions(this.integration.config),\n });\n } catch (e) {\n throw new Error(\n `Failed to list Gerrit projects for query ${this.config.query}, ${e}`,\n );\n }\n const gerritProjectsResponse = (await parseGerritJsonResponse(\n response as any,\n )) as GerritProjectQueryResult;\n const projects = Object.keys(gerritProjectsResponse);\n\n const locations = projects.map(project => this.createLocationSpec(project));\n await this.connection.applyMutation({\n type: 'full',\n entities: locations.map(location => ({\n locationKey: this.getProviderName(),\n entity: locationSpecToLocationEntity({ location }),\n })),\n });\n logger.info(`Found ${locations.length} locations.`);\n }\n\n private createLocationSpec(project: string): LocationSpec {\n return {\n type: 'url',\n target: `${this.integration.config.gitilesBaseUrl}/${project}/+/refs/heads/${this.config.branch}/catalog-info.yaml`,\n presence: 'optional',\n };\n }\n}\n"],"names":["ScmIntegrations","InputError","u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MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC;AACzH,MAAM,QAAQ,EAAE,UAAU;AAC1B,KAAK,CAAC;AACN,GAAG;AACH;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/providers/config.ts","../src/providers/GerritEntityProvider.ts"],"sourcesContent":["/*\n * Copyright 2022 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 { Config } from '@backstage/config';\nimport { GerritProviderConfig } from './types';\n\nfunction readGerritConfig(id: string, config: Config): GerritProviderConfig {\n const branch = config.getOptionalString('branch') ?? 'master';\n const host = config.getString('host');\n const query = config.getString('query');\n\n return {\n branch,\n host,\n id,\n query,\n };\n}\n\nexport function readGerritConfigs(config: Config): GerritProviderConfig[] {\n const configs: GerritProviderConfig[] = [];\n\n const providerConfigs = config.getOptionalConfig('catalog.providers.gerrit');\n\n if (!providerConfigs) {\n return configs;\n }\n\n for (const id of providerConfigs.keys()) {\n configs.push(readGerritConfig(id, providerConfigs.getConfig(id)));\n }\n\n return configs;\n}\n","/*\n * Copyright 2022 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 { TaskRunner } from '@backstage/backend-tasks';\nimport { Config } from '@backstage/config';\nimport { InputError } from '@backstage/errors';\nimport {\n EntityProvider,\n EntityProviderConnection,\n LocationSpec,\n locationSpecToLocationEntity,\n} from '@backstage/plugin-catalog-backend';\nimport fetch, { Response } from 'node-fetch';\nimport {\n GerritIntegration,\n getGerritProjectsApiUrl,\n getGerritRequestOptions,\n parseGerritJsonResponse,\n ScmIntegrations,\n} from '@backstage/integration';\nimport * as uuid from 'uuid';\nimport { Logger } from 'winston';\n\nimport { readGerritConfigs } from './config';\nimport { GerritProjectQueryResult, GerritProviderConfig } from './types';\n\n/** @public */\nexport class GerritEntityProvider implements EntityProvider {\n private readonly config: GerritProviderConfig;\n private readonly integration: GerritIntegration;\n private readonly logger: Logger;\n private readonly scheduleFn: () => Promise<void>;\n private connection?: EntityProviderConnection;\n\n static fromConfig(\n configRoot: Config,\n options: {\n logger: Logger;\n schedule: TaskRunner;\n },\n ): GerritEntityProvider[] {\n const providerConfigs = readGerritConfigs(configRoot);\n const integrations = ScmIntegrations.fromConfig(configRoot).gerrit;\n const providers: GerritEntityProvider[] = [];\n\n providerConfigs.forEach(providerConfig => {\n const integration = integrations.byHost(providerConfig.host);\n if (!integration) {\n throw new InputError(\n `No gerrit integration found that matches host ${providerConfig.host}`,\n );\n }\n providers.push(\n new GerritEntityProvider(\n providerConfig,\n integration,\n options.logger,\n options.schedule,\n ),\n );\n });\n return providers;\n }\n\n private constructor(\n config: GerritProviderConfig,\n integration: GerritIntegration,\n logger: Logger,\n schedule: TaskRunner,\n ) {\n this.config = config;\n this.integration = integration;\n this.logger = logger.child({\n target: this.getProviderName(),\n });\n this.scheduleFn = this.createScheduleFn(schedule);\n }\n\n getProviderName(): string {\n return `gerrit-provider:${this.config.id}`;\n }\n\n async connect(connection: EntityProviderConnection): Promise<void> {\n this.connection = connection;\n await this.scheduleFn();\n }\n\n private createScheduleFn(schedule: TaskRunner): () => Promise<void> {\n return async () => {\n const taskId = `${this.getProviderName()}:refresh`;\n return schedule.run({\n id: taskId,\n fn: async () => {\n const logger = this.logger.child({\n class: GerritEntityProvider.prototype.constructor.name,\n taskId,\n taskInstanceId: uuid.v4(),\n });\n\n try {\n await this.refresh(logger);\n } catch (error) {\n logger.error(error);\n }\n },\n });\n };\n }\n\n async refresh(logger: Logger): Promise<void> {\n if (!this.connection) {\n throw new Error('Gerrit discovery connection not initialized');\n }\n\n let response: Response;\n\n const baseProjectApiUrl = getGerritProjectsApiUrl(this.integration.config);\n const projectQueryUrl = `${baseProjectApiUrl}?${this.config.query}`;\n try {\n response = await fetch(projectQueryUrl, {\n method: 'GET',\n ...getGerritRequestOptions(this.integration.config),\n });\n } catch (e) {\n throw new Error(\n `Failed to list Gerrit projects for query ${this.config.query}, ${e}`,\n );\n }\n const gerritProjectsResponse = (await parseGerritJsonResponse(\n response as any,\n )) as GerritProjectQueryResult;\n const projects = Object.keys(gerritProjectsResponse);\n\n const locations = projects.map(project => this.createLocationSpec(project));\n await this.connection.applyMutation({\n type: 'full',\n entities: locations.map(location => ({\n locationKey: this.getProviderName(),\n entity: locationSpecToLocationEntity({ location }),\n })),\n });\n logger.info(`Found ${locations.length} locations.`);\n }\n\n private createLocationSpec(project: string): LocationSpec {\n return {\n type: 'url',\n target: `${this.integration.config.gitilesBaseUrl}/${project}/+/refs/heads/${this.config.branch}/catalog-info.yaml`,\n presence: 'optional',\n };\n }\n}\n"],"names":["ScmIntegrations","InputError","uuid","getGerritProjectsApiUrl","fetch","getGerritRequestOptions","parseGerritJsonResponse","locationSpecToLocationEntity"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE;AACtC,EAAE,IAAI,EAAE,CAAC;AACT,EAAE,MAAM,MAAM,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,iBAAiB,CAAC,QAAQ,CAAC,KAAK,IAAI,GAAG,EAAE,GAAG,QAAQ,CAAC;AACnF,EAAE,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AACxC,EA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AAMC,mCAAuB;AAChE,MAAM,QAAQ;AACd,KAAK,CAAC;AACN,IAAI,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;AACzD,IAAI,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,KAAK,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;AAClF,IAAI,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;AACxC,MAAM,IAAI,EAAE,MAAM;AAClB,MAAM,QAAQ,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,MAAM;AAC7C,QAAQ,WAAW,EAAE,IAAI,CAAC,eAAe,EAAE;AAC3C,QAAQ,MAAM,EAAEC,iDAA4B,CAAC,EAAE,QAAQ,EAAE,CAAC;AAC1D,OAAO,CAAC,CAAC;AACT,KAAK,CAAC,CAAC;AACP,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;AACxD,GAAG;AACH,EAAE,kBAAkB,CAAC,OAAO,EAAE;AAC9B,IAAI,OAAO;AACX,MAAM,IAAI,EAAE,KAAK;AACjB,MAAM,MAAM,EAAE,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC;AACzH,MAAM,QAAQ,EAAE,UAAU;AAC1B,KAAK,CAAC;AACN,GAAG;AACH;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-backend-module-gerrit",
3
- "version": "0.1.2-next.2",
3
+ "version": "0.1.3",
4
4
  "main": "dist/index.cjs.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "Apache-2.0",
@@ -28,22 +28,22 @@
28
28
  "postpack": "backstage-cli package postpack"
29
29
  },
30
30
  "dependencies": {
31
- "@backstage/backend-common": "^0.14.1-next.3",
32
- "@backstage/backend-tasks": "^0.3.3-next.3",
33
- "@backstage/catalog-model": "^1.1.0-next.3",
31
+ "@backstage/backend-common": "^0.15.0",
32
+ "@backstage/backend-tasks": "^0.3.4",
33
+ "@backstage/catalog-model": "^1.1.0",
34
34
  "@backstage/config": "^1.0.1",
35
- "@backstage/errors": "^1.1.0-next.0",
36
- "@backstage/integration": "^1.2.2-next.3",
37
- "@backstage/plugin-catalog-backend": "^1.3.0-next.3",
35
+ "@backstage/errors": "^1.1.0",
36
+ "@backstage/integration": "^1.3.0",
37
+ "@backstage/plugin-catalog-backend": "^1.3.1",
38
38
  "fs-extra": "10.1.0",
39
- "msw": "^0.43.0",
39
+ "msw": "^0.44.0",
40
40
  "node-fetch": "^2.6.7",
41
41
  "uuid": "^8.0.0",
42
42
  "winston": "^3.2.1"
43
43
  },
44
44
  "devDependencies": {
45
- "@backstage/backend-test-utils": "^0.1.26-next.3",
46
- "@backstage/cli": "^0.18.0-next.3",
45
+ "@backstage/backend-test-utils": "^0.1.27",
46
+ "@backstage/cli": "^0.18.1",
47
47
  "@types/fs-extra": "^9.0.1"
48
48
  },
49
49
  "files": [
@@ -51,5 +51,5 @@
51
51
  "config.d.ts"
52
52
  ],
53
53
  "configSchema": "config.d.ts",
54
- "gitHead": "291b3a07233061266d9f3ce431345bf19fa4bbd5"
54
+ "gitHead": "a12f6269e3bf224aa7f52475be9152bc52addeed"
55
55
  }