@catladder/cli 1.2.0 → 1.4.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/dist/apps/cli/commands/project/commandInitGitlab.js +2 -3
- package/dist/apps/cli/commands/project/commandInitGitlab.js.map +1 -1
- package/dist/apps/cli/commands/project/utils/ensureNamespace.d.ts +2 -1
- package/dist/apps/cli/commands/project/utils/ensureNamespace.js +50 -20
- package/dist/apps/cli/commands/project/utils/ensureNamespace.js.map +1 -1
- package/dist/config/getProjectConfig.js +2 -2
- package/dist/config/getProjectConfig.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/apps/cli/commands/project/commandInitGitlab.ts +1 -5
- package/src/apps/cli/commands/project/utils/ensureNamespace.ts +42 -6
- package/src/config/getProjectConfig.ts +1 -1
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"catladder": "./bin/catladder"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@catladder/pipeline": "1.
|
|
19
|
+
"@catladder/pipeline": "1.4.0",
|
|
20
20
|
"@kubernetes/client-node": "^0.16.2",
|
|
21
21
|
"child-process-promise": "^2.2.1",
|
|
22
22
|
"command-exists-promise": "^2.0.2",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"eslint": "^8.7.0",
|
|
55
55
|
"typescript": "^4.5.4"
|
|
56
56
|
},
|
|
57
|
-
"version": "1.
|
|
57
|
+
"version": "1.4.0"
|
|
58
58
|
}
|
|
@@ -29,11 +29,7 @@ export default async (vorpal: Vorpal) =>
|
|
|
29
29
|
|
|
30
30
|
await connectToCluster(fullName);
|
|
31
31
|
|
|
32
|
-
const namespace =
|
|
33
|
-
context.fullConfig,
|
|
34
|
-
context.environment.shortName
|
|
35
|
-
);
|
|
36
|
-
await ensureNamespace(namespace);
|
|
32
|
+
const namespace = await ensureNamespace(context);
|
|
37
33
|
|
|
38
34
|
//$.verbose = true;
|
|
39
35
|
|
|
@@ -1,19 +1,55 @@
|
|
|
1
|
+
import { Context, getKubernetesNamespace } from "@catladder/pipeline";
|
|
1
2
|
import { V1Namespace, V1ObjectMeta } from "@kubernetes/client-node";
|
|
2
3
|
import k8sApi from "../../../../../k8sApi";
|
|
3
4
|
|
|
4
|
-
export default async function (
|
|
5
|
+
export default async function (context: Context) {
|
|
6
|
+
const namespace = getKubernetesNamespace(
|
|
7
|
+
context.fullConfig,
|
|
8
|
+
context.environment.shortName
|
|
9
|
+
);
|
|
10
|
+
const namespaceBody = new V1Namespace();
|
|
11
|
+
const metadata: V1ObjectMeta = {
|
|
12
|
+
name: namespace,
|
|
13
|
+
labels: {
|
|
14
|
+
customerName: context.fullConfig.customerName,
|
|
15
|
+
appName: context.fullConfig.appName,
|
|
16
|
+
environment: context.environment.shortName,
|
|
17
|
+
components: Object.keys(context.fullConfig.components).join("_"), // limited chars available...
|
|
18
|
+
buildTypes: Object.values(context.fullConfig.components)
|
|
19
|
+
.map((config) => config.build.type)
|
|
20
|
+
.join("_"), // limited chars available...
|
|
21
|
+
...Object.fromEntries(
|
|
22
|
+
Object.entries(context.fullConfig.components).map(
|
|
23
|
+
([componentName, config]) => [
|
|
24
|
+
"buildType_" + componentName,
|
|
25
|
+
config.build.type,
|
|
26
|
+
]
|
|
27
|
+
)
|
|
28
|
+
),
|
|
29
|
+
...(context.fullConfig.meta?.labels ?? {}),
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
namespaceBody.metadata = metadata;
|
|
5
34
|
try {
|
|
6
35
|
await k8sApi.readNamespace(namespace);
|
|
36
|
+
|
|
37
|
+
await k8sApi.patchNamespace(
|
|
38
|
+
namespace,
|
|
39
|
+
namespaceBody,
|
|
40
|
+
undefined,
|
|
41
|
+
undefined,
|
|
42
|
+
undefined,
|
|
43
|
+
undefined,
|
|
44
|
+
{ headers: { "content-type": "application/merge-patch+json" } } // see https://github.com/kubernetes-client/javascript/issues/443
|
|
45
|
+
); // update meta data
|
|
7
46
|
} catch (e) {
|
|
8
47
|
if (e.response?.body?.reason === "NotFound") {
|
|
9
|
-
const namespaceBody = new V1Namespace();
|
|
10
|
-
const metadata = {
|
|
11
|
-
name: namespace,
|
|
12
|
-
};
|
|
13
|
-
namespaceBody.metadata = metadata as V1ObjectMeta;
|
|
14
48
|
await k8sApi.createNamespace(namespaceBody);
|
|
15
49
|
} else {
|
|
50
|
+
console.error(e.response?.body);
|
|
16
51
|
throw e;
|
|
17
52
|
}
|
|
18
53
|
}
|
|
54
|
+
return namespace;
|
|
19
55
|
}
|
|
@@ -93,7 +93,7 @@ const resolveSecrets = async (
|
|
|
93
93
|
|
|
94
94
|
return Object.fromEntries(
|
|
95
95
|
Object.entries(allEnvVars).map(([key, value]) => {
|
|
96
|
-
const isSecret = value?.startsWith?.("$CL_");
|
|
96
|
+
const isSecret = String(value)?.startsWith?.("$CL_");
|
|
97
97
|
if (isSecret) {
|
|
98
98
|
// secrets have CL_XXXX structure
|
|
99
99
|
const found = allVariablesInGitlab.find((v) => "$" + v.key === value);
|