@backstage-community/plugin-scaffolder-backend-module-kubernetes 2.7.0 → 2.8.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,11 @@
1
1
  ### Dependencies
2
2
 
3
+ ## 2.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 698f577: Backstage version bump to v1.39.0
8
+
3
9
  ## 2.7.0
4
10
 
5
11
  ### Minor Changes
@@ -2,6 +2,8 @@
2
2
 
3
3
  var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
4
4
  var clientNode = require('@kubernetes/client-node');
5
+ var zod = require('zod');
6
+ var createKubernetesNamespace_examples = require('./createKubernetesNamespace.examples.cjs.js');
5
7
 
6
8
  const KUBERNETES_API_URL_ANNOTATION = "kubernetes.io/api-server";
7
9
  const KUBERNETES_CLUSTER_TYPE = "kubernetes-cluster";
@@ -65,51 +67,29 @@ function createKubernetesNamespaceAction(catalogClient) {
65
67
  return pluginScaffolderNode.createTemplateAction({
66
68
  id: "kubernetes:create-namespace",
67
69
  description: "Creates a kubernetes namespace",
70
+ examples: createKubernetesNamespace_examples.examples,
68
71
  schema: {
69
- input: {
70
- type: "object",
71
- oneOf: [
72
- { required: ["namespace", "token", "url"] },
73
- { required: ["namespace", "token", "clusterRef"] }
74
- ],
75
- properties: {
76
- namespace: {
77
- title: "Namespace name",
78
- description: "Name of the namespace to be created",
79
- type: "string"
80
- },
81
- clusterRef: {
82
- title: "Cluster entity reference",
83
- description: "Cluster resource entity reference from the catalog",
84
- type: "string"
85
- },
86
- url: {
87
- title: "Url",
88
- description: "Url of the kubernetes API, will be used if clusterRef is not provided",
89
- type: "string"
90
- },
91
- token: {
92
- title: "Token",
93
- description: "Bearer token to authenticate with",
94
- type: "string"
95
- },
96
- skipTLSVerify: {
97
- title: "Skip TLS verification",
98
- description: "Skip TLS certificate verification, not recommended to use in production environment, defaults to false",
99
- type: "boolean"
100
- },
101
- caData: {
102
- title: "CA Data",
103
- description: "Certificate Authority base64 encoded certificate",
104
- type: "string"
105
- },
106
- labels: {
107
- title: "Labels",
108
- description: "Labels that will be applied to the namespace.",
109
- type: "string"
110
- }
72
+ input: zod.z.object({
73
+ namespace: zod.z.string().describe("Name of the namespace to be created"),
74
+ token: zod.z.string().describe("Bearer token to authenticate with"),
75
+ clusterRef: zod.z.string().optional().describe("Cluster resource entity reference from the catalog"),
76
+ url: zod.z.string().optional().describe(
77
+ "Url of the kubernetes API, will be used if clusterRef is not provided"
78
+ ),
79
+ skipTLSVerify: zod.z.boolean().optional().default(false).describe(
80
+ "Skip TLS certificate verification, not recommended to use in production environment, defaults to false"
81
+ ),
82
+ caData: zod.z.string().optional().describe("Certificate Authority base64 encoded certificate"),
83
+ labels: zod.z.string().optional().describe("Labels that will be applied to the namespace.")
84
+ }).superRefine((data, ctx) => {
85
+ if (!data.clusterRef && !data.url) {
86
+ ctx.addIssue({
87
+ code: zod.z.ZodIssueCode.custom,
88
+ message: "Either clusterRef or url must be provided",
89
+ path: ["clusterRef", "url"]
90
+ });
111
91
  }
112
- }
92
+ })
113
93
  },
114
94
  async handler(ctx) {
115
95
  const {
@@ -1 +1 @@
1
- {"version":3,"file":"createKubernetesNamespace.cjs.js","sources":["../../src/actions/createKubernetesNamespace.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 { CatalogClient } from '@backstage/catalog-client';\nimport type { Entity } from '@backstage/catalog-model';\nimport {\n createTemplateAction,\n type ActionContext,\n} from '@backstage/plugin-scaffolder-node';\n\nimport {\n CoreV1Api,\n CoreV1ApiCreateNamespaceRequest,\n KubeConfig,\n} from '@kubernetes/client-node';\n\nconst KUBERNETES_API_URL_ANNOTATION = 'kubernetes.io/api-server';\nconst KUBERNETES_CLUSTER_TYPE = 'kubernetes-cluster';\n\nexport interface HttpErrorBody {\n kind: string;\n apiVersion: string;\n metadata: Object;\n status: string;\n message: string;\n reason: string;\n details: { name: string; kind: string };\n code: number;\n}\n\ntype TemplateActionParameters = {\n namespace: string;\n clusterRef?: string;\n url?: string;\n token: string;\n skipTLSVerify?: boolean;\n caData?: string;\n labels?: string;\n};\n\nconst getUrlFromClusterRef = async (\n ctx: ActionContext<TemplateActionParameters>,\n catalogClient: CatalogClient,\n clusterRef: string,\n): Promise<string> => {\n const isResource = clusterRef.startsWith('resource:');\n if (!isResource) {\n ctx.logger.warn(\n 'Cluster reference in the wrong format, attempting to fix it',\n );\n }\n const catalogEntity: Entity | undefined = await catalogClient.getEntityByRef(\n isResource ? clusterRef : `resource:${clusterRef}`,\n );\n if (!catalogEntity) {\n throw new Error('Resource not found');\n }\n if (catalogEntity.spec?.type !== KUBERNETES_CLUSTER_TYPE) {\n ctx.logger.warn(`Resource is not of ${KUBERNETES_CLUSTER_TYPE} type`);\n }\n const apiUrl =\n catalogEntity.metadata?.annotations?.[KUBERNETES_API_URL_ANNOTATION];\n if (!apiUrl) {\n throw new Error(\n `Cluster resource is missing ${KUBERNETES_API_URL_ANNOTATION} annotation`,\n );\n }\n return apiUrl;\n};\n\nconst validateUrl = (url: string | undefined = '') => {\n try {\n // eslint-disable-next-line no-new\n new URL(url);\n } catch (error) {\n throw new Error(`\"${url}\" is an invalid url`);\n }\n};\n\nexport const convertLabelsToObject = (\n labelsString: string | undefined,\n): { [key: string]: string } => {\n const result: { [key: string]: string } = {};\n\n if (!labelsString || labelsString.indexOf('=') === -1) {\n console.error(\n \"Invalid label string. Label string must contain at least one label separated by '=' character.\",\n );\n return result;\n }\n\n const labelsArray = labelsString.split(';');\n\n labelsArray.forEach(label => {\n const separatorIndex = label.indexOf('=');\n if (separatorIndex !== -1) {\n const key = label.slice(0, separatorIndex).trim();\n const value = label.slice(separatorIndex + 1).trim();\n if (key && value) {\n result[key] = value;\n }\n } else {\n console.error(\n `Invalid label: '${label}'. Label must contain at least one '=' character.`,\n );\n }\n });\n\n return result;\n};\n\nexport function createKubernetesNamespaceAction(catalogClient: CatalogClient) {\n return createTemplateAction<TemplateActionParameters>({\n id: 'kubernetes:create-namespace',\n description: 'Creates a kubernetes namespace',\n schema: {\n input: {\n type: 'object',\n oneOf: [\n { required: ['namespace', 'token', 'url'] },\n { required: ['namespace', 'token', 'clusterRef'] },\n ],\n properties: {\n namespace: {\n title: 'Namespace name',\n description: 'Name of the namespace to be created',\n type: 'string',\n },\n clusterRef: {\n title: 'Cluster entity reference',\n description: 'Cluster resource entity reference from the catalog',\n type: 'string',\n },\n url: {\n title: 'Url',\n description:\n 'Url of the kubernetes API, will be used if clusterRef is not provided',\n type: 'string',\n },\n token: {\n title: 'Token',\n description: 'Bearer token to authenticate with',\n type: 'string',\n },\n skipTLSVerify: {\n title: 'Skip TLS verification',\n description:\n 'Skip TLS certificate verification, not recommended to use in production environment, defaults to false',\n type: 'boolean',\n },\n caData: {\n title: 'CA Data',\n description: 'Certificate Authority base64 encoded certificate',\n type: 'string',\n },\n labels: {\n title: 'Labels',\n description: 'Labels that will be applied to the namespace.',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n namespace,\n clusterRef,\n token,\n url,\n skipTLSVerify,\n caData,\n labels,\n } = ctx.input;\n const kubeConfig = new KubeConfig();\n const name = 'backstage';\n const cluster = {\n server: '',\n name,\n serviceAccountToken: token,\n skipTLSVerify: skipTLSVerify || false,\n caData,\n };\n\n if (clusterRef && url) {\n throw new Error(\n \"Cluster reference and url can't be specified at the same time\",\n );\n }\n\n if (!clusterRef && !url) {\n throw new Error('Cluster reference or url are required');\n }\n\n if (clusterRef) {\n cluster.server = await getUrlFromClusterRef(\n ctx,\n catalogClient,\n clusterRef,\n );\n } else {\n validateUrl(url);\n cluster.server = url!;\n }\n\n kubeConfig.loadFromOptions({\n clusters: [cluster],\n users: [{ name, token }],\n contexts: [\n {\n name,\n user: name,\n cluster: name,\n },\n ],\n currentContext: name,\n });\n\n const namespaceLabels = convertLabelsToObject(labels);\n\n const api = kubeConfig.makeApiClient(CoreV1Api);\n const k8sNamespace: CoreV1ApiCreateNamespaceRequest = {\n body: {\n metadata: {\n name: namespace,\n labels: namespaceLabels,\n },\n },\n };\n await api.createNamespace(k8sNamespace).catch((e: Error) => {\n // e.body should be string or blob binary\n if ('body' in e && typeof e.body === 'string') {\n let body: HttpErrorBody | undefined;\n try {\n body = JSON.parse(e.body);\n } catch (error) {\n /* eslint-disable-line no-empty */\n }\n if (body) {\n throw new Error(\n `Failed to create kubernetes namespace, API code: ${body.code} -- ${body.message}`,\n );\n }\n }\n\n throw new Error(`Failed to create kubernetes namespace, ${e.message}`);\n });\n },\n });\n}\n"],"names":["createTemplateAction","KubeConfig","CoreV1Api"],"mappings":";;;;;AA4BA,MAAM,6BAAgC,GAAA,0BAAA;AACtC,MAAM,uBAA0B,GAAA,oBAAA;AAuBhC,MAAM,oBAAuB,GAAA,OAC3B,GACA,EAAA,aAAA,EACA,UACoB,KAAA;AACpB,EAAM,MAAA,UAAA,GAAa,UAAW,CAAA,UAAA,CAAW,WAAW,CAAA;AACpD,EAAA,IAAI,CAAC,UAAY,EAAA;AACf,IAAA,GAAA,CAAI,MAAO,CAAA,IAAA;AAAA,MACT;AAAA,KACF;AAAA;AAEF,EAAM,MAAA,aAAA,GAAoC,MAAM,aAAc,CAAA,cAAA;AAAA,IAC5D,UAAA,GAAa,UAAa,GAAA,CAAA,SAAA,EAAY,UAAU,CAAA;AAAA,GAClD;AACA,EAAA,IAAI,CAAC,aAAe,EAAA;AAClB,IAAM,MAAA,IAAI,MAAM,oBAAoB,CAAA;AAAA;AAEtC,EAAI,IAAA,aAAA,CAAc,IAAM,EAA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C,OAAO,CAAA;AAAA,QAClB,KAAO,EAAA,CAAC,EAAE,IAAA,EAAM,OAAO,CAAA;AAAA,QACvB,QAAU,EAAA;AAAA,UACR;AAAA,YACE,IAAA;AAAA,YACA,IAAM,EAAA,IAAA;AAAA,YACN,OAAS,EAAA;AAAA;AACX,SACF;AAAA,QACA,cAAgB,EAAA;AAAA,OACjB,CAAA;AAED,MAAM,MAAA,eAAA,GAAkB,sBAAsB,MAAM,CAAA;AAEpD,MAAM,MAAA,GAAA,GAAM,UAAW,CAAA,aAAA,CAAcC,oBAAS,CAAA;AAC9C,MAAA,MAAM,YAAgD,GAAA;AAAA,QACpD,IAAM,EAAA;AAAA,UACJ,QAAU,EAAA;AAAA,YACR,IAAM,EAAA,SAAA;AAAA,YACN,MAAQ,EAAA;AAAA;AACV;AACF,OACF;AACA,MAAA,MAAM,IAAI,eAAgB,CAAA,YAAY,CAAE,CAAA,KAAA,CAAM,CAAC,CAAa,KAAA;AAE1D,QAAA,IAAI,MAAU,IAAA,CAAA,IAAK,OAAO,CAAA,CAAE,SAAS,QAAU,EAAA;AAC7C,UAAI,IAAA,IAAA;AACJ,UAAI,IAAA;AACF,YAAO,IAAA,GAAA,IAAA,CAAK,KAAM,CAAA,CAAA,CAAE,IAAI,CAAA;AAAA,mBACjB,KAAO,EAAA;AAAA;AAGhB,UAAA,IAAI,IAAM,EAAA;AACR,YAAA,MAAM,IAAI,KAAA;AAAA,cACR,CAAoD,iDAAA,EAAA,IAAA,CAAK,IAAI,CAAA,IAAA,EAAO,KAAK,OAAO,CAAA;AAAA,aAClF;AAAA;AACF;AAGF,QAAA,MAAM,IAAI,KAAA,CAAM,CAA0C,uCAAA,EAAA,CAAA,CAAE,OAAO,CAAE,CAAA,CAAA;AAAA,OACtE,CAAA;AAAA;AACH,GACD,CAAA;AACH;;;;;"}
1
+ {"version":3,"file":"createKubernetesNamespace.cjs.js","sources":["../../src/actions/createKubernetesNamespace.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 { CatalogClient } from '@backstage/catalog-client';\nimport type { Entity } from '@backstage/catalog-model';\nimport {\n createTemplateAction,\n type ActionContext,\n} from '@backstage/plugin-scaffolder-node';\n\nimport {\n CoreV1Api,\n CoreV1ApiCreateNamespaceRequest,\n KubeConfig,\n} from '@kubernetes/client-node';\nimport { z } from 'zod';\nimport { examples } from './createKubernetesNamespace.examples';\n\nconst KUBERNETES_API_URL_ANNOTATION = 'kubernetes.io/api-server';\nconst KUBERNETES_CLUSTER_TYPE = 'kubernetes-cluster';\n\nexport interface HttpErrorBody {\n kind: string;\n apiVersion: string;\n metadata: Object;\n status: string;\n message: string;\n reason: string;\n details: { name: string; kind: string };\n code: number;\n}\n\ntype TemplateActionParameters = {\n namespace: string;\n clusterRef?: string;\n url?: string;\n token: string;\n skipTLSVerify?: boolean;\n caData?: string;\n labels?: string;\n};\n\nconst getUrlFromClusterRef = async (\n ctx: ActionContext<TemplateActionParameters>,\n catalogClient: CatalogClient,\n clusterRef: string,\n): Promise<string> => {\n const isResource = clusterRef.startsWith('resource:');\n if (!isResource) {\n ctx.logger.warn(\n 'Cluster reference in the wrong format, attempting to fix it',\n );\n }\n const catalogEntity: Entity | undefined = await catalogClient.getEntityByRef(\n isResource ? clusterRef : `resource:${clusterRef}`,\n );\n if (!catalogEntity) {\n throw new Error('Resource not found');\n }\n if (catalogEntity.spec?.type !== KUBERNETES_CLUSTER_TYPE) {\n ctx.logger.warn(`Resource is not of ${KUBERNETES_CLUSTER_TYPE} type`);\n }\n const apiUrl =\n catalogEntity.metadata?.annotations?.[KUBERNETES_API_URL_ANNOTATION];\n if (!apiUrl) {\n throw new Error(\n `Cluster resource is missing ${KUBERNETES_API_URL_ANNOTATION} annotation`,\n );\n }\n return apiUrl;\n};\n\nconst validateUrl = (url: string | undefined = '') => {\n try {\n // eslint-disable-next-line no-new\n new URL(url);\n } catch (error) {\n throw new Error(`\"${url}\" is an invalid url`);\n }\n};\n\nexport const convertLabelsToObject = (\n labelsString: string | undefined,\n): { [key: string]: string } => {\n const result: { [key: string]: string } = {};\n\n if (!labelsString || labelsString.indexOf('=') === -1) {\n console.error(\n \"Invalid label string. Label string must contain at least one label separated by '=' character.\",\n );\n return result;\n }\n\n const labelsArray = labelsString.split(';');\n\n labelsArray.forEach(label => {\n const separatorIndex = label.indexOf('=');\n if (separatorIndex !== -1) {\n const key = label.slice(0, separatorIndex).trim();\n const value = label.slice(separatorIndex + 1).trim();\n if (key && value) {\n result[key] = value;\n }\n } else {\n console.error(\n `Invalid label: '${label}'. Label must contain at least one '=' character.`,\n );\n }\n });\n\n return result;\n};\n\n/**\n * @public\n */\nexport function createKubernetesNamespaceAction(catalogClient: CatalogClient) {\n return createTemplateAction<TemplateActionParameters>({\n id: 'kubernetes:create-namespace',\n description: 'Creates a kubernetes namespace',\n examples,\n schema: {\n input: z\n .object({\n namespace: z.string().describe('Name of the namespace to be created'),\n token: z.string().describe('Bearer token to authenticate with'),\n clusterRef: z\n .string()\n .optional()\n .describe('Cluster resource entity reference from the catalog'),\n url: z\n .string()\n .optional()\n .describe(\n 'Url of the kubernetes API, will be used if clusterRef is not provided',\n ),\n skipTLSVerify: z\n .boolean()\n .optional()\n .default(false)\n .describe(\n 'Skip TLS certificate verification, not recommended to use in production environment, defaults to false',\n ),\n caData: z\n .string()\n .optional()\n .describe('Certificate Authority base64 encoded certificate'),\n labels: z\n .string()\n .optional()\n .describe('Labels that will be applied to the namespace.'),\n })\n .superRefine((data, ctx) => {\n if (!data.clusterRef && !data.url) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Either clusterRef or url must be provided',\n path: ['clusterRef', 'url'],\n });\n }\n }),\n },\n async handler(ctx) {\n const {\n namespace,\n clusterRef,\n token,\n url,\n skipTLSVerify,\n caData,\n labels,\n } = ctx.input;\n const kubeConfig = new KubeConfig();\n const name = 'backstage';\n const cluster = {\n server: '',\n name,\n serviceAccountToken: token,\n skipTLSVerify: skipTLSVerify || false,\n caData,\n };\n\n if (clusterRef && url) {\n throw new Error(\n \"Cluster reference and url can't be specified at the same time\",\n );\n }\n\n if (!clusterRef && !url) {\n throw new Error('Cluster reference or url are required');\n }\n\n if (clusterRef) {\n cluster.server = await getUrlFromClusterRef(\n ctx,\n catalogClient,\n clusterRef,\n );\n } else {\n validateUrl(url);\n cluster.server = url!;\n }\n\n kubeConfig.loadFromOptions({\n clusters: [cluster],\n users: [{ name, token }],\n contexts: [\n {\n name,\n user: name,\n cluster: name,\n },\n ],\n currentContext: name,\n });\n\n const namespaceLabels = convertLabelsToObject(labels);\n\n const api = kubeConfig.makeApiClient(CoreV1Api);\n const k8sNamespace: CoreV1ApiCreateNamespaceRequest = {\n body: {\n metadata: {\n name: namespace,\n labels: namespaceLabels,\n },\n },\n };\n await api.createNamespace(k8sNamespace).catch((e: Error) => {\n // e.body should be string or blob binary\n if ('body' in e && typeof e.body === 'string') {\n let body: HttpErrorBody | undefined;\n try {\n body = JSON.parse(e.body);\n } catch (error) {\n /* eslint-disable-line no-empty */\n }\n if (body) {\n throw new Error(\n `Failed to create kubernetes namespace, API code: ${body.code} -- ${body.message}`,\n );\n }\n }\n\n throw new Error(`Failed to create kubernetes namespace, ${e.message}`);\n });\n },\n });\n}\n"],"names":["createTemplateAction","examples","z","KubeConfig","CoreV1Api"],"mappings":";;;;;;;AA8BA,MAAM,6BAAgC,GAAA,0BAAA;AACtC,MAAM,uBAA0B,GAAA,oBAAA;AAuBhC,MAAM,oBAAuB,GAAA,OAC3B,GACA,EAAA,aAAA,EACA,UACoB,KAAA;AACpB,EAAM,MAAA,UAAA,G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AK,IAAI,CAAA,IAAA,EAAO,KAAK,OAAO,CAAA;AAAA,aAClF;AAAA;AACF;AAGF,QAAA,MAAM,IAAI,KAAA,CAAM,CAA0C,uCAAA,EAAA,CAAA,CAAE,OAAO,CAAE,CAAA,CAAA;AAAA,OACtE,CAAA;AAAA;AACH,GACD,CAAA;AACH;;;;;"}
@@ -0,0 +1,65 @@
1
+ 'use strict';
2
+
3
+ var yaml = require('yaml');
4
+
5
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
6
+
7
+ var yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
8
+
9
+ const examples = [
10
+ {
11
+ description: "Creates a namespace in the Kubernetes cluster using url.",
12
+ example: yaml__default.default.stringify({
13
+ steps: [
14
+ {
15
+ id: "create-kubernetes-namespace",
16
+ action: "kubernetes:create-namespace",
17
+ name: "Create Kubernetes namespace",
18
+ input: {
19
+ namespace: "example-namespace",
20
+ token: "YOUR_AUTH_TOKEN",
21
+ url: "https://api.foo.example.com:6443"
22
+ }
23
+ }
24
+ ]
25
+ })
26
+ },
27
+ {
28
+ description: "Creates a namespace in the Kubernetes cluster using clusterRef.",
29
+ example: yaml__default.default.stringify({
30
+ steps: [
31
+ {
32
+ id: "create-kubernetes-namespace",
33
+ action: "kubernetes:create-namespace",
34
+ name: "Create Kubernetes namespace",
35
+ input: {
36
+ namespace: "example-namespace",
37
+ token: "YOUR_AUTH_TOKEN",
38
+ clusterRef: "resource:default/kubernetes-cluster-entity"
39
+ }
40
+ }
41
+ ]
42
+ })
43
+ },
44
+ {
45
+ description: "Creates a namespace in the Kubernetes cluster with labels.",
46
+ example: yaml__default.default.stringify({
47
+ steps: [
48
+ {
49
+ id: "create-kubernetes-namespace",
50
+ action: "kubernetes:create-namespace",
51
+ name: "Create Kubernetes namespace",
52
+ input: {
53
+ namespace: "my-namespace",
54
+ token: "YOUR_AUTH_TOKEN",
55
+ url: "https://api.foo.example.com:6443",
56
+ labels: "kubernetes.io/type=namespace;app.io/managed-by=org"
57
+ }
58
+ }
59
+ ]
60
+ })
61
+ }
62
+ ];
63
+
64
+ exports.examples = examples;
65
+ //# sourceMappingURL=createKubernetesNamespace.examples.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createKubernetesNamespace.examples.cjs.js","sources":["../../src/actions/createKubernetesNamespace.examples.ts"],"sourcesContent":["/*\n * Copyright 2025 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Creates a namespace in the Kubernetes cluster using url.',\n example: yaml.stringify({\n steps: [\n {\n id: 'create-kubernetes-namespace',\n action: 'kubernetes:create-namespace',\n name: 'Create Kubernetes namespace',\n input: {\n namespace: 'example-namespace',\n token: 'YOUR_AUTH_TOKEN',\n url: 'https://api.foo.example.com:6443',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Creates a namespace in the Kubernetes cluster using clusterRef.',\n example: yaml.stringify({\n steps: [\n {\n id: 'create-kubernetes-namespace',\n action: 'kubernetes:create-namespace',\n name: 'Create Kubernetes namespace',\n input: {\n namespace: 'example-namespace',\n token: 'YOUR_AUTH_TOKEN',\n clusterRef: 'resource:default/kubernetes-cluster-entity',\n },\n },\n ],\n }),\n },\n {\n description: 'Creates a namespace in the Kubernetes cluster with labels.',\n example: yaml.stringify({\n steps: [\n {\n id: 'create-kubernetes-namespace',\n action: 'kubernetes:create-namespace',\n name: 'Create Kubernetes namespace',\n input: {\n namespace: 'my-namespace',\n token: 'YOUR_AUTH_TOKEN',\n url: 'https://api.foo.example.com:6443',\n labels: 'kubernetes.io/type=namespace;app.io/managed-by=org',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,0DAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,6BAAA;AAAA,UACJ,MAAQ,EAAA,6BAAA;AAAA,UACR,IAAM,EAAA,6BAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,SAAW,EAAA,mBAAA;AAAA,YACX,KAAO,EAAA,iBAAA;AAAA,YACP,GAAK,EAAA;AAAA;AACP;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WACE,EAAA,iEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,6BAAA;AAAA,UACJ,MAAQ,EAAA,6BAAA;AAAA,UACR,IAAM,EAAA,6BAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,SAAW,EAAA,mBAAA;AAAA,YACX,KAAO,EAAA,iBAAA;AAAA,YACP,UAAY,EAAA;AAAA;AACd;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,4DAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,6BAAA;AAAA,UACJ,MAAQ,EAAA,6BAAA;AAAA,UACR,IAAM,EAAA,6BAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,SAAW,EAAA,cAAA;AAAA,YACX,KAAO,EAAA,iBAAA;AAAA,YACP,GAAK,EAAA,kCAAA;AAAA,YACL,MAAQ,EAAA;AAAA;AACV;AACF;AACF,KACD;AAAA;AAEL;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,19 +1,15 @@
1
1
  import * as _backstage_plugin_scaffolder_node from '@backstage/plugin-scaffolder-node';
2
- import * as _backstage_types_index from '@backstage/types/index';
3
2
  import { CatalogClient } from '@backstage/catalog-client';
4
3
  import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
5
4
 
6
- type TemplateActionParameters = {
7
- namespace: string;
8
- clusterRef?: string;
9
- url?: string;
10
- token: string;
11
- skipTLSVerify?: boolean;
12
- caData?: string;
13
- labels?: string;
14
- };
15
- declare function createKubernetesNamespaceAction(catalogClient: CatalogClient): _backstage_plugin_scaffolder_node.TemplateAction<TemplateActionParameters, _backstage_types_index.JsonObject, "v1">;
5
+ /**
6
+ * @public
7
+ */
8
+ declare function createKubernetesNamespaceAction(catalogClient: CatalogClient): _backstage_plugin_scaffolder_node.TemplateAction<any, any, "v1">;
16
9
 
10
+ /**
11
+ * @public
12
+ */
17
13
  declare const scaffolderModuleKubernetesAction: _backstage_backend_plugin_api.BackendFeature;
18
14
 
19
15
  export { createKubernetesNamespaceAction, scaffolderModuleKubernetesAction as default };
@@ -1 +1 @@
1
- {"version":3,"file":"module.cjs.js","sources":["../src/module.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 {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { CatalogClient } from '@backstage/catalog-client';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\n\nimport { createKubernetesNamespaceAction } from './actions';\n\nexport const scaffolderModuleKubernetesAction = createBackendModule({\n moduleId: 'scaffolder-backend-kubernetes',\n pluginId: 'scaffolder',\n register(env) {\n env.registerInit({\n deps: {\n scaffolder: scaffolderActionsExtensionPoint,\n discovery: coreServices.discovery,\n },\n async init({ scaffolder, discovery }) {\n const catalogClient = new CatalogClient({\n discoveryApi: discovery,\n });\n\n scaffolder.addActions(createKubernetesNamespaceAction(catalogClient));\n },\n });\n },\n});\n"],"names":["createBackendModule","scaffolderActionsExtensionPoint","coreServices","catalogClient","CatalogClient","createKubernetesNamespaceAction"],"mappings":";;;;;;;AAwBO,MAAM,mCAAmCA,oCAAoB,CAAA;AAAA,EAClE,QAAU,EAAA,+BAAA;AAAA,EACV,QAAU,EAAA,YAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,UAAY,EAAAC,qCAAA;AAAA,QACZ,WAAWC,6BAAa,CAAA;AAAA,OAC1B;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,UAAA,EAAY,WAAa,EAAA;AACpC,QAAM,MAAAC,eAAA,GAAgB,IAAIC,2BAAc,CAAA;AAAA,UACtC,YAAc,EAAA;AAAA,SACf,CAAA;AAED,QAAW,UAAA,CAAA,UAAA,CAAWC,yDAAgC,CAAAF,eAAa,CAAC,CAAA;AAAA;AACtE,KACD,CAAA;AAAA;AAEL,CAAC;;;;"}
1
+ {"version":3,"file":"module.cjs.js","sources":["../src/module.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 {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { CatalogClient } from '@backstage/catalog-client';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\n\nimport { createKubernetesNamespaceAction } from './actions';\n\n/**\n * @public\n */\nexport const scaffolderModuleKubernetesAction = createBackendModule({\n moduleId: 'scaffolder-backend-kubernetes',\n pluginId: 'scaffolder',\n register(env) {\n env.registerInit({\n deps: {\n scaffolder: scaffolderActionsExtensionPoint,\n discovery: coreServices.discovery,\n },\n async init({ scaffolder, discovery }) {\n const catalogClient = new CatalogClient({\n discoveryApi: discovery,\n });\n\n scaffolder.addActions(createKubernetesNamespaceAction(catalogClient));\n },\n });\n },\n});\n"],"names":["createBackendModule","scaffolderActionsExtensionPoint","coreServices","catalogClient","CatalogClient","createKubernetesNamespaceAction"],"mappings":";;;;;;;AA2BO,MAAM,mCAAmCA,oCAAoB,CAAA;AAAA,EAClE,QAAU,EAAA,+BAAA;AAAA,EACV,QAAU,EAAA,YAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,UAAY,EAAAC,qCAAA;AAAA,QACZ,WAAWC,6BAAa,CAAA;AAAA,OAC1B;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,UAAA,EAAY,WAAa,EAAA;AACpC,QAAM,MAAAC,eAAA,GAAgB,IAAIC,2BAAc,CAAA;AAAA,UACtC,YAAc,EAAA;AAAA,SACf,CAAA;AAED,QAAW,UAAA,CAAA,UAAA,CAAWC,yDAAgC,CAAAF,eAAa,CAAC,CAAA;AAAA;AACtE,KACD,CAAA;AAAA;AAEL,CAAC;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage-community/plugin-scaffolder-backend-module-kubernetes",
3
3
  "description": "The kubernetes module for @backstage/plugin-scaffolder-backend",
4
- "version": "2.7.0",
4
+ "version": "2.8.0",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -47,15 +47,17 @@
47
47
  "postpack": "backstage-cli package postpack"
48
48
  },
49
49
  "dependencies": {
50
- "@backstage/backend-plugin-api": "^1.3.0",
51
- "@backstage/catalog-client": "^1.9.1",
52
- "@backstage/plugin-scaffolder-node": "^0.8.1",
53
- "@kubernetes/client-node": "1.0.0-rc7"
50
+ "@backstage/backend-plugin-api": "^1.3.1",
51
+ "@backstage/catalog-client": "^1.10.0",
52
+ "@backstage/plugin-scaffolder-node": "^0.8.2",
53
+ "@kubernetes/client-node": "1.0.0-rc7",
54
+ "yaml": "^2.0.0",
55
+ "zod": "^3.22.4"
54
56
  },
55
57
  "devDependencies": {
56
- "@backstage/catalog-model": "^1.7.3",
57
- "@backstage/cli": "^0.32.0",
58
- "@backstage/plugin-scaffolder-node-test-utils": "^0.2.1",
58
+ "@backstage/catalog-model": "^1.7.4",
59
+ "@backstage/cli": "^0.32.1",
60
+ "@backstage/plugin-scaffolder-node-test-utils": "^0.2.2",
59
61
  "msw": "1.3.5"
60
62
  },
61
63
  "files": [