@catladder/cli 1.40.2 → 1.41.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/bin/catenv +1 -1
- package/bin/catenv-dev +3 -0
- package/bin/catladder +1 -1
- package/bin/catladder-dev +3 -0
- package/dist/apps/cli/commands/general/index.d.ts +1 -1
- package/dist/apps/cli/commands/general/portForward.d.ts +1 -1
- package/dist/apps/cli/commands/mongodb/index.d.ts +1 -1
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.d.ts +1 -1
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js +2 -1
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js.map +1 -1
- package/dist/apps/cli/commands/mongodb/projectMongoGetShell.d.ts +1 -1
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.d.ts +1 -1
- package/dist/apps/cli/commands/mongodb/utils/index.js +2 -1
- package/dist/apps/cli/commands/mongodb/utils/index.js.map +1 -1
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandConfigSecrets.d.ts +2 -1
- package/dist/apps/cli/commands/project/commandConfigSecrets.js.map +1 -1
- package/dist/apps/cli/commands/project/commandCopyDB.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandDeletePods.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandDeletePods.js +2 -1
- package/dist/apps/cli/commands/project/commandDeletePods.js.map +1 -1
- package/dist/apps/cli/commands/project/commandDeleteProject.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandEnvVars.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandGetShell.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandGetShell.js +2 -1
- package/dist/apps/cli/commands/project/commandGetShell.js.map +1 -1
- package/dist/apps/cli/commands/project/commandGitlabCi.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandGitlabCi.js.map +1 -1
- package/dist/apps/cli/commands/project/commandInitProject.old.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandListPods.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandListPods.js +2 -2
- package/dist/apps/cli/commands/project/commandListPods.js.map +1 -1
- package/dist/apps/cli/commands/project/commandMigrateHelm3.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandNamespace.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenCostDashboard.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenDashboard.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenEnv.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenGit.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenGit.js +2 -7
- package/dist/apps/cli/commands/project/commandOpenGit.js.map +1 -1
- package/dist/apps/cli/commands/project/commandOpenGrafana.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js +2 -1
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js.map +1 -1
- package/dist/apps/cli/commands/project/commandOpenLogs.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandPauseProject.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandPortForward.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandPortForward.js +2 -1
- package/dist/apps/cli/commands/project/commandPortForward.js.map +1 -1
- package/dist/apps/cli/commands/project/commandSetup.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandTriggerCronjob.d.ts +1 -1
- package/dist/apps/cli/commands/project/commandTriggerCronjob.js.map +1 -1
- package/dist/apps/cli/commands/project/index.d.ts +1 -1
- package/dist/apps/cli/commands/project/setup/index.d.ts +1 -1
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.d.ts +1 -1
- package/dist/apps/cli/commands/project/setup/setupContext.d.ts +2 -2
- package/dist/apps/cli/commands/project/setup/setupContext.js.map +1 -1
- package/dist/apps/cli/commands/project/setup/setupKubernetes.d.ts +2 -2
- package/dist/apps/cli/commands/project/setup/setupKubernetes.js +10 -15
- package/dist/apps/cli/commands/project/setup/setupKubernetes.js.map +1 -1
- package/dist/apps/cli/commands/project/utils/ensureNamespace.d.ts +1 -1
- package/dist/apps/cli/commands/project/utils/ensureNamespace.js.map +1 -1
- package/dist/apps/cli/commands/project/utils/showProjectBanner.d.ts +1 -1
- package/dist/apps/cli/commands/shared/index.d.ts +1 -1
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.d.ts +1 -1
- package/dist/apps/cli/config/writeConfig.d.ts +2 -2
- package/dist/apps/cli/verify/index.d.ts +1 -1
- package/dist/apps/cli/verify/migration/fromv2.d.ts +1 -1
- package/dist/apps/cli/verify/migration/fromv2.js.map +1 -1
- package/dist/apps/cli/verify/migration/migrateSecrets.d.ts +3 -3
- package/dist/apps/cli/verify/migration/migrateSecrets.js.map +1 -1
- package/dist/apps/cli/verify/migration/oldGitlabCi.d.ts +1 -1
- package/dist/bundles/catenv/index.js +15 -0
- package/dist/bundles/catenv/xdg-open +1066 -0
- package/dist/bundles/cli/clipboard_i686.exe +0 -0
- package/dist/bundles/cli/clipboard_x86_64.exe +0 -0
- package/dist/bundles/cli/exec-child.js +39 -0
- package/dist/bundles/cli/index.js +574 -0
- package/dist/bundles/cli/xdg-open +1066 -0
- package/dist/bundles/cli/xsel +0 -0
- package/dist/catenv.js +2 -4
- package/dist/catenv.js.map +1 -1
- package/dist/cli.js +0 -2
- package/dist/cli.js.map +1 -1
- package/dist/config/getProjectConfig.d.ts +3 -6
- package/dist/config/getProjectConfig.js +10 -6
- package/dist/config/getProjectConfig.js.map +1 -1
- package/dist/config/parseChoice.d.ts +4 -0
- package/dist/config/parseChoice.js +9 -0
- package/dist/config/parseChoice.js.map +1 -0
- package/dist/kubernetes/index.d.ts +3 -0
- package/dist/kubernetes/index.js +88 -0
- package/dist/kubernetes/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/cluster.d.ts +2 -2
- package/dist/utils/cluster.js +3 -8
- package/dist/utils/cluster.js.map +1 -1
- package/dist/utils/gitlab.d.ts +1 -1
- package/dist/utils/gitlab.js +1 -1
- package/dist/utils/gitlab.js.map +1 -1
- package/dist/utils/projects/index.d.ts +0 -3
- package/dist/utils/projects/index.js +3 -54
- package/dist/utils/projects/index.js.map +1 -1
- package/package.json +25 -23
- package/scripts/bundle +4 -0
- package/src/apps/catenv/catenv.ts +1 -1
- package/src/apps/cli/commands/general/index.ts +1 -1
- package/src/apps/cli/commands/general/portForward.ts +1 -1
- package/src/apps/cli/commands/mongodb/index.ts +1 -1
- package/src/apps/cli/commands/mongodb/projectMongoDestroyMember.ts +3 -5
- package/src/apps/cli/commands/mongodb/projectMongoGetShell.ts +1 -1
- package/src/apps/cli/commands/mongodb/projectMongoPortForward.ts +1 -1
- package/src/apps/cli/commands/mongodb/utils/index.ts +2 -4
- package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +1 -1
- package/src/apps/cli/commands/project/commandConfigSecrets.ts +2 -1
- package/src/apps/cli/commands/project/commandCopyDB.ts +1 -1
- package/src/apps/cli/commands/project/commandDeletePods.ts +3 -5
- package/src/apps/cli/commands/project/commandDeleteProject.ts +1 -1
- package/src/apps/cli/commands/project/commandEnvVars.ts +1 -1
- package/src/apps/cli/commands/project/commandGetMyTotalWorktime.ts +1 -1
- package/src/apps/cli/commands/project/commandGetShell.ts +3 -5
- package/src/apps/cli/commands/project/commandGitlabCi.ts +2 -1
- package/src/apps/cli/commands/project/commandInitProject.old.ts +1 -1
- package/src/apps/cli/commands/project/commandListPods.ts +2 -2
- package/src/apps/cli/commands/project/commandMigrateHelm3.ts +1 -1
- package/src/apps/cli/commands/project/commandNamespace.ts +1 -1
- package/src/apps/cli/commands/project/commandOpenCostDashboard.ts +1 -1
- package/src/apps/cli/commands/project/commandOpenDashboard.ts +1 -1
- package/src/apps/cli/commands/project/commandOpenEnv.ts +1 -1
- package/src/apps/cli/commands/project/commandOpenGit.ts +3 -3
- package/src/apps/cli/commands/project/commandOpenGrafana.ts +1 -1
- package/src/apps/cli/commands/project/commandOpenGrafanaPod.ts +3 -5
- package/src/apps/cli/commands/project/commandOpenLogs.ts +1 -1
- package/src/apps/cli/commands/project/commandPauseProject.ts +1 -1
- package/src/apps/cli/commands/project/commandPortForward.ts +3 -5
- package/src/apps/cli/commands/project/commandSetup.ts +1 -1
- package/src/apps/cli/commands/project/commandTriggerCronjob.ts +3 -2
- package/src/apps/cli/commands/project/index.ts +1 -1
- package/src/apps/cli/commands/project/setup/index.ts +1 -1
- package/src/apps/cli/commands/project/setup/setupAccessTokens.ts +1 -1
- package/src/apps/cli/commands/project/setup/setupContext.ts +3 -2
- package/src/apps/cli/commands/project/setup/setupKubernetes.ts +30 -23
- package/src/apps/cli/commands/project/utils/ensureNamespace.ts +4 -2
- package/src/apps/cli/commands/project/utils/showProjectBanner.ts +1 -1
- package/src/apps/cli/commands/shared/index.ts +1 -1
- package/src/apps/cli/commands/theStuffThatReallyMatters/index.ts +1 -1
- package/src/apps/cli/config/writeConfig.ts +2 -2
- package/src/apps/cli/verify/index.ts +1 -1
- package/src/apps/cli/verify/migration/fromv2.ts +4 -7
- package/src/apps/cli/verify/migration/migrateSecrets.ts +4 -3
- package/src/apps/cli/verify/migration/oldGitlabCi.ts +1 -1
- package/src/catenv.ts +3 -4
- package/src/cli.ts +1 -2
- package/src/config/getProjectConfig.ts +6 -8
- package/src/config/parseChoice.ts +4 -0
- package/src/kubernetes/index.ts +27 -0
- package/src/utils/cluster.ts +3 -3
- package/src/utils/gitlab.ts +5 -4
- package/src/utils/projects/index.ts +3 -27
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import open from "open";
|
|
2
|
-
import { CommandInstance } from "vorpal";
|
|
2
|
+
import type { CommandInstance } from "vorpal";
|
|
3
3
|
import { doGitlabRequest, getProjectInfo } from "../../../../../utils/gitlab";
|
|
4
4
|
|
|
5
5
|
export const setupAccessTokens = async (instance: CommandInstance) => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Context
|
|
2
|
-
import {
|
|
1
|
+
import type { Context} from "@catladder/pipeline";
|
|
2
|
+
import { isOfDeployType } from "@catladder/pipeline";
|
|
3
|
+
import type { CommandInstance } from "vorpal";
|
|
3
4
|
import { setupKubernetes } from "./setupKubernetes";
|
|
4
5
|
|
|
5
6
|
export const setupContext = async (
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Context} from "@catladder/pipeline";
|
|
1
3
|
import {
|
|
2
|
-
Context,
|
|
3
4
|
getFullKubernetesClusterName,
|
|
4
5
|
isOfDeployType,
|
|
5
6
|
} from "@catladder/pipeline";
|
|
6
|
-
import { CommandInstance } from "vorpal";
|
|
7
|
-
import {
|
|
7
|
+
import type { CommandInstance } from "vorpal";
|
|
8
|
+
import { exec } from "child-process-promise";
|
|
8
9
|
import { connectToCluster } from "../../../../../utils/cluster";
|
|
9
10
|
import { upsertAllVariables } from "../../../../../utils/gitlab";
|
|
10
11
|
import ensureNamespace from "../utils/ensureNamespace";
|
|
@@ -33,25 +34,32 @@ export const setupKubernetes = async (
|
|
|
33
34
|
// we currently create one per component to better separate them
|
|
34
35
|
instance.log("ensuring service accounts...");
|
|
35
36
|
const serviceAccountName = `cl-${context.componentName}-deploy`;
|
|
36
|
-
const KUBE_URL =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
);
|
|
37
|
+
const KUBE_URL = await exec(
|
|
38
|
+
`TERM=dumb kubectl cluster-info | grep -E 'Kubernetes master|Kubernetes control plane' | awk '/http/ {print $NF}'`
|
|
39
|
+
).then((s: any) => s.stdout.trim());
|
|
40
40
|
|
|
41
41
|
// first upsert service acount in the ns
|
|
42
42
|
try {
|
|
43
|
-
await
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
await exec(
|
|
44
|
+
`kubectl delete serviceaccount --namespace ${namespace} ${serviceAccountName}`
|
|
45
|
+
);
|
|
46
|
+
await exec(
|
|
47
|
+
`kubectl delete rolebinding --namespace ${namespace} ${serviceAccountName}`
|
|
48
|
+
);
|
|
49
|
+
await exec(
|
|
50
|
+
`kubectl delete role --namespace ${namespace} ${serviceAccountName}`
|
|
51
|
+
);
|
|
46
52
|
} catch (e) {
|
|
47
53
|
// ignore
|
|
48
54
|
}
|
|
49
55
|
|
|
50
|
-
await
|
|
56
|
+
await exec(
|
|
57
|
+
`kubectl create serviceaccount --namespace ${namespace} ${serviceAccountName}`
|
|
58
|
+
);
|
|
51
59
|
|
|
52
60
|
// upsert role in the ns
|
|
53
61
|
|
|
54
|
-
await
|
|
62
|
+
await exec(`cat <<EOF | kubectl apply -f -
|
|
55
63
|
kind: Role
|
|
56
64
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
57
65
|
metadata:
|
|
@@ -76,20 +84,19 @@ roleRef:
|
|
|
76
84
|
name: ${serviceAccountName}
|
|
77
85
|
apiGroup: rbac.authorization.k8s.io
|
|
78
86
|
EOF
|
|
79
|
-
|
|
87
|
+
`);
|
|
80
88
|
|
|
81
89
|
// get token name
|
|
82
|
-
const tokenName =
|
|
83
|
-
|
|
90
|
+
const tokenName = await exec(
|
|
91
|
+
`kubectl get serviceaccount --namespace ${namespace} ${serviceAccountName} -o jsonpath='{.secrets[0].name}'`
|
|
92
|
+
).then((c: any) => c.stdout.trim());
|
|
84
93
|
|
|
85
|
-
const KUBE_CA_PEM =
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
(c) => c.stdout.trim()
|
|
92
|
-
);
|
|
94
|
+
const KUBE_CA_PEM = await exec(
|
|
95
|
+
`kubectl get secret ${tokenName} --namespace ${namespace} -o jsonpath="{['data']['ca\\.crt']}"`
|
|
96
|
+
).then((c: any) => c.stdout.trim());
|
|
97
|
+
const KUBE_TOKEN = await exec(
|
|
98
|
+
`kubectl get secret ${tokenName} --namespace ${namespace} -o jsonpath="{['data']['token']}" | base64 --decode`
|
|
99
|
+
).then((c: any) => c.stdout.trim());
|
|
93
100
|
|
|
94
101
|
const vars = {
|
|
95
102
|
KUBE_TOKEN,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { Context
|
|
2
|
-
import {
|
|
1
|
+
import type { Context} from "@catladder/pipeline";
|
|
2
|
+
import { getKubernetesNamespace } from "@catladder/pipeline";
|
|
3
|
+
import type { V1ObjectMeta } from "@kubernetes/client-node";
|
|
4
|
+
import { V1Namespace } from "@kubernetes/client-node";
|
|
3
5
|
import { getk8sApi } from "../../../../../k8sApi";
|
|
4
6
|
|
|
5
7
|
export default async function (context: Context) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { spawn } from "child-process-promise";
|
|
2
2
|
import fetch from "node-fetch";
|
|
3
|
-
import Vorpal from "vorpal";
|
|
3
|
+
import type Vorpal from "vorpal";
|
|
4
4
|
|
|
5
5
|
export default async (vorpal: Vorpal) => {
|
|
6
6
|
vorpal.command("dadjoke", "something for jonas.").action(async function () {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Config } from "@catladder/pipeline";
|
|
1
|
+
import type { Config } from "@catladder/pipeline";
|
|
2
2
|
import { spawn, exec } from "child-process-promise";
|
|
3
3
|
import { writeFile } from "fs-extra";
|
|
4
4
|
import { dump } from "js-yaml";
|
|
5
5
|
import { format } from "prettier";
|
|
6
|
-
import { CommandInstance } from "vorpal";
|
|
6
|
+
import type { CommandInstance } from "vorpal";
|
|
7
7
|
import { getGitRoot } from "../../../utils/projects";
|
|
8
8
|
|
|
9
9
|
export const writeConfig = async (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
BuildConfig,
|
|
3
3
|
ComponentConfig,
|
|
4
4
|
Config,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from "fs-extra";
|
|
15
15
|
import { isEmpty } from "lodash";
|
|
16
16
|
import { join } from "path";
|
|
17
|
-
import Vorpal from "vorpal";
|
|
17
|
+
import type Vorpal from "vorpal";
|
|
18
18
|
import {
|
|
19
19
|
getGitlabCi,
|
|
20
20
|
getGitlabCiFilePath,
|
|
@@ -24,11 +24,8 @@ import { syncBitwarden } from "../../../../utils/passwordstore";
|
|
|
24
24
|
import { getGitRoot } from "../../../../utils/projects";
|
|
25
25
|
import { writeConfig } from "../../config/writeConfig";
|
|
26
26
|
import { migrateSecrets } from "./migrateSecrets";
|
|
27
|
-
import {
|
|
28
|
-
|
|
29
|
-
isOldInclude,
|
|
30
|
-
OldGitlabCiFile,
|
|
31
|
-
} from "./oldGitlabCi";
|
|
27
|
+
import type { OldGitlabCiFile } from "./oldGitlabCi";
|
|
28
|
+
import { detectBuildConfig, isOldInclude } from "./oldGitlabCi";
|
|
32
29
|
export const LEGACY_ENVS = [
|
|
33
30
|
"dev-local",
|
|
34
31
|
"dev",
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Config
|
|
1
|
+
import type { Config } from "@catladder/pipeline";
|
|
2
|
+
import { getEnvironment } from "@catladder/pipeline";
|
|
2
3
|
import { load } from "js-yaml";
|
|
3
4
|
import { pick } from "lodash";
|
|
4
|
-
import { CommandInstance } from "vorpal";
|
|
5
|
+
import type { CommandInstance } from "vorpal";
|
|
5
6
|
import { upsertAllVariables } from "../../../../utils/gitlab";
|
|
6
7
|
import { readPass, trashItem } from "../../../../utils/passwordstore";
|
|
7
|
-
import { LEGACY_ENVS } from "./fromv2";
|
|
8
|
+
import type { LEGACY_ENVS } from "./fromv2";
|
|
8
9
|
|
|
9
10
|
const getPassPath = (newConfig: Config, env: string) => {
|
|
10
11
|
return `${newConfig.customerName}/${newConfig.appName}/${env}/secrets.yml`;
|
package/src/catenv.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import catenv from "./apps/catenv/catenv";
|
|
2
|
-
import { $, argv } from "zx";
|
|
3
|
-
import { parseChoice } from "./config/getProjectConfig";
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
import { parseChoice } from "./config/parseChoice";
|
|
4
|
+
|
|
5
|
+
const choice = process.argv[2] ? parseChoice(process.argv[2]) : null;
|
|
6
6
|
|
|
7
|
-
$.verbose = false;
|
|
8
7
|
catenv(choice).then(() => {
|
|
9
8
|
// we have to exit manually, because we have some file watches
|
|
10
9
|
process.exit();
|
package/src/cli.ts
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Config} from "@catladder/pipeline";
|
|
1
3
|
import {
|
|
2
4
|
readConfigSync,
|
|
3
5
|
getAllEnvs,
|
|
4
6
|
getEnvironment as _getEnvironment,
|
|
5
7
|
createContext,
|
|
6
|
-
getSecretVarName
|
|
7
|
-
Config,
|
|
8
|
+
getSecretVarName
|
|
8
9
|
} from "@catladder/pipeline";
|
|
9
10
|
|
|
10
|
-
import { CommandInstance } from "vorpal";
|
|
11
|
+
import type { CommandInstance } from "vorpal";
|
|
11
12
|
import { getAllVariables, getVariableValueByRawName } from "../utils/gitlab";
|
|
12
13
|
|
|
13
14
|
import { getGitRoot } from "../utils/projects";
|
|
14
15
|
import { readYaml } from "../utils/files";
|
|
15
16
|
import { watch } from "fs";
|
|
16
17
|
|
|
18
|
+
export { parseChoice } from "./parseChoice";
|
|
19
|
+
|
|
17
20
|
let currentConfig: Config = null;
|
|
18
21
|
|
|
19
22
|
// reload the config on change
|
|
@@ -59,11 +62,6 @@ export const getProjectComponents = async () => {
|
|
|
59
62
|
return Object.keys(config.components);
|
|
60
63
|
};
|
|
61
64
|
|
|
62
|
-
export const parseChoice = (envComponent: string) => {
|
|
63
|
-
const [env, componentName] = envComponent.split(":").map((x) => x || null);
|
|
64
|
-
return { env, componentName };
|
|
65
|
-
};
|
|
66
|
-
|
|
67
65
|
export const getPipelineContextByChoice = async (
|
|
68
66
|
env: string,
|
|
69
67
|
componentName: string
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { parseChoice } from "../config/parseChoice";
|
|
2
|
+
import { getk8sApi } from "../k8sApi";
|
|
3
|
+
import { getProjectNamespace } from "../utils/projects";
|
|
4
|
+
|
|
5
|
+
export const getProjectPods = async (envComponent: string) => {
|
|
6
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
7
|
+
const k8sApi = getk8sApi();
|
|
8
|
+
const res = await k8sApi.listNamespacedPod(namespace);
|
|
9
|
+
|
|
10
|
+
const { componentName } = parseChoice(envComponent);
|
|
11
|
+
return res.body.items.filter((item) =>
|
|
12
|
+
componentName ? item.metadata?.name?.includes(componentName + "-") : true
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const getProjectPvcs = async (envComponent: string) => {
|
|
17
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
18
|
+
const k8sApi = getk8sApi();
|
|
19
|
+
const res = await k8sApi.listNamespacedPersistentVolumeClaim(namespace);
|
|
20
|
+
|
|
21
|
+
return res.body.items;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const getProjectPodNames = async (envComponent: string) => {
|
|
25
|
+
const pods = await getProjectPods(envComponent);
|
|
26
|
+
return pods.map((n) => n.metadata.name);
|
|
27
|
+
};
|
package/src/utils/cluster.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { exec } from "child-process-promise";
|
|
2
2
|
|
|
3
3
|
export const getCurrentContext = async () =>
|
|
4
|
-
(await
|
|
4
|
+
(await exec(`kubectl config current-context`)).stdout.trim();
|
|
5
5
|
|
|
6
6
|
export const getCurrentConnectedClusterName = async () => {
|
|
7
7
|
return await getCurrentContext();
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
export const connectToCluster = async (fullname: string) => {
|
|
11
|
-
await
|
|
11
|
+
await exec(`kubectl config use-context ${fullname}`);
|
|
12
12
|
};
|
package/src/utils/gitlab.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { has, isObject, times } from "lodash";
|
|
|
4
4
|
import memoizee from "memoizee";
|
|
5
5
|
import fetch from "node-fetch";
|
|
6
6
|
import open from "open";
|
|
7
|
-
import { CommandInstance } from "vorpal";
|
|
7
|
+
import type { CommandInstance } from "vorpal";
|
|
8
8
|
import { getPreference, hasPreference, setPreference } from "./preferences";
|
|
9
9
|
|
|
10
10
|
const TOKEN_KEY = "gitlab-personal-access-token";
|
|
@@ -90,9 +90,10 @@ export const getProjectInfo = async (
|
|
|
90
90
|
const gitRemoteOriginUrl = (
|
|
91
91
|
await exec("git config --get remote.origin.url")
|
|
92
92
|
).stdout.trim();
|
|
93
|
-
const projectPath =
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
const projectPath =
|
|
94
|
+
/(https:\/\/|git@)git\.panter\.ch[:/]([^.]*)(\.git)?/g.exec(
|
|
95
|
+
gitRemoteOriginUrl
|
|
96
|
+
);
|
|
96
97
|
const project = await doGitlabRequest(
|
|
97
98
|
vorpal,
|
|
98
99
|
`projects/${encodeURIComponent(projectPath[2])}`
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { $ } from "zx";
|
|
2
1
|
import { join } from "path";
|
|
3
2
|
import { getProjectConfig, parseChoice } from "../../config/getProjectConfig";
|
|
4
|
-
|
|
3
|
+
|
|
5
4
|
import { readFileOrError } from "../files";
|
|
5
|
+
import { exec } from "child-process-promise";
|
|
6
6
|
|
|
7
7
|
export const getGitRoot = async (): Promise<string> => {
|
|
8
|
-
return (await
|
|
8
|
+
return (await exec(`git rev-parse --show-toplevel`)).stdout.trim();
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export const getRootGitlabCiFile = async () => {
|
|
@@ -29,27 +29,3 @@ export const getProjectNamespace = async (envComponent: string) => {
|
|
|
29
29
|
const config = await getProjectConfig();
|
|
30
30
|
return `${config.customerName}-${config.appName}-${env}`;
|
|
31
31
|
};
|
|
32
|
-
|
|
33
|
-
export const getProjectPods = async (envComponent: string) => {
|
|
34
|
-
const namespace = await getProjectNamespace(envComponent);
|
|
35
|
-
const k8sApi = getk8sApi();
|
|
36
|
-
const res = await k8sApi.listNamespacedPod(namespace);
|
|
37
|
-
|
|
38
|
-
const { componentName } = parseChoice(envComponent);
|
|
39
|
-
return res.body.items.filter((item) =>
|
|
40
|
-
componentName ? item.metadata?.name?.includes(componentName + "-") : true
|
|
41
|
-
);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const getProjectPvcs = async (envComponent: string) => {
|
|
45
|
-
const namespace = await getProjectNamespace(envComponent);
|
|
46
|
-
const k8sApi = getk8sApi();
|
|
47
|
-
const res = await k8sApi.listNamespacedPersistentVolumeClaim(namespace);
|
|
48
|
-
|
|
49
|
-
return res.body.items;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const getProjectPodNames = async (envComponent: string) => {
|
|
53
|
-
const pods = await getProjectPods(envComponent);
|
|
54
|
-
return pods.map((n) => n.metadata.name);
|
|
55
|
-
};
|