@storm-software/k8s-tools 0.27.1 → 0.28.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.
Files changed (42) hide show
  1. package/.eslintrc.json +35 -0
  2. package/CHANGELOG.md +39 -0
  3. package/README.md +1 -1
  4. package/executors.ts +4 -0
  5. package/generators.ts +4 -0
  6. package/index.ts +5 -0
  7. package/package.json +4 -4
  8. package/project.json +61 -0
  9. package/src/executors/container-publish/executor.spec.ts +18 -0
  10. package/src/executors/container-publish/executor.ts +216 -0
  11. package/src/executors/helm-package/executor.ts +71 -0
  12. package/src/generators/helm-chart/files/chart/.helmignore +23 -0
  13. package/src/generators/helm-chart/generator.ts +69 -0
  14. package/src/generators/helm-dependency/generator.ts +135 -0
  15. package/src/plugins/docker/_dockerfile.ts +225 -0
  16. package/src/plugins/docker/index.ts +1 -0
  17. package/src/plugins/index.ts +1 -0
  18. package/src/types.ts +37 -0
  19. package/src/utils/client.ts +141 -0
  20. package/src/utils/ensure-init.ts +37 -0
  21. package/src/utils/index.ts +3 -0
  22. package/src/utils/prettier.ts +62 -0
  23. package/tsconfig.json +31 -0
  24. package/tsup.config.ts +26 -0
  25. /package/{dist/src → src}/executors/container-publish/schema.d.ts +0 -0
  26. /package/{dist/src → src}/executors/container-publish/schema.json +0 -0
  27. /package/{dist/src → src}/executors/helm-package/schema.d.ts +0 -0
  28. /package/{dist/src → src}/executors/helm-package/schema.json +0 -0
  29. /package/{dist/src → src}/generators/helm-chart/files/chart/Chart.yaml.template +0 -0
  30. /package/{dist/src → src}/generators/helm-chart/files/chart/templates/NOTES.txt +0 -0
  31. /package/{dist/src → src}/generators/helm-chart/files/chart/templates/_helpers.yaml +0 -0
  32. /package/{dist/src → src}/generators/helm-chart/files/chart/templates/deployment.yaml +0 -0
  33. /package/{dist/src → src}/generators/helm-chart/files/chart/templates/hpa.yaml +0 -0
  34. /package/{dist/src → src}/generators/helm-chart/files/chart/templates/ingress.yaml +0 -0
  35. /package/{dist/src → src}/generators/helm-chart/files/chart/templates/service.yaml +0 -0
  36. /package/{dist/src → src}/generators/helm-chart/files/chart/templates/serviceaccount.yaml +0 -0
  37. /package/{dist/src → src}/generators/helm-chart/files/chart/templates/test/test-connection.yaml +0 -0
  38. /package/{dist/src → src}/generators/helm-chart/files/chart/values.yaml +0 -0
  39. /package/{dist/src → src}/generators/helm-chart/schema.d.ts +0 -0
  40. /package/{dist/src → src}/generators/helm-chart/schema.json +0 -0
  41. /package/{dist/src → src}/generators/helm-dependency/schema.d.ts +0 -0
  42. /package/{dist/src → src}/generators/helm-dependency/schema.json +0 -0
package/.eslintrc.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "extends": ["../../.eslintrc.json"],
3
+ "ignorePatterns": ["!**/*"],
4
+ "overrides": [
5
+ {
6
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7
+ "parserOptions": {
8
+ "project": ["packages/k8s-tools/tsconfig.*?.json"]
9
+ },
10
+ "rules": {}
11
+ },
12
+ {
13
+ "files": ["*.ts", "*.tsx"],
14
+ "rules": {}
15
+ },
16
+ {
17
+ "files": ["*.js", "*.jsx"],
18
+ "rules": {}
19
+ },
20
+ {
21
+ "files": ["*.json"],
22
+ "parser": "jsonc-eslint-parser",
23
+ "rules": {
24
+ "@nx/dependency-checks": "error"
25
+ }
26
+ },
27
+ {
28
+ "files": ["./package.json", "./executors.json", "./generators.json"],
29
+ "parser": "jsonc-eslint-parser",
30
+ "rules": {
31
+ "@nx/nx-plugin-checks": "error"
32
+ }
33
+ }
34
+ ]
35
+ }
package/CHANGELOG.md CHANGED
@@ -2,6 +2,45 @@
2
2
 
