@backstage-community/plugin-nomad-backend 0.14.0 → 0.16.0

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,17 @@
1
1
  # @backstage-community/plugin-nomad-backend
2
2
 
3
+ ## 0.16.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b607186: Backstage version bump to v1.47.2
8
+
9
+ ## 0.15.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 71b816e: Drops support for the old backend system.
14
+
3
15
  ## 0.14.0
4
16
 
5
17
  ### Minor Changes
package/README.md CHANGED
@@ -1,64 +1,24 @@
1
1
  # @backstage-community/plugin-nomad-backend
2
2
 
3
- A backend for [Nomad](https://www.nomadproject.io/), this plugin exposes a service with routes that are used by the `@backstage-community/plugin-nomad-backend` plugin to query Job and Group information from a Nomad API.
3
+ A backend for [Nomad](https://www.nomadproject.io/), this plugin exposes a service with routes to query Job and Group information from a Nomad API.
4
4
 
5
- ## New Backend System
5
+ ## Setup
6
6
 
7
- The Nomad backend plugin has support for the [new backend system](https://backstage.io/docs/backend-system/), here's how you can set that up:
8
-
9
- In your `packages/backend/src/index.ts` make the following changes:
10
-
11
- ```diff
12
- import { createBackend } from '@backstage/backend-defaults';
13
- const backend = createBackend();
14
- // ... other feature additions
15
- backend.add(import('@backstage-community/plugin-nomad-backend'));
16
- backend.start();
17
- ```
18
-
19
- ## Set Up
20
-
21
- 1. Install the plugin using:
7
+ Install the plugin using:
22
8
 
23
9
  ```bash
24
10
  # From your Backstage root directory
25
11
  yarn --cwd packages/backend add @backstage-community/plugin-nomad-backend
26
12
  ```
27
13
 
28
- 2. Create a `nomad.ts` file inside `packages/backend/src/plugins/`:
29
-
30
- ```typescript
31
- import { createRouter } from '@backstage-community/plugin-nomad-backend';
32
- import { Router } from 'express';
33
- import { PluginEnvironment } from '../types';
34
-
35
- export default async function createPlugin(
36
- props: PluginEnvironment,
37
- ): Promise<Router> {
38
- return await createRouter(props);
39
- }
40
- ```
41
-
42
- 3. Modify your `packages/backend/src/index.ts` to include:
43
-
44
- ```diff
45
- ...
46
-
47
- import { Config } from '@backstage/config';
48
- import app from './plugins/app';
49
- +import nomad from './plugins/nomad';
50
- ...
51
-
52
- async function main() {
53
- ...
54
-
55
- const authEnv = useHotMemoize(module, () => createEnv('auth'));
56
- + const nomadEnv = useHotMemoize(module, () => createEnv('nomad'));
57
- ...
14
+ In your `packages/backend/src/index.ts` make the following changes:
58
15
 
59
- const apiRouter = Router();
60
- apiRouter.use('/catalog', await catalog(catalogEnv));
61
- + apiRouter.use('/nomad', await nomad(nomadEnv));
16
+ ```ts
17
+ import { createBackend } from '@backstage/backend-defaults';
18
+ const backend = createBackend();
19
+ // ... other feature additions
20
+ backend.add(import('@backstage-community/plugin-nomad-backend'));
21
+ backend.start();
62
22
  ```
63
23
 
64
24
  Note: for this backend to work, the `nomad` configuration described in the README of `@backstage-community/plugin-nomad` must be implemented.
package/dist/index.cjs.js CHANGED
@@ -2,11 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var router = require('./service/router.cjs.js');
6
5
  var plugin = require('./plugin.cjs.js');
7
6
 
8
7
 
9
8
 
10
- exports.createRouter = router.createRouter;
11
9
  exports.default = plugin.nomadPlugin;
12
10
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,21 +1,4 @@
1
- import { Config } from '@backstage/config';
2
- import express from 'express';
3
1
  import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
4
- import { LoggerService } from '@backstage/backend-plugin-api';
5
-
6
- /**
7
- * @deprecated Please migrate to the new backend system as this will be removed in the future.
8
- *
9
- * @public */
10
- interface RouterOptions {
11
- logger: LoggerService;
12
- config: Config;
13
- }
14
- /**
15
- * @deprecated Please migrate to the new backend system as this will be removed in the future.
16
- *
17
- * @public */
18
- declare function createRouter(options: RouterOptions): Promise<express.Router>;
19
2
 
20
3
  /**
21
4
  * Nomad backend plugin
@@ -24,4 +7,4 @@ declare function createRouter(options: RouterOptions): Promise<express.Router>;
24
7
  */
25
8
  declare const nomadPlugin: _backstage_backend_plugin_api.BackendFeature;
26
9
 
27
- export { type RouterOptions, createRouter, nomadPlugin as default };
10
+ export { nomadPlugin as default };
@@ -15,9 +15,6 @@ const nomadPlugin = backendPluginApi.createBackendPlugin({
15
15
  async init({ logger, config, httpRouter }) {
16
16
  httpRouter.use(
17
17
  await router.createRouter({
18
- /**
19
- * Logger for logging purposes
20
- */
21
18
  logger,
22
19
  config
23
20
  })
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2023 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 coreServices,\n createBackendPlugin,\n} from '@backstage/backend-plugin-api';\nimport { createRouter } from './service/router';\n\n/**\n * Nomad backend plugin\n *\n * @public\n */\nexport const nomadPlugin = createBackendPlugin({\n pluginId: 'nomad',\n register(env) {\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.rootConfig,\n httpRouter: coreServices.httpRouter,\n },\n async init({ logger, config, httpRouter }) {\n httpRouter.use(\n await createRouter({\n /**\n * Logger for logging purposes\n */\n logger,\n config,\n }),\n );\n httpRouter.addAuthPolicy({\n path: '/health',\n allow: 'unauthenticated',\n });\n },\n });\n },\n});\n"],"names":["createBackendPlugin","coreServices","createRouter"],"mappings":";;;;;AA2BO,MAAM,cAAcA,oCAAoB,CAAA;AAAA,EAC7C,QAAU,EAAA,OAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,QAAQC,6BAAa,CAAA,MAAA;AAAA,QACrB,QAAQA,6BAAa,CAAA,UAAA;AAAA,QACrB,YAAYA,6BAAa,CAAA;AAAA,OAC3B;AAAA,MACA,MAAM,IAAK,CAAA,EAAE,MAAQ,EAAA,MAAA,EAAQ,YAAc,EAAA;AACzC,QAAW,UAAA,CAAA,GAAA;AAAA,UACT,MAAMC,mBAAa,CAAA;AAAA;AAAA;AAAA;AAAA,YAIjB,MAAA;AAAA,YACA;AAAA,WACD;AAAA,SACH;AACA,QAAA,UAAA,CAAW,aAAc,CAAA;AAAA,UACvB,IAAM,EAAA,SAAA;AAAA,UACN,KAAO,EAAA;AAAA,SACR,CAAA;AAAA;AACH,KACD,CAAA;AAAA;AAEL,CAAC;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2023 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 coreServices,\n createBackendPlugin,\n} from '@backstage/backend-plugin-api';\nimport { createRouter } from './service/router';\n\n/**\n * Nomad backend plugin\n *\n * @public\n */\nexport const nomadPlugin = createBackendPlugin({\n pluginId: 'nomad',\n register(env) {\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.rootConfig,\n httpRouter: coreServices.httpRouter,\n },\n async init({ logger, config, httpRouter }) {\n httpRouter.use(\n await createRouter({\n logger,\n config,\n }),\n );\n httpRouter.addAuthPolicy({\n path: '/health',\n allow: 'unauthenticated',\n });\n },\n });\n },\n});\n"],"names":["createBackendPlugin","coreServices","createRouter"],"mappings":";;;;;AA2BO,MAAM,cAAcA,oCAAoB,CAAA;AAAA,EAC7C,QAAU,EAAA,OAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,QAAQC,6BAAa,CAAA,MAAA;AAAA,QACrB,QAAQA,6BAAa,CAAA,UAAA;AAAA,QACrB,YAAYA,6BAAa,CAAA;AAAA,OAC3B;AAAA,MACA,MAAM,IAAK,CAAA,EAAE,MAAQ,EAAA,MAAA,EAAQ,YAAc,EAAA;AACzC,QAAW,UAAA,CAAA,GAAA;AAAA,UACT,MAAMC,mBAAa,CAAA;AAAA,YACjB,MAAA;AAAA,YACA;AAAA,WACD;AAAA,SACH;AACA,QAAA,UAAA,CAAW,aAAc,CAAA;AAAA,UACvB,IAAM,EAAA,SAAA;AAAA,UACN,KAAO,EAAA;AAAA,SACR,CAAA;AAAA;AACH,KACD,CAAA;AAAA;AAEL,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"router.cjs.js","sources":["../../src/service/router.ts"],"sourcesContent":["/*\n * Copyright 2023 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 fetch from 'node-fetch';\nimport { Config } from '@backstage/config';\nimport { InputError } from '@backstage/errors';\nimport express from 'express';\nimport Router from 'express-promise-router';\nimport { LoggerService } from '@backstage/backend-plugin-api';\nimport { MiddlewareFactory } from '@backstage/backend-defaults/rootHttpRouter';\n\n/**\n * @deprecated Please migrate to the new backend system as this will be removed in the future.\n *\n * @public */\nexport interface RouterOptions {\n logger: LoggerService;\n config: Config;\n}\n\n/**\n * @deprecated Please migrate to the new backend system as this will be removed in the future.\n *\n * @public */\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const { config, logger } = options;\n\n // Get Nomad addr and token from config\n const addr = config.getString('nomad.addr');\n const token = config.getOptionalString('nomad.token');\n\n const router = Router();\n router.use(express.json());\n\n router.get('/health', (_, resp) => {\n resp.json({ status: 'ok' });\n });\n\n router.get('/v1/allocations', async (req, res) => {\n // Check namespace argument\n const namespace = (req.query.namespace as string) ?? '';\n if (!namespace || namespace === '') {\n throw new InputError(`Missing \"namespace\" query parameter`);\n }\n\n // Check filter argument\n const filter = (req.query.filter as string) ?? '';\n logger.debug(`request headers: namespace=${namespace} filter=${filter}`);\n\n // Issue the request\n const endpoint = `${addr}/v1/allocations?namespace=${encodeURIComponent(\n namespace,\n )}&filter=${encodeURIComponent(filter)}`;\n const allocationsResp = await fetch(endpoint, {\n method: 'GET',\n headers: {\n Accept: 'application/json',\n 'X-Nomad-Token': token || '',\n },\n });\n\n // Check response\n if (allocationsResp.status !== 200) {\n const body = await allocationsResp.text();\n logger.error(`failed to call /v1/allocations endpoint: ${body}`);\n res.status(allocationsResp.status).json({ message: body });\n return;\n }\n\n // Deserialize and return\n const allocationsBody = await allocationsResp.json();\n logger.debug(`/v1/allocations response: ${allocationsBody}`);\n res.json(allocationsBody);\n });\n\n router.get('/v1/job/:job_id/versions', async (req, resp) => {\n // Check namespace argument\n const namespace = (req.query.namespace as string) ?? '';\n if (!namespace || namespace === '') {\n throw new InputError(`Missing \"namespace\" query parameter`);\n }\n\n // Get job ID\n const jobID = (req.params.job_id as string) ?? '';\n\n // Issue the request\n const apiResp = await fetch(\n `${addr}/v1/job/${jobID}/versions?namespace=${encodeURIComponent(\n namespace,\n )}`,\n {\n method: 'GET',\n headers: {\n Accept: 'application/json',\n 'X-Nomad-Token': token || '',\n },\n },\n );\n\n // Check response\n if (apiResp.status !== 200) {\n const body = await apiResp.text();\n logger.error(`failed to call /v1/job/:job_id/versions endpoint: ${body}`);\n resp.status(apiResp.status).json({ message: body });\n return;\n }\n\n // Deserialize and return\n const versionsBody = await apiResp.json();\n logger.debug(`/v1/job/:job_id/versions response: ${versionsBody}`);\n resp.json(versionsBody);\n });\n\n router.use(MiddlewareFactory.create({ config, logger }).error());\n return router;\n}\n"],"names":["Router","express","InputError","fetch","MiddlewareFactory"],"mappings":";;;;;;;;;;;;;;AAqCA,eAAsB,aACpB,OACyB,EAAA;AACzB,EAAM,MAAA,EAAE,MAAQ,EAAA,MAAA,EAAW,GAAA,OAAA;AAG3B,EAAM,MAAA,IAAA,GAAO,MAAO,CAAA,SAAA,CAAU,YAAY,CAAA;AAC1C,EAAM,MAAA,KAAA,GAAQ,MAAO,CAAA,iBAAA,CAAkB,aAAa,CAAA;AAEpD,EAAA,MAAM,SAASA,uBAAO,EAAA;AACtB,EAAO,MAAA,CAAA,GAAA,CAAIC,wBAAQ,CAAA,IAAA,EAAM,CAAA;AAEzB,EAAA,MAAA,CAAO,GAAI,CAAA,SAAA,EAAW,CAAC,CAAA,EAAG,IAAS,KAAA;AACjC,IAAA,IAAA,CAAK,IAAK,CAAA,EAAE,MAAQ,EAAA,IAAA,EAAM,CAAA;AAAA,GAC3B,CAAA;AAED,EAAA,MAAA,CAAO,GAAI,CAAA,iBAAA,EAAmB,OAAO,GAAA,EAAK,GAAQ,KAAA;AAEhD,IAAM,MAAA,SAAA,GAAa,GAAI,CAAA,KAAA,CAAM,SAAwB,IAAA,EAAA;AACrD,IAAI,IAAA,CAAC,SAAa,IAAA,SAAA,KAAc,EAAI,EAAA;AAClC,MAAM,MAAA,IAAI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sourcesContent":["/*\n * Copyright 2023 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 fetch from 'node-fetch';\nimport { Config } from '@backstage/config';\nimport { InputError } from '@backstage/errors';\nimport express from 'express';\nimport Router from 'express-promise-router';\nimport { LoggerService } from '@backstage/backend-plugin-api';\nimport { MiddlewareFactory } from '@backstage/backend-defaults/rootHttpRouter';\n\nexport interface RouterOptions {\n logger: LoggerService;\n config: Config;\n}\n\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const { config, logger } = options;\n\n // Get Nomad addr and token from config\n const addr = config.getString('nomad.addr');\n const token = config.getOptionalString('nomad.token');\n\n const router = Router();\n router.use(express.json());\n\n router.get('/health', (_, resp) => {\n resp.json({ status: 'ok' });\n });\n\n router.get('/v1/allocations', async (req, res) => {\n // Check namespace argument\n const namespace = (req.query.namespace as string) ?? '';\n if (!namespace || namespace === '') {\n throw new InputError(`Missing \"namespace\" query parameter`);\n }\n\n // Check filter argument\n const filter = (req.query.filter as string) ?? '';\n logger.debug(`request headers: namespace=${namespace} filter=${filter}`);\n\n // Issue the request\n const endpoint = `${addr}/v1/allocations?namespace=${encodeURIComponent(\n namespace,\n )}&filter=${encodeURIComponent(filter)}`;\n const allocationsResp = await fetch(endpoint, {\n method: 'GET',\n headers: {\n Accept: 'application/json',\n 'X-Nomad-Token': token || '',\n },\n });\n\n // Check response\n if (allocationsResp.status !== 200) {\n const body = await allocationsResp.text();\n logger.error(`failed to call /v1/allocations endpoint: ${body}`);\n res.status(allocationsResp.status).json({ message: body });\n return;\n }\n\n // Deserialize and return\n const allocationsBody = await allocationsResp.json();\n logger.debug(`/v1/allocations response: ${allocationsBody}`);\n res.json(allocationsBody);\n });\n\n router.get('/v1/job/:job_id/versions', async (req, resp) => {\n // Check namespace argument\n const namespace = (req.query.namespace as string) ?? '';\n if (!namespace || namespace === '') {\n throw new InputError(`Missing \"namespace\" query parameter`);\n }\n\n // Get job ID\n const jobID = (req.params.job_id as string) ?? '';\n\n // Issue the request\n const apiResp = await fetch(\n `${addr}/v1/job/${jobID}/versions?namespace=${encodeURIComponent(\n namespace,\n )}`,\n {\n method: 'GET',\n headers: {\n Accept: 'application/json',\n 'X-Nomad-Token': token || '',\n },\n },\n );\n\n // Check response\n if (apiResp.status !== 200) {\n const body = await apiResp.text();\n logger.error(`failed to call /v1/job/:job_id/versions endpoint: ${body}`);\n resp.status(apiResp.status).json({ message: body });\n return;\n }\n\n // Deserialize and return\n const versionsBody = await apiResp.json();\n logger.debug(`/v1/job/:job_id/versions response: ${versionsBody}`);\n resp.json(versionsBody);\n });\n\n router.use(MiddlewareFactory.create({ config, logger }).error());\n return router;\n}\n"],"names":["Router","express","InputError","fetch","MiddlewareFactory"],"mappings":";;;;;;;;;;;;;;AA6BA,eAAsB,aACpB,OACyB,EAAA;AACzB,EAAM,MAAA,EAAE,MAAQ,EAAA,MAAA,EAAW,GAAA,OAAA;AAG3B,EAAM,MAAA,IAAA,GAAO,MAAO,CAAA,SAAA,CAAU,YAAY,CAAA;AAC1C,EAAM,MAAA,KAAA,GAAQ,MAAO,CAAA,iBAAA,CAAkB,aAAa,CAAA;AAEpD,EAAA,MAAM,SAASA,uBAAO,EAAA;AACtB,EAAO,MAAA,CAAA,GAAA,CAAIC,wBAAQ,CAAA,IAAA,EAAM,CAAA;AAEzB,EAAA,MAAA,CAAO,GAAI,CAAA,SAAA,EAAW,CAAC,CAAA,EAAG,IAAS,KAAA;AACjC,IAAA,IAAA,CAAK,IAAK,CAAA,EAAE,MAAQ,EAAA,IAAA,EAAM,CAAA;AAAA,GAC3B,CAAA;AAED,EAAA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K,YAAY,CAAA;AAAA,GACvB,CAAA;AAED,EAAO,MAAA,CAAA,GAAA,CAAIC,iCAAkB,MAAO,CAAA,EAAE,QAAQ,MAAO,EAAC,CAAE,CAAA,KAAA,EAAO,CAAA;AAC/D,EAAO,OAAA,MAAA;AACT;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage-community/plugin-nomad-backend",
3
- "version": "0.14.0",
3
+ "version": "0.16.0",
4
4
  "backstage": {
5
5
  "role": "backend-plugin",
6
6
  "pluginId": "nomad",
@@ -39,8 +39,8 @@
39
39
  "test": "backstage-cli package test"
40
40
  },
41
41
  "dependencies": {
42
- "@backstage/backend-defaults": "^0.14.0",
43
- "@backstage/backend-plugin-api": "^1.6.0",
42
+ "@backstage/backend-defaults": "^0.15.1",
43
+ "@backstage/backend-plugin-api": "^1.6.2",
44
44
  "@backstage/config": "^1.3.6",
45
45
  "@backstage/errors": "^1.2.7",
46
46
  "@types/express": "*",
@@ -50,9 +50,9 @@
50
50
  "yn": "^4.0.0"
51
51
  },
52
52
  "devDependencies": {
53
- "@backstage/backend-test-utils": "^1.10.2",
54
- "@backstage/cli": "^0.35.1",
55
- "@backstage/plugin-auth-backend": "^0.25.7",
53
+ "@backstage/backend-test-utils": "^1.10.4",
54
+ "@backstage/cli": "^0.35.3",
55
+ "@backstage/plugin-auth-backend": "^0.26.0",
56
56
  "@backstage/plugin-auth-backend-module-guest-provider": "^0.2.15",
57
57
  "@types/node-fetch": "^2.5.12",
58
58
  "@types/supertest": "^6.0.0",