@storm-software/k8s-tools 0.12.0 → 0.18.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 +56 -0
- package/{src → dist/src}/generators/helm-chart/schema.d.ts +4 -1
- package/{src → dist/src}/generators/helm-dependency/schema.d.ts +4 -1
- package/dist/src/types.d.mts +31 -0
- package/{src → dist/src}/types.d.ts +9 -6
- package/dist/src/types.js +7 -0
- package/dist/src/types.mjs +7 -0
- package/executors.json +4 -4
- package/generators.json +4 -4
- package/package.json +1 -84
- package/index.d.ts +0 -1
- package/index.js +0 -3267
- package/meta.json +0 -634
- package/src/executors/container-publish/executor.d.ts +0 -7
- package/src/executors/container-publish/executor.js +0 -199
- package/src/executors/helm-package/executor.d.ts +0 -8
- package/src/executors/helm-package/executor.js +0 -252
- package/src/executors/index.d.ts +0 -2
- package/src/generators/helm-chart/files/chart/.helmignore +0 -23
- package/src/generators/helm-chart/files/chart/templates/NOTES.txt +0 -22
- package/src/generators/helm-chart/files/chart/templates/_helpers.yaml +0 -62
- package/src/generators/helm-chart/files/chart/templates/deployment.yaml +0 -68
- package/src/generators/helm-chart/files/chart/templates/hpa.yaml +0 -32
- package/src/generators/helm-chart/files/chart/templates/ingress.yaml +0 -61
- package/src/generators/helm-chart/files/chart/templates/service.yaml +0 -13
- package/src/generators/helm-chart/files/chart/templates/serviceaccount.yaml +0 -13
- package/src/generators/helm-chart/files/chart/templates/test/test-connection.yaml +0 -15
- package/src/generators/helm-chart/generator.d.ts +0 -8
- package/src/generators/helm-chart/generator.js +0 -89
- package/src/generators/helm-dependency/generator.d.ts +0 -8
- package/src/generators/helm-dependency/generator.js +0 -2757
- package/src/generators/index.d.ts +0 -2
- package/src/index.d.ts +0 -3
- package/src/plugins/docker/_dockerfile.d.ts +0 -9
- package/src/plugins/docker/index.d.ts +0 -1
- package/src/plugins/docker/index.js +0 -215
- package/src/plugins/index.d.ts +0 -1
- package/src/utils/client.d.ts +0 -31
- package/src/utils/ensure-init.d.ts +0 -9
- package/src/utils/prettier.d.ts +0 -9
- /package/{src → dist/src}/executors/container-publish/schema.d.ts +0 -0
- /package/{src → dist/src}/executors/container-publish/schema.json +0 -0
- /package/{src → dist/src}/executors/helm-package/schema.d.ts +0 -0
- /package/{src → dist/src}/executors/helm-package/schema.json +0 -0
- /package/{src → dist/src}/generators/helm-chart/files/chart/Chart.yaml.template +0 -0
- /package/{src → dist/src}/generators/helm-chart/files/chart/values.yaml +0 -0
- /package/{src → dist/src}/generators/helm-chart/schema.json +0 -0
- /package/{src → dist/src}/generators/helm-dependency/schema.json +0 -0
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
29
|
-
// packages/k8s-tools/src/executors/container-publish/executor.ts
|
|
30
|
-
var executor_exports = {};
|
|
31
|
-
__export(executor_exports, {
|
|
32
|
-
default: () => publishExecutor,
|
|
33
|
-
getRegistryVersion: () => getRegistryVersion
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(executor_exports);
|
|
36
|
-
var import_devkit = require("@nx/devkit");
|
|
37
|
-
var import_apply_workspace_tokens = require("@storm-software/workspace-tools/utils/apply-workspace-tokens");
|
|
38
|
-
var import_package_helpers = require("@storm-software/workspace-tools/utils/package-helpers");
|
|
39
|
-
var import_node_https = __toESM(require("node:https"));
|
|
40
|
-
async function* publishExecutor(options, context) {
|
|
41
|
-
const { loadStormConfig, applyWorkspaceTokens, findWorkspaceRoot } = await import("@storm-software/config-tools");
|
|
42
|
-
const isDryRun = process.env.NX_DRY_RUN === "true" || options.dryRun || false;
|
|
43
|
-
if (!context.projectName) {
|
|
44
|
-
throw new Error("The executor requires a projectName.");
|
|
45
|
-
}
|
|
46
|
-
console.info(
|
|
47
|
-
`\u{1F680} Running Storm Container Registry Publish executor on the ${context.projectName} crate`
|
|
48
|
-
);
|
|
49
|
-
const workspaceRoot = findWorkspaceRoot();
|
|
50
|
-
const config = await loadStormConfig(workspaceRoot);
|
|
51
|
-
const projectConfig = context.projectsConfigurations?.projects[context.projectName];
|
|
52
|
-
if (!projectConfig) {
|
|
53
|
-
throw new Error(
|
|
54
|
-
`The executor requires a valid projectsConfiguration - No configuration found for project ${context.projectName}`
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
const projectRoot = projectConfig?.root ?? workspaceRoot;
|
|
58
|
-
const sourceRoot = projectConfig?.sourceRoot ?? workspaceRoot;
|
|
59
|
-
const projectName = projectConfig?.name ?? context.projectName;
|
|
60
|
-
config.workspaceRoot = workspaceRoot;
|
|
61
|
-
const tokenized = await applyWorkspaceTokens(
|
|
62
|
-
options,
|
|
63
|
-
{
|
|
64
|
-
config,
|
|
65
|
-
workspaceRoot,
|
|
66
|
-
projectRoot,
|
|
67
|
-
sourceRoot,
|
|
68
|
-
projectName,
|
|
69
|
-
...projectConfig
|
|
70
|
-
},
|
|
71
|
-
import_apply_workspace_tokens.applyWorkspaceExecutorTokens
|
|
72
|
-
);
|
|
73
|
-
tokenized.engine ??= "docker";
|
|
74
|
-
tokenized.registry ??= config.registry.container;
|
|
75
|
-
try {
|
|
76
|
-
if (isDryRun) {
|
|
77
|
-
console.log(
|
|
78
|
-
`Would publish to ${tokenized.registry}, but [dry-run] was set`
|
|
79
|
-
);
|
|
80
|
-
} else {
|
|
81
|
-
console.log(`Published to ${tokenized.registry}`);
|
|
82
|
-
const packageManager = (0, import_package_helpers.getPackageInfo)(projectConfig);
|
|
83
|
-
if (packageManager) {
|
|
84
|
-
tokenized["build-args"] ??= [
|
|
85
|
-
"ENVIRONMENT=production",
|
|
86
|
-
"DEBUG_IMAGE=false"
|
|
87
|
-
];
|
|
88
|
-
tokenized["labels"] ??= [];
|
|
89
|
-
let version = "";
|
|
90
|
-
if (process.env.TAG) {
|
|
91
|
-
version = process.env.TAG;
|
|
92
|
-
} else {
|
|
93
|
-
if (packageManager.type === "Cargo.toml") {
|
|
94
|
-
version = packageManager.content.package.version;
|
|
95
|
-
} else if (packageManager.type === "package.json") {
|
|
96
|
-
version = packageManager.content.version;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
tokenized["build-args"].push(`RELEASE=${version}`);
|
|
100
|
-
tokenized["labels"].push(`org.opencontainers.image.version=${version}`);
|
|
101
|
-
const tags = await getRegistryVersion(projectName, config);
|
|
102
|
-
if (tags.length === 0) {
|
|
103
|
-
tokenized["labels"].push(
|
|
104
|
-
`org.opencontainers.image.created=${(/* @__PURE__ */ new Date()).toISOString()}`
|
|
105
|
-
);
|
|
106
|
-
} else if (tags.includes(version)) {
|
|
107
|
-
console.warn(
|
|
108
|
-
`Skipped package "${projectName}" because v${version} already exists in ${tokenized.registry}`
|
|
109
|
-
);
|
|
110
|
-
return {
|
|
111
|
-
success: true
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
} else {
|
|
115
|
-
console.warn(
|
|
116
|
-
`No package manager found for project "${projectName}" - Skipping container publishing`
|
|
117
|
-
);
|
|
118
|
-
return {
|
|
119
|
-
success: true
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
const { project, target, configuration } = (0, import_devkit.parseTargetString)(
|
|
123
|
-
"container",
|
|
124
|
-
context
|
|
125
|
-
);
|
|
126
|
-
for await (const output of await (0, import_devkit.runExecutor)({ project, target, configuration }, tokenized, context)) {
|
|
127
|
-
if (!output.success) {
|
|
128
|
-
throw new Error("Could not compile application files");
|
|
129
|
-
}
|
|
130
|
-
yield;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return {
|
|
134
|
-
success: true
|
|
135
|
-
};
|
|
136
|
-
} catch (error) {
|
|
137
|
-
console.error(`Failed to publish to ${tokenized.registry}`);
|
|
138
|
-
console.error(error);
|
|
139
|
-
console.log("");
|
|
140
|
-
return {
|
|
141
|
-
success: false
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
var getRegistryVersion = (name, config) => {
|
|
146
|
-
if (!name) {
|
|
147
|
-
throw new Error(
|
|
148
|
-
"The `getRegistryVersion` function requires a container name."
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
try {
|
|
152
|
-
const tagsApiUrl = `${config.registry.container}/v2/namespaces/${encodeURIComponent(config.namespace ? config.namespace : "storm-software")}/repositories/${encodeURIComponent(
|
|
153
|
-
name.replace(`${config.namespace}-`, "")
|
|
154
|
-
)}/tags`;
|
|
155
|
-
console.log(`Checking for existing version at ${tagsApiUrl}`);
|
|
156
|
-
return new Promise(
|
|
157
|
-
(resolve, reject) => import_node_https.default.get(tagsApiUrl, (res) => {
|
|
158
|
-
if (res.statusCode === 404) {
|
|
159
|
-
console.log(`No existing version found at ${tagsApiUrl}`);
|
|
160
|
-
return resolve([]);
|
|
161
|
-
}
|
|
162
|
-
res.on("data", (data) => {
|
|
163
|
-
if (data) {
|
|
164
|
-
console.log(
|
|
165
|
-
`Existing versions found at ${tagsApiUrl} - ${data}`
|
|
166
|
-
);
|
|
167
|
-
const json = JSON.parse(data.toString());
|
|
168
|
-
return resolve(
|
|
169
|
-
json.results.filter(
|
|
170
|
-
(result) => result.status === "active" && result.name && result.name !== "latest"
|
|
171
|
-
).map((result) => result.name)
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
return reject(
|
|
175
|
-
new Error(
|
|
176
|
-
"No data returned from container registry, expected a 404 if no tags exist"
|
|
177
|
-
)
|
|
178
|
-
);
|
|
179
|
-
});
|
|
180
|
-
}).on("error", (e) => {
|
|
181
|
-
throw e;
|
|
182
|
-
})
|
|
183
|
-
);
|
|
184
|
-
} catch (error) {
|
|
185
|
-
console.error(`Failed to get version from ${config.registry.container}`);
|
|
186
|
-
console.error(error);
|
|
187
|
-
console.log("");
|
|
188
|
-
throw new Error(
|
|
189
|
-
`Could not get version from container registry - ${config.registry.container}`,
|
|
190
|
-
{
|
|
191
|
-
cause: error
|
|
192
|
-
}
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
197
|
-
0 && (module.exports = {
|
|
198
|
-
getRegistryVersion
|
|
199
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ExecutorContext, PromiseExecutor } from "@nx/devkit";
|
|
2
|
-
import type { StormConfig } from "@storm-software/config";
|
|
3
|
-
import { HelmPackageExecutorSchema } from "./schema";
|
|
4
|
-
export declare function serveExecutor(options: HelmPackageExecutorSchema, context: ExecutorContext, config?: StormConfig): Promise<{
|
|
5
|
-
success: boolean;
|
|
6
|
-
}>;
|
|
7
|
-
declare const _default: PromiseExecutor<HelmPackageExecutorSchema>;
|
|
8
|
-
export default _default;
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
29
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
30
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
31
|
-
if (decorator = decorators[i])
|
|
32
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
33
|
-
if (kind && result) __defProp(target, key, result);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
// packages/k8s-tools/src/executors/helm-package/executor.ts
|
|
38
|
-
var executor_exports = {};
|
|
39
|
-
__export(executor_exports, {
|
|
40
|
-
default: () => executor_default,
|
|
41
|
-
serveExecutor: () => serveExecutor
|
|
42
|
-
});
|
|
43
|
-
module.exports = __toCommonJS(executor_exports);
|
|
44
|
-
var import_base_executor = require("@storm-software/workspace-tools/base/base-executor");
|
|
45
|
-
|
|
46
|
-
// packages/k8s-tools/src/utils/client.ts
|
|
47
|
-
var import_node_child_process = require("node:child_process");
|
|
48
|
-
|
|
49
|
-
// packages/k8s-tools/src/types.ts
|
|
50
|
-
var AbstractHelmClient = class {
|
|
51
|
-
constructor() {
|
|
52
|
-
this.initialized = false;
|
|
53
|
-
}
|
|
54
|
-
async initialize() {
|
|
55
|
-
throw new Error("Method not implemented.");
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// packages/k8s-tools/src/utils/ensure-init.ts
|
|
60
|
-
var ensureInitialized = (target, propertyKey, descriptor) => {
|
|
61
|
-
const originalMethod = descriptor.value;
|
|
62
|
-
descriptor.value = async function(...arguments_) {
|
|
63
|
-
const self = this;
|
|
64
|
-
if (self.initialized === void 0 || typeof self.initialize !== "function") {
|
|
65
|
-
throw new TypeError(
|
|
66
|
-
`The ensureInitialized decorator can only be applied in classes with an 'initialized' property and 'initialize' method.`
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
if (!self.initialized) {
|
|
70
|
-
await self.initialize();
|
|
71
|
-
}
|
|
72
|
-
return originalMethod.apply(this, arguments_);
|
|
73
|
-
};
|
|
74
|
-
return descriptor;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// packages/k8s-tools/src/utils/client.ts
|
|
78
|
-
var HelmClient = class extends AbstractHelmClient {
|
|
79
|
-
/**
|
|
80
|
-
* Creates an instance of HelmClient
|
|
81
|
-
*/
|
|
82
|
-
constructor() {
|
|
83
|
-
super();
|
|
84
|
-
}
|
|
85
|
-
package(options) {
|
|
86
|
-
let chartPath = void 0;
|
|
87
|
-
let output = {};
|
|
88
|
-
try {
|
|
89
|
-
output = this.runCommand([
|
|
90
|
-
"helm",
|
|
91
|
-
"package",
|
|
92
|
-
options.chartFolder,
|
|
93
|
-
"-d",
|
|
94
|
-
options.outputFolder
|
|
95
|
-
]);
|
|
96
|
-
} catch (err) {
|
|
97
|
-
if (err?.stderr.length > 0 && err?.exitCode !== 0) {
|
|
98
|
-
throw new Error(`Failed to package chart: ${err.stderr}`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
if (output?.stderr.length > 0 && output?.exitCode !== 0) {
|
|
102
|
-
throw new Error(`Failed to package chart: ${output.stderr}`);
|
|
103
|
-
}
|
|
104
|
-
const match = output.stdout?.match(
|
|
105
|
-
/Successfully packaged chart and saved it to: (.+)/
|
|
106
|
-
);
|
|
107
|
-
if (!match || match.length < 2) {
|
|
108
|
-
throw new Error("Failed to parse chart path from helm output");
|
|
109
|
-
}
|
|
110
|
-
chartPath = match[1]?.trim();
|
|
111
|
-
return new Promise((resolve) => resolve(chartPath));
|
|
112
|
-
}
|
|
113
|
-
push(options) {
|
|
114
|
-
try {
|
|
115
|
-
this.runCommand(["helm", "push", options.chartPath, options.remote]);
|
|
116
|
-
} catch (err) {
|
|
117
|
-
if (err?.stderr.length > 0 && err?.exitCode !== 0) {
|
|
118
|
-
throw new Error(`Failed to push chart: ${err.stderr}`);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
dependencyUpdate(chartFolder) {
|
|
123
|
-
try {
|
|
124
|
-
this.runCommand(["helm", "dependency", "update", chartFolder]);
|
|
125
|
-
} catch (err) {
|
|
126
|
-
if (err?.stderr.length > 0 && err?.exitCode !== 0) {
|
|
127
|
-
throw new Error(`Failed to update chart dependencies: ${err.stderr}`);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
dependencyBuild(chartFolder) {
|
|
132
|
-
try {
|
|
133
|
-
this.runCommand(["helm", "dependency", "build", chartFolder]);
|
|
134
|
-
} catch (err) {
|
|
135
|
-
if (err?.stderr.length > 0 && err?.exitCode !== 0) {
|
|
136
|
-
throw new Error(`Failed to build chart dependencies: ${err.stderr}`);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
addRepository(name, url) {
|
|
141
|
-
try {
|
|
142
|
-
this.runCommand(["helm", "repo", "add", name, url]);
|
|
143
|
-
} catch (err) {
|
|
144
|
-
if (err?.stderr.length > 0 && err?.exitCode !== 0) {
|
|
145
|
-
throw new Error(`Failed to add repository: ${err.stderr}`);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Initialize Helm
|
|
151
|
-
*
|
|
152
|
-
* @returns A promise
|
|
153
|
-
*/
|
|
154
|
-
async initialize() {
|
|
155
|
-
if (this.initialized) {
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
try {
|
|
159
|
-
this.runCommand(["helm", "version"]);
|
|
160
|
-
} catch (err) {
|
|
161
|
-
if (err?.stderr.length > 0 && err?.exitCode !== 0) {
|
|
162
|
-
throw new Error(`Helm is not installed: ${err.stderr}`);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return new Promise((resolve) => {
|
|
166
|
-
this.initialized = true;
|
|
167
|
-
resolve();
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
runCommand(commands) {
|
|
171
|
-
return (0, import_node_child_process.execSync)(commands.filter(Boolean).join(" "), {
|
|
172
|
-
encoding: "utf8",
|
|
173
|
-
windowsHide: true,
|
|
174
|
-
maxBuffer: 1024 * 1e6,
|
|
175
|
-
stdio: "pipe"
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
__decorateClass([
|
|
180
|
-
ensureInitialized
|
|
181
|
-
], HelmClient.prototype, "package", 1);
|
|
182
|
-
__decorateClass([
|
|
183
|
-
ensureInitialized
|
|
184
|
-
], HelmClient.prototype, "push", 1);
|
|
185
|
-
__decorateClass([
|
|
186
|
-
ensureInitialized
|
|
187
|
-
], HelmClient.prototype, "dependencyUpdate", 1);
|
|
188
|
-
__decorateClass([
|
|
189
|
-
ensureInitialized
|
|
190
|
-
], HelmClient.prototype, "dependencyBuild", 1);
|
|
191
|
-
__decorateClass([
|
|
192
|
-
ensureInitialized
|
|
193
|
-
], HelmClient.prototype, "addRepository", 1);
|
|
194
|
-
var createHelmClient = () => {
|
|
195
|
-
return new HelmClient();
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
// packages/k8s-tools/src/executors/helm-package/executor.ts
|
|
199
|
-
async function serveExecutor(options, context, config) {
|
|
200
|
-
const { writeWarning } = await import("@storm-software/config-tools");
|
|
201
|
-
if (!context?.projectName || !context?.projectsConfigurations?.projects?.[context.projectName]?.root) {
|
|
202
|
-
throw new Error("Nx executor context was invalid");
|
|
203
|
-
}
|
|
204
|
-
const helm = createHelmClient();
|
|
205
|
-
if (options.dependencies?.repositories) {
|
|
206
|
-
for (const repository of options.dependencies.repositories) {
|
|
207
|
-
if (repository.name && repository.url) {
|
|
208
|
-
helm.addRepository(repository.name, repository.url);
|
|
209
|
-
} else {
|
|
210
|
-
throw new Error("Repository name and url are required");
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
if (options.dependencies?.update) {
|
|
215
|
-
helm.dependencyUpdate(options.chartFolder);
|
|
216
|
-
}
|
|
217
|
-
if (options.dependencies?.build) {
|
|
218
|
-
helm.dependencyBuild(options.chartFolder);
|
|
219
|
-
}
|
|
220
|
-
const chartPath = await helm.package({
|
|
221
|
-
chartFolder: options.chartFolder,
|
|
222
|
-
outputFolder: options.outputFolder
|
|
223
|
-
});
|
|
224
|
-
if (options.push && chartPath && options.remote) {
|
|
225
|
-
helm.push({
|
|
226
|
-
chartPath,
|
|
227
|
-
remote: options.remote
|
|
228
|
-
});
|
|
229
|
-
} else {
|
|
230
|
-
writeWarning(`Chart packaged at: ${chartPath}`, config);
|
|
231
|
-
}
|
|
232
|
-
return {
|
|
233
|
-
success: true
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
var executor_default = (0, import_base_executor.withRunExecutor)(
|
|
237
|
-
"Helm Chart Package executor",
|
|
238
|
-
serveExecutor,
|
|
239
|
-
{
|
|
240
|
-
skipReadingConfig: false,
|
|
241
|
-
hooks: {
|
|
242
|
-
applyDefaultOptions: (options) => {
|
|
243
|
-
options.port ??= 4500;
|
|
244
|
-
return options;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
);
|
|
249
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
250
|
-
0 && (module.exports = {
|
|
251
|
-
serveExecutor
|
|
252
|
-
});
|
package/src/executors/index.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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/
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
1. Get the application URL by running these commands:
|
|
2
|
-
{{- if .Values.ingress.enabled }}
|
|
3
|
-
{{- range $host := .Values.ingress.hosts }}
|
|
4
|
-
{{- range .paths }}
|
|
5
|
-
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
|
|
6
|
-
{{- end }}
|
|
7
|
-
{{- end }}
|
|
8
|
-
{{- else if contains "NodePort" .Values.service.type }}
|
|
9
|
-
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "chart.fullname" . }})
|
|
10
|
-
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
|
|
11
|
-
echo http://$NODE_IP:$NODE_PORT
|
|
12
|
-
{{- else if contains "LoadBalancer" .Values.service.type }}
|
|
13
|
-
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
|
|
14
|
-
You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "chart.fullname" . }}'
|
|
15
|
-
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "chart.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
|
|
16
|
-
echo http://$SERVICE_IP:{{ .Values.service.port }}
|
|
17
|
-
{{- else if contains "ClusterIP" .Values.service.type }}
|
|
18
|
-
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "chart.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
|
|
19
|
-
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
|
|
20
|
-
echo "Visit http://127.0.0.1:8080 to use your application"
|
|
21
|
-
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
|
|
22
|
-
{{- end }}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
{{/*
|
|
2
|
-
Expand the name of the chart.
|
|
3
|
-
*/}}
|
|
4
|
-
{{- define "chart.name" -}}
|
|
5
|
-
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
|
|
6
|
-
{{- end }}
|
|
7
|
-
|
|
8
|
-
{{/*
|
|
9
|
-
Create a default fully qualified app name.
|
|
10
|
-
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
|
11
|
-
If release name contains chart name it will be used as a full name.
|
|
12
|
-
*/}}
|
|
13
|
-
{{- define "chart.fullname" -}}
|
|
14
|
-
{{- if .Values.fullnameOverride }}
|
|
15
|
-
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
|
|
16
|
-
{{- else }}
|
|
17
|
-
{{- $name := default .Chart.Name .Values.nameOverride }}
|
|
18
|
-
{{- if contains $name .Release.Name }}
|
|
19
|
-
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
|
|
20
|
-
{{- else }}
|
|
21
|
-
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
|
|
22
|
-
{{- end }}
|
|
23
|
-
{{- end }}
|
|
24
|
-
{{- end }}
|
|
25
|
-
|
|
26
|
-
{{/*
|
|
27
|
-
Create chart name and version as used by the chart label.
|
|
28
|
-
*/}}
|
|
29
|
-
{{- define "chart.chart" -}}
|
|
30
|
-
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
|
31
|
-
{{- end }}
|
|
32
|
-
|
|
33
|
-
{{/*
|
|
34
|
-
Common labels
|
|
35
|
-
*/}}
|
|
36
|
-
{{- define "chart.labels" -}}
|
|
37
|
-
helm.sh/chart: {{ include "chart.chart" . }}
|
|
38
|
-
{{ include "chart.selectorLabels" . }}
|
|
39
|
-
{{- if .Chart.AppVersion }}
|
|
40
|
-
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
|
41
|
-
{{- end }}
|
|
42
|
-
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
|
43
|
-
{{- end }}
|
|
44
|
-
|
|
45
|
-
{{/*
|
|
46
|
-
Selector labels
|
|
47
|
-
*/}}
|
|
48
|
-
{{- define "chart.selectorLabels" -}}
|
|
49
|
-
app.kubernetes.io/name: {{ include "chart.name" . }}
|
|
50
|
-
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
51
|
-
{{- end }}
|
|
52
|
-
|
|
53
|
-
{{/*
|
|
54
|
-
Create the name of the service account to use
|
|
55
|
-
*/}}
|
|
56
|
-
{{- define "chart.serviceAccountName" -}}
|
|
57
|
-
{{- if .Values.serviceAccount.create }}
|
|
58
|
-
{{- default (include "chart.fullname" .) .Values.serviceAccount.name }}
|
|
59
|
-
{{- else }}
|
|
60
|
-
{{- default "default" .Values.serviceAccount.name }}
|
|
61
|
-
{{- end }}
|
|
62
|
-
{{- end }}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
apiVersion: apps/v1
|
|
2
|
-
kind: Deployment
|
|
3
|
-
metadata:
|
|
4
|
-
name: {{ include "chart.fullname" . }}
|
|
5
|
-
labels:
|
|
6
|
-
{{- include "chart.labels" . | nindent 4 }}
|
|
7
|
-
spec:
|
|
8
|
-
{{- if not .Values.autoscaling.enabled }}
|
|
9
|
-
replicas: {{ .Values.replicaCount }}
|
|
10
|
-
{{- end }}
|
|
11
|
-
selector:
|
|
12
|
-
matchLabels:
|
|
13
|
-
{{- include "chart.selectorLabels" . | nindent 6 }}
|
|
14
|
-
template:
|
|
15
|
-
metadata:
|
|
16
|
-
{{- with .Values.podAnnotations }}
|
|
17
|
-
annotations:
|
|
18
|
-
{{- toYaml . | nindent 8 }}
|
|
19
|
-
{{- end }}
|
|
20
|
-
labels:
|
|
21
|
-
{{- include "chart.labels" . | nindent 8 }}
|
|
22
|
-
{{- with .Values.podLabels }}
|
|
23
|
-
{{- toYaml . | nindent 8 }}
|
|
24
|
-
{{- end }}
|
|
25
|
-
spec:
|
|
26
|
-
{{- with .Values.imagePullSecrets }}
|
|
27
|
-
imagePullSecrets:
|
|
28
|
-
{{- toYaml . | nindent 8 }}
|
|
29
|
-
{{- end }}
|
|
30
|
-
serviceAccountName: {{ include "chart.serviceAccountName" . }}
|
|
31
|
-
securityContext:
|
|
32
|
-
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
|
33
|
-
containers:
|
|
34
|
-
- name: {{ .Chart.Name }}
|
|
35
|
-
securityContext:
|
|
36
|
-
{{- toYaml .Values.securityContext | nindent 12 }}
|
|
37
|
-
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
|
|
38
|
-
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
|
39
|
-
ports:
|
|
40
|
-
- name: http
|
|
41
|
-
containerPort: {{ .Values.service.port }}
|
|
42
|
-
protocol: TCP
|
|
43
|
-
livenessProbe:
|
|
44
|
-
{{- toYaml .Values.livenessProbe | nindent 12 }}
|
|
45
|
-
readinessProbe:
|
|
46
|
-
{{- toYaml .Values.readinessProbe | nindent 12 }}
|
|
47
|
-
resources:
|
|
48
|
-
{{- toYaml .Values.resources | nindent 12 }}
|
|
49
|
-
{{- with .Values.volumeMounts }}
|
|
50
|
-
volumeMounts:
|
|
51
|
-
{{- toYaml . | nindent 12 }}
|
|
52
|
-
{{- end }}
|
|
53
|
-
{{- with .Values.volumes }}
|
|
54
|
-
volumes:
|
|
55
|
-
{{- toYaml . | nindent 8 }}
|
|
56
|
-
{{- end }}
|
|
57
|
-
{{- with .Values.nodeSelector }}
|
|
58
|
-
nodeSelector:
|
|
59
|
-
{{- toYaml . | nindent 8 }}
|
|
60
|
-
{{- end }}
|
|
61
|
-
{{- with .Values.affinity }}
|
|
62
|
-
affinity:
|
|
63
|
-
{{- toYaml . | nindent 8 }}
|
|
64
|
-
{{- end }}
|
|
65
|
-
{{- with .Values.tolerations }}
|
|
66
|
-
tolerations:
|
|
67
|
-
{{- toYaml . | nindent 8 }}
|
|
68
|
-
{{- end }}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{{- if .Values.autoscaling.enabled }}
|
|
2
|
-
apiVersion: autoscaling/v2
|
|
3
|
-
kind: HorizontalPodAutoscaler
|
|
4
|
-
metadata:
|
|
5
|
-
name: {{ include "chart.fullname" . }}
|
|
6
|
-
labels:
|
|
7
|
-
{{- include "chart.labels" . | nindent 4 }}
|
|
8
|
-
spec:
|
|
9
|
-
scaleTargetRef:
|
|
10
|
-
apiVersion: apps/v1
|
|
11
|
-
kind: Deployment
|
|
12
|
-
name: {{ include "chart.fullname" . }}
|
|
13
|
-
minReplicas: {{ .Values.autoscaling.minReplicas }}
|
|
14
|
-
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
|
|
15
|
-
metrics:
|
|
16
|
-
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
|
|
17
|
-
- type: Resource
|
|
18
|
-
resource:
|
|
19
|
-
name: cpu
|
|
20
|
-
target:
|
|
21
|
-
type: Utilization
|
|
22
|
-
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
|
|
23
|
-
{{- end }}
|
|
24
|
-
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
|
|
25
|
-
- type: Resource
|
|
26
|
-
resource:
|
|
27
|
-
name: memory
|
|
28
|
-
target:
|
|
29
|
-
type: Utilization
|
|
30
|
-
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
|
|
31
|
-
{{- end }}
|
|
32
|
-
{{- end }}
|