3
3
  # Changelog for Storm Ops - K8s Tools
4
4
 
5
+ ## [0.28.0](https://github.com/storm-software/storm-ops/releases/tag/k8s-tools%400.28.0) (2025-05-06)
6
+
7
+ ### Features
8
+
9
+ - **workspace-tools:** Update the publish executor source code
10
+ ([527dcfe84](https://github.com/storm-software/storm-ops/commit/527dcfe84))
11
+
12
+ ### Miscellaneous
13
+
14
+ - **monorepo:** Regenerate README markdown files
15
+ ([d58a4014e](https://github.com/storm-software/storm-ops/commit/d58a4014e))
16
+
17
+ ### Updated Dependencies
18
+
19
+ - Updated workspace-tools to 1.270.0
20
+ - Updated workspace-tools to 1.270.0
21
+ - Updated config-tools to 1.166.0
22
+ - Updated config-tools to 1.166.0
23
+ - Updated config to 1.116.0
24
+ - Updated config to 1.116.0
25
+
26
+ ## [0.27.2](https://github.com/storm-software/storm-ops/releases/tag/k8s-tools%400.27.2) (2025-05-05)
27
+
28
+ ### Miscellaneous
29
+
30
+ - **workspace-tools:** Skip git checks during publish
31
+ ([7fdcbfc9a](https://github.com/storm-software/storm-ops/commit/7fdcbfc9a))
32
+ - **monorepo:** Regenerate README markdown files
33
+ ([fb8ab0609](https://github.com/storm-software/storm-ops/commit/fb8ab0609))
34
+
35
+ ### Updated Dependencies
36
+
37
+ - Updated workspace-tools to 1.269.2
38
+ - Updated workspace-tools to 1.269.2
39
+ - Updated config-tools to 1.165.2
40
+ - Updated config-tools to 1.165.2
41
+ - Updated config to 1.115.2
42
+ - Updated config to 1.115.2
43
+
5
44
  ## [0.27.1](https://github.com/storm-software/storm-ops/releases/tag/k8s-tools%400.27.1) (2025-05-05)
6
45
 
7
46
  ### Miscellaneous
package/README.md CHANGED
@@ -21,7 +21,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
21
21
 
22
22
  <h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
23
23
 
24
- [![Version](https://img.shields.io/badge/version-0.27.0-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/storm-ops/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
24
+ [![Version](https://img.shields.io/badge/version-0.27.1-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/storm-ops/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
25
25
 
26
26
  <!-- prettier-ignore-start -->
27
27
  <!-- markdownlint-disable -->
package/executors.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./src/executors/container-publish/executor";
2
+ export { type ContainerPublishExecutorSchema } from "./src/executors/container-publish/schema.d";
3
+ export * from "./src/executors/helm-package/executor";
4
+ export { type HelmPackageExecutorSchema } from "./src/executors/helm-package/schema.d";
package/generators.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./src/generators/helm-chart/generator";
2
+ export { type HelmChartGeneratorSchema } from "./src/generators/helm-chart/schema.d";
3
+ export * from "./src/generators/helm-dependency/generator";
4
+ export { type HelmDependencyGeneratorSchema } from "./src/generators/helm-dependency/schema.d";
package/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from "./executors";
2
+ export * from "./generators";
3
+ export * from "./src/plugins";
4
+ export * from "./src/types";
5
+ export * from "./src/utils";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storm-software/k8s-tools",
3
- "version": "0.27.1",
3
+ "version": "0.28.0",
4
4
  "description": "Tools for managing Kubernetes (k8s) infrastructure within a Nx workspace.",
5
5
  "repository": {
6
6
  "type": "github",
@@ -162,9 +162,9 @@
162
162
  }
163
163
  },
164
164
  "dependencies": {
165
- "@storm-software/config": "1.115.1",
166
- "@storm-software/config-tools": "1.165.1",
167
- "@storm-software/workspace-tools": "1.269.1",
165
+ "@storm-software/config": "1.116.0",
166
+ "@storm-software/config-tools": "1.166.0",
167
+ "@storm-software/workspace-tools": "1.270.0",
168
168
  "js-yaml": "^4.1.0"
169
169
  },
170
170
  "devDependencies": {
package/project.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "k8s-tools",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "packages/k8s-tools/src",
5
+ "projectType": "library",
6
+ "implicitDependencies": [
7
+ "workspace-tools",
8
+ "untyped",
9
+ "config-tools",
10
+ "config"
11
+ ],
12
+ "targets": {
13
+ "build-untyped": {
14
+ "executor": "nx:run-commands",
15
+ "dependsOn": ["clean", "^build"],
16
+ "inputs": [
17
+ "{projectRoot}/src/**/untyped.ts",
18
+ "{projectRoot}/src/**/*.untyped.ts"
19
+ ],
20
+ "outputs": [
21
+ "{projectRoot}/src/**/schema.d.ts",
22
+ "{projectRoot}/src/**/*.schema.d.ts",
23
+ "{projectRoot}/src/**/schema.md",
24
+ "{projectRoot}/src/**/*.schema.md",
25
+ "{projectRoot}/src/**/schema.json",
26
+ "{projectRoot}/src/**/*.schema.json"
27
+ ],
28
+ "options": {
29
+ "commands": [
30
+ "node dist/packages/untyped/bin/untyped.cjs generate --entry=\"packages/k8s-tools/**/{untyped.ts,*.untyped.ts}\" "
31
+ ]
32
+ }
33
+ },
34
+ "build-base": {
35
+ "executor": "nx:run-commands",
36
+ "dependsOn": ["build-untyped", "clean", "^build"],
37
+ "options": {
38
+ "command": "tsup-node --config=tsup.config.ts",
39
+ "cwd": "{projectRoot}"
40
+ }
41
+ },
42
+ "build": {
43
+ "executor": "nx:run-commands",
44
+ "dependsOn": ["build-base", "build-untyped"],
45
+ "options": {
46
+ "commands": [
47
+ "pnpm copyfiles LICENSE dist/packages/k8s-tools",
48
+ "pnpm copyfiles --up=2 ./packages/k8s-tools/*.md ./packages/k8s-tools/executors.json ./packages/k8s-tools/generators.json ./packages/k8s-tools/package.json dist/packages/k8s-tools",
49
+ "pnpm copyfiles --up=3 \"./packages/k8s-tools/dist/**/*\" dist/packages/k8s-tools/dist",
50
+ "pnpm copyfiles --up=3 \"./packages/k8s-tools/src/**/*schema.d.ts\" dist/packages/k8s-tools/dist/src",
51
+ "pnpm copyfiles --up=3 \"./packages/k8s-tools/src/**/*schema.json\" dist/packages/k8s-tools/dist/src",
52
+ "pnpm copyfiles --up=3 \"./packages/k8s-tools/src/**/*.md\" dist/packages/k8s-tools/docs/api",
53
+ "pnpm copyfiles --up=4 \"./packages/k8s-tools/src/generators/*/files/**/*\" dist/packages/k8s-tools/dist/src/generators"
54
+ ]
55
+ }
56
+ },
57
+ "nx-release-publish": {
58
+ "executor": "@storm-software/workspace-tools:npm-publish"
59
+ }
60
+ }
61
+ }
@@ -0,0 +1,18 @@
1
+ import { ExecutorContext } from "@nx/devkit";
2
+
3
+ import executor from "./executor";
4
+ import { ContainerPublishExecutorSchema } from "./schema";
5
+
6
+ const options: ContainerPublishExecutorSchema = {};
7
+ const context: ExecutorContext = {
8
+ root: "",
9
+ cwd: process.cwd(),
10
+ isVerbose: false,
11
+ };
12
+
13
+ describe("ContainerPublish Executor", () => {
14
+ it("can run", async () => {
15
+ const output = await executor(options, context);
16
+ expect(output.success).toBe(true);
17
+ });
18
+ });
@@ -0,0 +1,216 @@
1
+ import {
2
+ parseTargetString,
3
+ runExecutor,
4
+ type ExecutorContext
5
+ } from "@nx/devkit";
6
+ import { StormWorkspaceConfig } from "@storm-software/config";
7
+ import {
8
+ applyWorkspaceTokens,
9
+ findWorkspaceRoot,
10
+ getConfig,
11
+ type BaseTokenizerOptions
12
+ } from "@storm-software/config-tools";
13
+ import { applyWorkspaceExecutorTokens } from "@storm-software/workspace-tools/utils/apply-workspace-tokens";
14
+ import { getPackageInfo } from "@storm-software/workspace-tools/utils/package-helpers";
15
+ import { CargoToml } from "@storm-software/workspace-tools/utils/toml";
16
+ import https from "node:https";
17
+ import type { ContainerPublishExecutorSchema } from "./schema.d";
18
+
19
+ export default async function* publishExecutor(
20
+ options: ContainerPublishExecutorSchema,
21
+ context: ExecutorContext
22
+ ) {
23
+ /**
24
+ * We need to check both the env var and the option because the executor may have been triggered
25
+ * indirectly via dependsOn, in which case the env var will be set, but the option will not.
26
+ */
27
+ const isDryRun = process.env.NX_DRY_RUN === "true" || options.dryRun || false;
28
+
29
+ if (!context.projectName) {
30
+ throw new Error("The executor requires a projectName.");
31
+ }
32
+
33
+ console.info(
34
+ `🚀 Running Storm Container Registry Publish executor on the ${context.projectName} crate`
35
+ );
36
+
37
+ const workspaceRoot = findWorkspaceRoot();
38
+ const config = await getConfig(workspaceRoot);
39
+
40
+ const projectConfig =
41
+ context.projectsConfigurations?.projects[context.projectName];
42
+ if (!projectConfig) {
43
+ throw new Error(
44
+ `The executor requires a valid projectsConfiguration - No configuration found for project ${context.projectName}`
45
+ );
46
+ }
47
+
48
+ const projectRoot = projectConfig?.root ?? workspaceRoot;
49
+ const sourceRoot = projectConfig?.sourceRoot ?? workspaceRoot;
50
+ const projectName = projectConfig?.name ?? context.projectName;
51
+ config.workspaceRoot = workspaceRoot;
52
+
53
+ const tokenized = (await applyWorkspaceTokens(
54
+ options,
55
+ {
56
+ config,
57
+ workspaceRoot,
58
+ projectRoot,
59
+ sourceRoot,
60
+ projectName,
61
+ ...projectConfig
62
+ } as BaseTokenizerOptions,
63
+ applyWorkspaceExecutorTokens
64
+ )) as ContainerPublishExecutorSchema;
65
+
66
+ tokenized.engine ??= "docker";
67
+ tokenized.registry ??= config.registry.container;
68
+
69
+ try {
70
+ if (isDryRun) {
71
+ console.log(
72
+ `Would publish to ${tokenized.registry}, but [dry-run] was set`
73
+ );
74
+ } else {
75
+ console.log(`Published to ${tokenized.registry}`);
76
+
77
+ const packageManager = getPackageInfo(projectConfig);
78
+ if (packageManager) {
79
+ tokenized["build-args"] ??= [
80
+ "ENVIRONMENT=production",
81
+ "DEBUG_IMAGE=false"
82
+ ];
83
+ tokenized["labels"] ??= [];
84
+
85
+ let version = "";
86
+ if (process.env.TAG) {
87
+ version = process.env.TAG;
88
+ } else {
89
+ if (packageManager.type === "Cargo.toml") {
90
+ version = (packageManager.content as CargoToml).package.version;
91
+ } else if (packageManager.type === "package.json") {
92
+ version = packageManager.content.version;
93
+ }
94
+ }
95
+
96
+ tokenized["build-args"].push(`RELEASE=${version}`);
97
+ tokenized["labels"].push(`org.opencontainers.image.version=${version}`);
98
+
99
+ const tags = await getRegistryVersion(projectName, config);
100
+ if (tags.length === 0) {
101
+ tokenized["labels"].push(
102
+ `org.opencontainers.image.created=${new Date().toISOString()}`
103
+ );
104
+ } else if (tags.includes(version)) {
105
+ console.warn(
106
+ `Skipped package "${projectName}" because v${version} already exists in ${tokenized.registry}`
107
+ );
108
+ return {
109
+ success: true
110
+ };
111
+ }
112
+ } else {
113
+ console.warn(
114
+ `No package manager found for project "${projectName}" - Skipping container publishing`
115
+ );
116
+ return {
117
+ success: true
118
+ };
119
+ }
120
+
121
+ const { project, target, configuration } = parseTargetString(
122
+ "container",
123
+ context
124
+ );
125
+ for await (const output of await runExecutor<{
126
+ success: boolean;
127
+ baseUrl?: string;
128
+ }>({ project, target, configuration }, tokenized, context)) {
129
+ if (!output.success) {
130
+ throw new Error("Could not compile application files");
131
+ }
132
+ yield;
133
+ }
134
+ }
135
+
136
+ return {
137
+ success: true
138
+ };
139
+ } catch (error: any) {
140
+ console.error(`Failed to publish to ${tokenized.registry}`);
141
+ console.error(error);
142
+ console.log("");
143
+
144
+ return {
145
+ success: false
146
+ };
147
+ }
148
+ }
149
+
150
+ export const getRegistryVersion = (
151
+ name: string,
152
+ config: StormWorkspaceConfig
153
+ ): Promise<string[]> => {
154
+ if (!name) {
155
+ throw new Error(
156
+ "The `getRegistryVersion` function requires a container name."
157
+ );
158
+ }
159
+
160
+ try {
161
+ const tagsApiUrl = `${config.registry.container}/v2/namespaces/${encodeURIComponent(config.namespace ? config.namespace : "storm-software")}/repositories/${encodeURIComponent(
162
+ name.replace(`${config.namespace}-`, "")
163
+ )}/tags`;
164
+ console.log(`Checking for existing version at ${tagsApiUrl}`);
165
+
166
+ return new Promise(
167
+ (resolve: (value: string[]) => void, reject: (error: any) => void) =>
168
+ https
169
+ .get(tagsApiUrl, res => {
170
+ if (res.statusCode === 404) {
171
+ console.log(`No existing version found at ${tagsApiUrl}`);
172
+ return resolve([] as string[]);
173
+ }
174
+
175
+ res.on("data", data => {
176
+ if (data) {
177
+ console.log(
178
+ `Existing versions found at ${tagsApiUrl} - ${data}`
179
+ );
180
+ const json = JSON.parse(data.toString());
181
+ return resolve(
182
+ json.results
183
+ .filter(
184
+ (result: { status: string; name: string }) =>
185
+ result.status === "active" &&
186
+ result.name &&
187
+ result.name !== "latest"
188
+ )
189
+ .map((result: { name: string }) => result.name)
190
+ );
191
+ }
192
+
193
+ return reject(
194
+ new Error(
195
+ "No data returned from container registry, expected a 404 if no tags exist"
196
+ )
197
+ );
198
+ });
199
+ })
200
+ .on("error", e => {
201
+ throw e;
202
+ })
203
+ );
204
+ } catch (error) {
205
+ console.error(`Failed to get version from ${config.registry.container}`);
206
+ console.error(error);
207
+ console.log("");
208
+
209
+ throw new Error(
210
+ `Could not get version from container registry - ${config.registry.container}`,
211
+ {
212
+ cause: error
213
+ }
214
+ );
215
+ }
216
+ };
@@ -0,0 +1,71 @@
1
+ import type { ExecutorContext, PromiseExecutor } from "@nx/devkit";
2
+ import type { StormWorkspaceConfig } from "@storm-software/config";
3
+ import { writeWarning } from "@storm-software/config-tools/logger/console";
4
+ import { withRunExecutor } from "@storm-software/workspace-tools/base/base-executor";
5
+ import { createHelmClient } from "../../utils/client";
6
+ import { HelmPackageExecutorSchema } from "./schema";
7
+
8
+ export async function serveExecutor(
9
+ options: HelmPackageExecutorSchema,
10
+ context: ExecutorContext,
11
+ config?: StormWorkspaceConfig
12
+ ) {
13
+ if (
14
+ !context?.projectName ||
15
+ !context?.projectsConfigurations?.projects?.[context.projectName]?.root
16
+ ) {
17
+ throw new Error("Nx executor context was invalid");
18
+ }
19
+
20
+ const helm = createHelmClient();
21
+ if (options.dependencies?.repositories) {
22
+ for (const repository of options.dependencies.repositories) {
23
+ if (repository.name && repository.url) {
24
+ helm.addRepository(repository.name, repository.url);
25
+ } else {
26
+ throw new Error("Repository name and url are required");
27
+ }
28
+ }
29
+ }
30
+
31
+ if (options.dependencies?.update) {
32
+ helm.dependencyUpdate(options.chartFolder);
33
+ }
34
+
35
+ if (options.dependencies?.build) {
36
+ helm.dependencyBuild(options.chartFolder);
37
+ }
38
+
39
+ const chartPath = await helm.package({
40
+ chartFolder: options.chartFolder,
41
+ outputFolder: options.outputFolder
42
+ });
43
+
44
+ if (options.push && chartPath && options.remote) {
45
+ helm.push({
46
+ chartPath,
47
+ remote: options.remote
48
+ });
49
+ } else {
50
+ writeWarning(`Chart packaged at: ${chartPath}`, config);
51
+ }
52
+
53
+ return {
54
+ success: true
55
+ };
56
+ }
57
+
58
+ export default withRunExecutor<HelmPackageExecutorSchema>(
59
+ "Helm Chart Package executor",
60
+ serveExecutor,
61
+ {
62
+ skipReadingConfig: false,
63
+ hooks: {
64
+ applyDefaultOptions: (options: HelmPackageExecutorSchema) => {
65
+ options.port ??= 4500;
66
+
67
+ return options as HelmPackageExecutorSchema;
68
+ }
69
+ }
70
+ }
71
+ ) as PromiseExecutor<HelmPackageExecutorSchema>;
@@ -0,0 +1,23 @@
1
+ # Patterns to ignore when building packages.
2
+ # This supports shell glob matching, relative path matching, and
3
+ # negation (prefixed with !). Only one pattern per line.
4
+ .DS_Store
5
+ # Common VCS dirs
6
+ .git/
7
+ .gitignore
8
+ .bzr/
9
+ .bzrignore
10
+ .hg/
11
+ .hgignore
12
+ .svn/
13
+ # Common backup files
14
+ *.swp
15
+ *.bak
16
+ *.tmp
17
+ *.orig
18
+ *~
19
+ # Various IDEs
20
+ .project
21
+ .idea/
22
+ *.tmproj
23
+ .vscode/
@@ -0,0 +1,69 @@
1
+ import {
2
+ formatFiles,
3
+ generateFiles,
4
+ readProjectConfiguration,
5
+ Tree,
6
+ updateProjectConfiguration
7
+ } from "@nx/devkit";
8
+ import { StormWorkspaceConfig } from "@storm-software/config";
9
+ import { writeDebug } from "@storm-software/config-tools/logger/console";
10
+ import { withRunGenerator } from "@storm-software/workspace-tools/base/base-generator";
11
+ import { join } from "path";
12
+ import type { HelmChartGeneratorSchema } from "./schema";
13
+
14
+ export async function helmChartGeneratorFn(
15
+ tree: Tree,
16
+ options: HelmChartGeneratorSchema,
17
+ config?: StormWorkspaceConfig
18
+ ) {
19
+ writeDebug("📝 Preparing to write Helm Chart", config);
20
+
21
+ const project = readProjectConfiguration(tree, options.project);
22
+ if (project.targets?.["helm-package"]) {
23
+ throw new Error(
24
+ `Project ${options.project} already has a helm target. Please remove it before running this command.`
25
+ );
26
+ }
27
+
28
+ updateProjectConfiguration(tree, options.project, {
29
+ ...project,
30
+ targets: {
31
+ ...project.targets,
32
+ "helm-package": {
33
+ executor: "@storm-software/k8s-tools:helm-package",
34
+ outputs: ["{options.outputFolder}"],
35
+ options: {
36
+ chartFolder: `${project.root}/${options.chartFolder}`,
37
+ outputFolder: "{workspaceRoot}/dist/charts/{projectRoot}",
38
+ push: false,
39
+ remote: "oci://localhost:5000/helm-charts",
40
+ dependencies: {
41
+ update: true,
42
+ build: true,
43
+ repositories: []
44
+ }
45
+ }
46
+ }
47
+ }
48
+ });
49
+
50
+ generateFiles(
51
+ tree,
52
+ join(__dirname, "files", "chart"),
53
+ join(project.root, options.chartFolder ?? ""),
54
+ options
55
+ );
56
+
57
+ if (options.format) {
58
+ await formatFiles(tree);
59
+ }
60
+
61
+ return {
62
+ success: true
63
+ };
64
+ }
65
+
66
+ export default withRunGenerator<HelmChartGeneratorSchema>(
67
+ "Helm Chart",
68
+ helmChartGeneratorFn
69
+ );