@storm-software/k8s-tools 0.1.0 → 0.2.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 +14 -0
- package/generators.json +2 -0
- package/index.js +152 -1239
- package/meta.json +1 -1
- package/package.json +1 -2
- package/src/executors/helm-package/executor.js +77 -1076
- package/src/generators/helm-chart/generator.d.ts +7 -4
- package/src/generators/helm-chart/generator.js +44 -86
- package/src/generators/helm-dependency/generator.d.ts +7 -4
- package/src/generators/helm-dependency/generator.js +33 -81
- package/src/utils/client.d.ts +10 -5
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Tree } from "@nx/devkit";
|
|
2
|
+
import { StormConfig } from "@storm-software/config";
|
|
2
3
|
import type { HelmChartGeneratorSchema } from "./schema";
|
|
3
|
-
export declare function
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export declare function helmChartGeneratorFn(tree: Tree, options: HelmChartGeneratorSchema, config?: StormConfig): Promise<{
|
|
5
|
+
success: boolean;
|
|
6
|
+
}>;
|
|
7
|
+
declare const _default: (tree: Tree, _options: HelmChartGeneratorSchema) => Promise<import("@nx/devkit").GeneratorCallback | import("packages/workspace-tools/declarations").BaseGeneratorResult>;
|
|
8
|
+
export default _default;
|
|
@@ -30,102 +30,60 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
var generator_exports = {};
|
|
31
31
|
__export(generator_exports, {
|
|
32
32
|
default: () => generator_default,
|
|
33
|
-
|
|
34
|
-
helmChartSchematic: () => helmChartSchematic
|
|
33
|
+
helmChartGeneratorFn: () => helmChartGeneratorFn
|
|
35
34
|
});
|
|
36
35
|
module.exports = __toCommonJS(generator_exports);
|
|
37
36
|
var import_devkit = require("@nx/devkit");
|
|
37
|
+
var import_workspace_tools = require("@storm-software/workspace-tools");
|
|
38
38
|
var import_path = require("path");
|
|
39
|
-
async function
|
|
40
|
-
const {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
writeTrace,
|
|
47
|
-
findWorkspaceRoot,
|
|
48
|
-
loadStormConfig
|
|
49
|
-
} = await import("@storm-software/config-tools");
|
|
50
|
-
const stopwatch = getStopwatch("Storm Helm Chart generator");
|
|
51
|
-
let config;
|
|
52
|
-
try {
|
|
53
|
-
writeInfo(`\u26A1 Running the Storm Helm Chart generator...
|
|
54
|
-
|
|
55
|
-
`, config);
|
|
56
|
-
const workspaceRoot = findWorkspaceRoot();
|
|
57
|
-
writeDebug(
|
|
58
|
-
`Loading the Storm Config from environment variables and storm.json file...
|
|
59
|
-
- workspaceRoot: ${workspaceRoot}`,
|
|
60
|
-
config
|
|
61
|
-
);
|
|
62
|
-
config = await loadStormConfig(workspaceRoot);
|
|
63
|
-
writeTrace(
|
|
64
|
-
`Loaded Storm config into env:
|
|
65
|
-
${Object.keys(process.env).map((key) => ` - ${key}=${JSON.stringify(process.env[key])}`).join("\n")}`,
|
|
66
|
-
config
|
|
39
|
+
async function helmChartGeneratorFn(tree, options, config) {
|
|
40
|
+
const { writeTrace } = await import("@storm-software/config-tools");
|
|
41
|
+
writeTrace("\u{1F4DD} Preparing to write Helm Chart", config);
|
|
42
|
+
const project = (0, import_devkit.readProjectConfiguration)(tree, options.project);
|
|
43
|
+
if (project.targets?.["helm-package"]) {
|
|
44
|
+
throw new Error(
|
|
45
|
+
`Project ${options.project} already has a helm target. Please remove it before running this command.`
|
|
67
46
|
);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"helm-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
outputFolder: "{workspaceRoot}/dist/charts/{projectRoot}",
|
|
86
|
-
push: false,
|
|
87
|
-
remote: "oci://localhost:5000/helm-charts",
|
|
88
|
-
dependencies: {
|
|
89
|
-
update: true,
|
|
90
|
-
build: true,
|
|
91
|
-
repositories: []
|
|
92
|
-
}
|
|
93
|
-
}
|
|
47
|
+
}
|
|
48
|
+
(0, import_devkit.updateProjectConfiguration)(tree, options.project, {
|
|
49
|
+
...project,
|
|
50
|
+
targets: {
|
|
51
|
+
...project.targets,
|
|
52
|
+
"helm-package": {
|
|
53
|
+
executor: "@storm-software/k8s-tools:helm-package",
|
|
54
|
+
outputs: ["{options.outputFolder}"],
|
|
55
|
+
options: {
|
|
56
|
+
chartFolder: `${project.root}/${options.chartFolder}`,
|
|
57
|
+
outputFolder: "{workspaceRoot}/dist/charts/{projectRoot}",
|
|
58
|
+
push: false,
|
|
59
|
+
remote: "oci://localhost:5000/helm-charts",
|
|
60
|
+
dependencies: {
|
|
61
|
+
update: true,
|
|
62
|
+
build: true,
|
|
63
|
+
repositories: []
|
|
94
64
|
}
|
|
95
65
|
}
|
|
96
|
-
});
|
|
97
|
-
(0, import_devkit.generateFiles)(
|
|
98
|
-
tree,
|
|
99
|
-
(0, import_path.join)(__dirname, "files", "chart"),
|
|
100
|
-
(0, import_path.join)(project.root, options.chartFolder ?? ""),
|
|
101
|
-
options
|
|
102
|
-
);
|
|
103
|
-
if (options.format) {
|
|
104
|
-
await (0, import_devkit.formatFiles)(tree);
|
|
105
66
|
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
- Details: ${error.message}
|
|
117
|
-
- Stacktrace: ${error.stack}`,
|
|
118
|
-
config
|
|
119
|
-
);
|
|
120
|
-
};
|
|
121
|
-
} finally {
|
|
122
|
-
stopwatch();
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
(0, import_devkit.generateFiles)(
|
|
70
|
+
tree,
|
|
71
|
+
(0, import_path.join)(__dirname, "files", "chart"),
|
|
72
|
+
(0, import_path.join)(project.root, options.chartFolder ?? ""),
|
|
73
|
+
options
|
|
74
|
+
);
|
|
75
|
+
if (options.format) {
|
|
76
|
+
await (0, import_devkit.formatFiles)(tree);
|
|
123
77
|
}
|
|
78
|
+
return {
|
|
79
|
+
success: true
|
|
80
|
+
};
|
|
124
81
|
}
|
|
125
|
-
var generator_default =
|
|
126
|
-
|
|
82
|
+
var generator_default = (0, import_workspace_tools.withRunGenerator)(
|
|
83
|
+
"Helm Chart",
|
|
84
|
+
helmChartGeneratorFn
|
|
85
|
+
);
|
|
127
86
|
// Annotate the CommonJS export names for ESM import in node:
|
|
128
87
|
0 && (module.exports = {
|
|
129
|
-
|
|
130
|
-
helmChartSchematic
|
|
88
|
+
helmChartGeneratorFn
|
|
131
89
|
});
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Tree } from "@nx/devkit";
|
|
2
|
+
import { StormConfig } from "@storm-software/config";
|
|
2
3
|
import type { HelmDependencyGeneratorSchema } from "./schema";
|
|
3
|
-
export declare function
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export declare function helmDependencyGeneratorFn(tree: Tree, options: HelmDependencyGeneratorSchema, config?: StormConfig): Promise<{
|
|
5
|
+
success: boolean;
|
|
6
|
+
}>;
|
|
7
|
+
declare const _default: (tree: Tree, _options: HelmDependencyGeneratorSchema) => Promise<import("@nx/devkit").GeneratorCallback | import("packages/workspace-tools/declarations").BaseGeneratorResult>;
|
|
8
|
+
export default _default;
|
|
@@ -30,11 +30,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
var generator_exports = {};
|
|
31
31
|
__export(generator_exports, {
|
|
32
32
|
default: () => generator_default,
|
|
33
|
-
|
|
34
|
-
helmDependencySchematic: () => helmDependencySchematic
|
|
33
|
+
helmDependencyGeneratorFn: () => helmDependencyGeneratorFn
|
|
35
34
|
});
|
|
36
35
|
module.exports = __toCommonJS(generator_exports);
|
|
37
36
|
var import_devkit = require("@nx/devkit");
|
|
37
|
+
var import_workspace_tools = require("@storm-software/workspace-tools");
|
|
38
38
|
|
|
39
39
|
// node_modules/.pnpm/js-yaml@4.1.0/node_modules/js-yaml/dist/js-yaml.mjs
|
|
40
40
|
function isNothing(subject) {
|
|
@@ -2659,84 +2659,37 @@ var jsYaml = {
|
|
|
2659
2659
|
var js_yaml_default = jsYaml;
|
|
2660
2660
|
|
|
2661
2661
|
// packages/k8s-tools/src/generators/helm-dependency/generator.ts
|
|
2662
|
-
async function
|
|
2663
|
-
const {
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
writeTrace,
|
|
2670
|
-
findWorkspaceRoot,
|
|
2671
|
-
loadStormConfig
|
|
2672
|
-
} = await import("@storm-software/config-tools");
|
|
2673
|
-
const stopwatch = getStopwatch("Storm Worker generator");
|
|
2674
|
-
let config;
|
|
2675
|
-
try {
|
|
2676
|
-
writeInfo(`\u26A1 Running the Storm Worker generator...
|
|
2677
|
-
|
|
2678
|
-
`, config);
|
|
2679
|
-
const workspaceRoot = findWorkspaceRoot();
|
|
2680
|
-
writeDebug(
|
|
2681
|
-
`Loading the Storm Config from environment variables and storm.json file...
|
|
2682
|
-
- workspaceRoot: ${workspaceRoot}`,
|
|
2683
|
-
config
|
|
2662
|
+
async function helmDependencyGeneratorFn(tree, options, config) {
|
|
2663
|
+
const { writeTrace } = await import("@storm-software/config-tools");
|
|
2664
|
+
writeTrace("\u{1F4DD} Preparing to add Helm Dependency", config);
|
|
2665
|
+
const project = (0, import_devkit.readProjectConfiguration)(tree, options.project);
|
|
2666
|
+
if (!project.targets?.["helm-package"]) {
|
|
2667
|
+
throw new Error(
|
|
2668
|
+
`Project ${options.project} does not have a helm target. Please run the chart generator first.`
|
|
2684
2669
|
);
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
updateChartYaml(
|
|
2709
|
-
tree,
|
|
2710
|
-
project,
|
|
2711
|
-
options.chartName,
|
|
2712
|
-
options.chartVersion,
|
|
2713
|
-
options.repository
|
|
2714
|
-
);
|
|
2715
|
-
if (options.format) {
|
|
2716
|
-
await (0, import_devkit.formatFiles)(tree);
|
|
2717
|
-
}
|
|
2718
|
-
});
|
|
2719
|
-
return (0, import_devkit.runTasksInSerial)(...tasks);
|
|
2720
|
-
} catch (error) {
|
|
2721
|
-
return () => {
|
|
2722
|
-
writeFatal(
|
|
2723
|
-
"A fatal error occurred while running the generator - the process was forced to terminate",
|
|
2724
|
-
config
|
|
2725
|
-
);
|
|
2726
|
-
writeError(
|
|
2727
|
-
`An exception was thrown in the generator's process
|
|
2728
|
-
- Details: ${error.message}
|
|
2729
|
-
- Stacktrace: ${error.stack}`,
|
|
2730
|
-
config
|
|
2731
|
-
);
|
|
2732
|
-
};
|
|
2733
|
-
} finally {
|
|
2734
|
-
stopwatch();
|
|
2735
|
-
}
|
|
2736
|
-
}
|
|
2737
|
-
var generator_default = helmDependencyGenerator;
|
|
2738
|
-
var helmDependencySchematic = (0, import_devkit.convertNxGenerator)(
|
|
2739
|
-
helmDependencyGenerator
|
|
2670
|
+
}
|
|
2671
|
+
(0, import_devkit.updateProjectConfiguration)(
|
|
2672
|
+
tree,
|
|
2673
|
+
options.project,
|
|
2674
|
+
addDependencyToConfig(project, options.repositoryName, options.repository)
|
|
2675
|
+
);
|
|
2676
|
+
updateChartYaml(
|
|
2677
|
+
tree,
|
|
2678
|
+
project,
|
|
2679
|
+
options.chartName,
|
|
2680
|
+
options.chartVersion,
|
|
2681
|
+
options.repository
|
|
2682
|
+
);
|
|
2683
|
+
if (options.format) {
|
|
2684
|
+
await (0, import_devkit.formatFiles)(tree);
|
|
2685
|
+
}
|
|
2686
|
+
return {
|
|
2687
|
+
success: true
|
|
2688
|
+
};
|
|
2689
|
+
}
|
|
2690
|
+
var generator_default = (0, import_workspace_tools.withRunGenerator)(
|
|
2691
|
+
"Helm Dependency",
|
|
2692
|
+
helmDependencyGeneratorFn
|
|
2740
2693
|
);
|
|
2741
2694
|
function addDependencyToConfig(project, name, url) {
|
|
2742
2695
|
return {
|
|
@@ -2795,8 +2748,7 @@ function updateChartYaml(tree, project, name, version, repository) {
|
|
|
2795
2748
|
}
|
|
2796
2749
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2797
2750
|
0 && (module.exports = {
|
|
2798
|
-
|
|
2799
|
-
helmDependencySchematic
|
|
2751
|
+
helmDependencyGeneratorFn
|
|
2800
2752
|
});
|
|
2801
2753
|
/*! Bundled license information:
|
|
2802
2754
|
|
package/src/utils/client.d.ts
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
import { AbstractHelmClient, PackageOptions, PushOptions } from "../types";
|
|
2
2
|
/** Helm wrapper class */
|
|
3
3
|
export declare class HelmClient extends AbstractHelmClient {
|
|
4
|
+
/**
|
|
5
|
+
* Creates an instance of HelmClient
|
|
6
|
+
*/
|
|
7
|
+
constructor();
|
|
4
8
|
/**
|
|
5
9
|
* Package a chart directory into a chart archive
|
|
6
10
|
*
|
|
7
11
|
* @param {PackageOptions} [options]
|
|
8
12
|
*/
|
|
9
13
|
package(options: PackageOptions): Promise<string | undefined>;
|
|
10
|
-
push(options: PushOptions):
|
|
11
|
-
dependencyUpdate(chartFolder: string):
|
|
12
|
-
dependencyBuild(chartFolder: string):
|
|
13
|
-
addRepository(name: string, url: string):
|
|
14
|
+
push(options: PushOptions): void;
|
|
15
|
+
dependencyUpdate(chartFolder: string): void;
|
|
16
|
+
dependencyBuild(chartFolder: string): void;
|
|
17
|
+
addRepository(name: string, url: string): void;
|
|
14
18
|
/**
|
|
15
19
|
* Initialize Helm
|
|
16
20
|
*
|
|
17
|
-
* @returns
|
|
21
|
+
* @returns A promise
|
|
18
22
|
*/
|
|
19
23
|
initialize(): Promise<void>;
|
|
24
|
+
private runCommand;
|
|
20
25
|
}
|
|
21
26
|
/**
|
|
22
27
|
* Create a new Helm client instance
|