@backstage-community/plugin-ocm-backend 5.3.0 → 5.4.1
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 +12 -0
- package/dist/helpers/kubernetes.cjs.js +40 -40
- package/dist/helpers/kubernetes.cjs.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
### Dependencies
|
|
2
2
|
|
|
3
|
+
## 5.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f1017d0: Updated dependency `@openapitools/openapi-generator-cli` to `2.16.3`.
|
|
8
|
+
|
|
9
|
+
## 5.4.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 7bed8e0: Update @kubernetes/client-node.
|
|
14
|
+
|
|
3
15
|
## 5.3.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -35,66 +35,66 @@ const hubApiClient = (clusterConfig, logger) => {
|
|
|
35
35
|
return kubeConfig.makeApiClient(clientNode.CustomObjectsApi);
|
|
36
36
|
};
|
|
37
37
|
const kubeApiResponseHandler = (call) => {
|
|
38
|
-
return call.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
38
|
+
return call.catch((e) => {
|
|
39
|
+
if ("body" in e && typeof e.body === "string") {
|
|
40
|
+
let body;
|
|
41
|
+
try {
|
|
42
|
+
body = JSON.parse(e.body);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
}
|
|
45
|
+
if (body) {
|
|
46
|
+
throw Object.assign(new Error(body.reason), {
|
|
47
|
+
// Name and statusCode are required by the backstage error handler
|
|
48
|
+
statusCode: body.code,
|
|
49
|
+
name: body.reason,
|
|
50
|
+
...body
|
|
51
|
+
});
|
|
52
|
+
}
|
|
52
53
|
}
|
|
53
|
-
throw Object.assign(new Error(
|
|
54
|
-
//
|
|
55
|
-
statusCode:
|
|
56
|
-
name:
|
|
57
|
-
...r.body
|
|
54
|
+
throw Object.assign(new Error(e.message), {
|
|
55
|
+
// If there is no body, default to 500
|
|
56
|
+
statusCode: 500,
|
|
57
|
+
name: e.message
|
|
58
58
|
});
|
|
59
59
|
});
|
|
60
60
|
};
|
|
61
61
|
const getManagedCluster = (api, name) => {
|
|
62
62
|
return kubeApiResponseHandler(
|
|
63
|
-
api.getClusterCustomObject(
|
|
64
|
-
"
|
|
65
|
-
"v1",
|
|
66
|
-
"
|
|
63
|
+
api.getClusterCustomObject({
|
|
64
|
+
plural: "managedclusters",
|
|
65
|
+
version: "v1",
|
|
66
|
+
group: "cluster.open-cluster-management.io",
|
|
67
67
|
name
|
|
68
|
-
)
|
|
68
|
+
})
|
|
69
69
|
);
|
|
70
70
|
};
|
|
71
71
|
const listManagedClusters = (api) => {
|
|
72
72
|
return kubeApiResponseHandler(
|
|
73
|
-
api.listClusterCustomObject(
|
|
74
|
-
"cluster.open-cluster-management.io",
|
|
75
|
-
"v1",
|
|
76
|
-
"managedclusters"
|
|
77
|
-
)
|
|
73
|
+
api.listClusterCustomObject({
|
|
74
|
+
group: "cluster.open-cluster-management.io",
|
|
75
|
+
version: "v1",
|
|
76
|
+
plural: "managedclusters"
|
|
77
|
+
})
|
|
78
78
|
);
|
|
79
79
|
};
|
|
80
80
|
const getManagedClusterInfo = (api, name) => {
|
|
81
81
|
return kubeApiResponseHandler(
|
|
82
|
-
api.getNamespacedCustomObject(
|
|
83
|
-
"internal.open-cluster-management.io",
|
|
84
|
-
"v1beta1",
|
|
82
|
+
api.getNamespacedCustomObject({
|
|
83
|
+
group: "internal.open-cluster-management.io",
|
|
84
|
+
version: "v1beta1",
|
|
85
85
|
name,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
)
|
|
86
|
+
namespace: name,
|
|
87
|
+
plural: "managedclusterinfos"
|
|
88
|
+
})
|
|
89
89
|
);
|
|
90
90
|
};
|
|
91
91
|
const listManagedClusterInfos = (api) => {
|
|
92
92
|
return kubeApiResponseHandler(
|
|
93
|
-
api.listClusterCustomObject(
|
|
94
|
-
"internal.open-cluster-management.io",
|
|
95
|
-
"v1beta1",
|
|
96
|
-
"managedclusterinfos"
|
|
97
|
-
)
|
|
93
|
+
api.listClusterCustomObject({
|
|
94
|
+
group: "internal.open-cluster-management.io",
|
|
95
|
+
version: "v1beta1",
|
|
96
|
+
plural: "managedclusterinfos"
|
|
97
|
+
})
|
|
98
98
|
);
|
|
99
99
|
};
|
|
100
100
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kubernetes.cjs.js","sources":["../../src/helpers/kubernetes.ts"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport { LoggerService } from '@backstage/backend-plugin-api';\n\nimport {\n CustomObjectsApi,\n KubeConfig,\n KubernetesListObject,\n} from '@kubernetes/client-node';\n\nimport
|
|
1
|
+
{"version":3,"file":"kubernetes.cjs.js","sources":["../../src/helpers/kubernetes.ts"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport { LoggerService } from '@backstage/backend-plugin-api';\n\nimport {\n CustomObjectsApi,\n KubeConfig,\n KubernetesListObject,\n} from '@kubernetes/client-node';\n\nimport { ManagedCluster, ManagedClusterInfo, OcmConfig } from '../types';\n\nexport const hubApiClient = (\n clusterConfig: OcmConfig,\n logger: LoggerService,\n): CustomObjectsApi => {\n const kubeConfig = new KubeConfig();\n\n if (!clusterConfig.serviceAccountToken) {\n logger.info('Using default kubernetes config');\n kubeConfig.loadFromDefault();\n return kubeConfig.makeApiClient(CustomObjectsApi);\n }\n\n logger.info('Loading kubernetes config from config file');\n\n const user = {\n name: 'backstage',\n token: clusterConfig.serviceAccountToken,\n };\n\n const context = {\n name: clusterConfig.hubResourceName,\n user: user.name,\n cluster: clusterConfig.hubResourceName,\n };\n\n kubeConfig.loadFromOptions({\n clusters: [\n {\n server: clusterConfig.url,\n name: clusterConfig.hubResourceName,\n skipTLSVerify: clusterConfig.skipTLSVerify,\n caData: clusterConfig.caData,\n },\n ],\n users: [user],\n contexts: [context],\n currentContext: context.name,\n });\n return kubeConfig.makeApiClient(CustomObjectsApi);\n};\n\nconst kubeApiResponseHandler = <T>(call: Promise<T>) => {\n return call.catch(e => {\n // r.body should be string or blob binary\n if ('body' in e && typeof e.body === 'string') {\n let body;\n try {\n body = JSON.parse(e.body);\n } catch (error) {\n /* eslint-disable-line no-empty */\n }\n if (body) {\n throw Object.assign(new Error(body.reason), {\n // Name and statusCode are required by the backstage error handler\n statusCode: body.code,\n name: body.reason,\n ...body,\n });\n }\n }\n\n throw Object.assign(new Error(e.message), {\n // If there is no body, default to 500\n statusCode: 500,\n name: e.message,\n });\n });\n};\n\nexport const getManagedCluster = (api: CustomObjectsApi, name: string) => {\n return kubeApiResponseHandler<ManagedCluster>(\n api.getClusterCustomObject({\n plural: 'managedclusters',\n version: 'v1',\n group: 'cluster.open-cluster-management.io',\n name,\n }),\n );\n};\n\nexport const listManagedClusters = (api: CustomObjectsApi) => {\n return kubeApiResponseHandler<KubernetesListObject<ManagedCluster>>(\n api.listClusterCustomObject({\n group: 'cluster.open-cluster-management.io',\n version: 'v1',\n plural: 'managedclusters',\n }),\n );\n};\n\nexport const getManagedClusterInfo = (api: CustomObjectsApi, name: string) => {\n return kubeApiResponseHandler<ManagedClusterInfo>(\n api.getNamespacedCustomObject({\n group: 'internal.open-cluster-management.io',\n version: 'v1beta1',\n name,\n namespace: name,\n plural: 'managedclusterinfos',\n }),\n );\n};\n\nexport const listManagedClusterInfos = (api: CustomObjectsApi) => {\n return kubeApiResponseHandler<KubernetesListObject<ManagedClusterInfo>>(\n api.listClusterCustomObject({\n group: 'internal.open-cluster-management.io',\n version: 'v1beta1',\n plural: 'managedclusterinfos',\n }),\n );\n};\n"],"names":["KubeConfig","CustomObjectsApi"],"mappings":";;;;AAyBa,MAAA,YAAA,GAAe,CAC1B,aAAA,EACA,MACqB,KAAA;AACrB,EAAM,MAAA,UAAA,GAAa,IAAIA,qBAAW,EAAA;AAElC,EAAI,IAAA,CAAC,cAAc,mBAAqB,EAAA;AACtC,IAAA,MAAA,CAAO,KAAK,iCAAiC,CAAA;AAC7C,IAAA,UAAA,CAAW,eAAgB,EAAA;AAC3B,IAAO,OAAA,UAAA,CAAW,cAAcC,2BAAgB,CAAA;AAAA;AAGlD,EAAA,MAAA,CAAO,KAAK,4CAA4C,CAAA;AAExD,EAAA,MAAM,IAAO,GAAA;AAAA,IACX,IAAM,EAAA,WAAA;AAAA,IACN,OAAO,aAAc,CAAA;AAAA,GACvB;AAEA,EAAA,MAAM,OAAU,GAAA;AAAA,IACd,MAAM,aAAc,CAAA,eAAA;AAAA,IACpB,MAAM,IAAK,CAAA,IAAA;AAAA,IACX,SAAS,aAAc,CAAA;AAAA,GACzB;AAEA,EAAA,UAAA,CAAW,eAAgB,CAAA;AAAA,IACzB,QAAU,EAAA;AAAA,MACR;AAAA,QACE,QAAQ,aAAc,CAAA,GAAA;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S,EAAA,IAAA;AAAA,MACT,KAAO,EAAA,oCAAA;AAAA,MACP;AAAA,KACD;AAAA,GACH;AACF;AAEa,MAAA,mBAAA,GAAsB,CAAC,GAA0B,KAAA;AAC5D,EAAO,OAAA,sBAAA;AAAA,IACL,IAAI,uBAAwB,CAAA;AAAA,MAC1B,KAAO,EAAA,oCAAA;AAAA,MACP,OAAS,EAAA,IAAA;AAAA,MACT,MAAQ,EAAA;AAAA,KACT;AAAA,GACH;AACF;AAEa,MAAA,qBAAA,GAAwB,CAAC,GAAA,EAAuB,IAAiB,KAAA;AAC5E,EAAO,OAAA,sBAAA;AAAA,IACL,IAAI,yBAA0B,CAAA;AAAA,MAC5B,KAAO,EAAA,qCAAA;AAAA,MACP,OAAS,EAAA,SAAA;AAAA,MACT,IAAA;AAAA,MACA,SAAW,EAAA,IAAA;AAAA,MACX,MAAQ,EAAA;AAAA,KACT;AAAA,GACH;AACF;AAEa,MAAA,uBAAA,GAA0B,CAAC,GAA0B,KAAA;AAChE,EAAO,OAAA,sBAAA;AAAA,IACL,IAAI,uBAAwB,CAAA;AAAA,MAC1B,KAAO,EAAA,qCAAA;AAAA,MACP,OAAS,EAAA,SAAA;AAAA,MACT,MAAQ,EAAA;AAAA,KACT;AAAA,GACH;AACF;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage-community/plugin-ocm-backend",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.1",
|
|
4
4
|
"main": "./dist/index.cjs.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@backstage/plugin-catalog-node": "^1.15.1",
|
|
60
60
|
"@backstage/plugin-permission-common": "^0.8.4",
|
|
61
61
|
"@backstage/plugin-permission-node": "^0.8.7",
|
|
62
|
-
"@kubernetes/client-node": "
|
|
62
|
+
"@kubernetes/client-node": "1.0.0-rc7",
|
|
63
63
|
"express": "^4.18.2",
|
|
64
64
|
"semver": "^7.5.4"
|
|
65
65
|
},
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"@backstage/cli": "^0.29.5",
|
|
70
70
|
"@backstage/config": "^1.3.2",
|
|
71
71
|
"@backstage/plugin-catalog-backend": "^1.30.0",
|
|
72
|
-
"@openapitools/openapi-generator-cli": "2.
|
|
72
|
+
"@openapitools/openapi-generator-cli": "2.16.3",
|
|
73
73
|
"@spotify/prettier-config": "^15.0.0",
|
|
74
74
|
"@types/express": "4.17.21",
|
|
75
75
|
"@types/supertest": "2.0.16",
|