@catladder/cli 1.145.0 → 1.146.1
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/bundles/catenv/index.js +1 -1
- package/dist/bundles/cli/index.js +1 -1
- package/dist/cli/src/apps/catci/commands/security/evaluateSecurityAudit.js.map +1 -1
- package/dist/cli/src/apps/catenv/catenv.js +8 -12
- package/dist/cli/src/apps/catenv/catenv.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/general/namespaceAutoCompletion.js +1 -1
- package/dist/cli/src/apps/cli/commands/mongodb/projectMongoGetShell.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/mongodb/projectMongoPortForward.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/mongodb/utils/index.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/setupAccessTokens.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/setupCloudRun.js +1 -2
- package/dist/cli/src/apps/cli/commands/project/setup/setupCloudRun.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/setupKubernetes.js +1 -2
- package/dist/cli/src/apps/cli/commands/project/setup/setupKubernetes.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/setupTopic.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/utils/ensureNamespace.js +1 -2
- package/dist/cli/src/apps/cli/commands/project/utils/ensureNamespace.js.map +1 -1
- package/dist/cli/src/gcloud/cloudSql/startProxy.js +1 -2
- package/dist/cli/src/gcloud/cloudSql/startProxy.js.map +1 -1
- package/dist/cli/src/utils/gitlab.d.ts +1 -1
- package/dist/cli/src/utils/gitlab.js +38 -26
- package/dist/cli/src/utils/gitlab.js.map +1 -1
- package/dist/cli/src/utils/promise.js.map +1 -1
- package/dist/pipeline/src/context/getEnvironmentVariables.js +1 -2
- package/dist/pipeline/src/context/getEnvironmentVariables.js.map +1 -1
- package/dist/pipeline/src/context/resolveReferences.js.map +1 -1
- package/dist/pipeline/src/deploy/base/deploy.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js +1 -2
- package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/index.js.map +1 -1
- package/dist/pipeline/src/deploy/kubernetes/kubeValues.js +1 -2
- package/dist/pipeline/src/deploy/kubernetes/kubeValues.js.map +1 -1
- package/dist/pipeline/src/pipeline/createMainPipeline.js.map +1 -1
- package/dist/pipeline/src/pipeline/generatePipelineFiles.js +5 -5
- package/dist/pipeline/src/pipeline/generatePipelineFiles.js.map +1 -1
- package/dist/pipeline/src/pipeline/gitlab/createGitlabJobs.js.map +1 -1
- package/dist/pipeline/src/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.js.map +1 -1
- package/dist/pipeline/src/types/config.d.ts +1 -1
- package/dist/pipeline/src/types/jobs.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/apps/catci/commands/security/auditDocument.ts +4 -4
- package/src/apps/catci/commands/security/commands.ts +14 -14
- package/src/apps/catci/commands/security/createSecurityAuditMergeRequest.ts +9 -9
- package/src/apps/catci/commands/security/evaluateSecurityAudit.ts +2 -2
- package/src/apps/catci/commands/security/topics.json +8 -16
- package/src/apps/catenv/catenv.ts +8 -7
- package/src/apps/catenv/printVariables.ts +3 -3
- package/src/apps/catenv/utils.ts +4 -4
- package/src/apps/catenv/writeDotEnvFiles.ts +1 -1
- package/src/apps/catenv/writeEnvDTs.ts +3 -3
- package/src/apps/cli/cli.ts +1 -1
- package/src/apps/cli/commands/cloudSQL/commandRestoreDb.ts +1 -1
- package/src/apps/cli/commands/general/index.ts +2 -2
- package/src/apps/cli/commands/general/namespaceAutoCompletion.ts +1 -1
- package/src/apps/cli/commands/mongodb/projectMongoDestroyMember.ts +11 -11
- package/src/apps/cli/commands/mongodb/projectMongoGetShell.ts +3 -4
- package/src/apps/cli/commands/mongodb/projectMongoPortForward.ts +3 -4
- package/src/apps/cli/commands/mongodb/utils/index.ts +8 -10
- package/src/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.ts +6 -6
- package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +7 -7
- package/src/apps/cli/commands/project/commandConfigSecrets.ts +22 -22
- package/src/apps/cli/commands/project/commandDeletePods.ts +1 -1
- 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 +1 -1
- package/src/apps/cli/commands/project/commandGitlabCi.ts +4 -4
- package/src/apps/cli/commands/project/commandListPods.ts +2 -2
- package/src/apps/cli/commands/project/commandMigrateHelm3.ts +6 -6
- package/src/apps/cli/commands/project/commandNamespace.ts +1 -1
- package/src/apps/cli/commands/project/commandOpenCostDashboard.ts +2 -2
- package/src/apps/cli/commands/project/commandOpenDashboard.ts +1 -1
- package/src/apps/cli/commands/project/commandOpenGit.ts +1 -1
- package/src/apps/cli/commands/project/commandOpenGrafana.ts +2 -2
- package/src/apps/cli/commands/project/commandOpenGrafanaPod.ts +2 -2
- 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/commandSecretsClearBackups.ts +1 -1
- package/src/apps/cli/commands/project/commandSecurityEvaluate.ts +2 -2
- package/src/apps/cli/commands/project/commandSetup.ts +1 -1
- package/src/apps/cli/commands/project/setup/index.ts +1 -1
- package/src/apps/cli/commands/project/setup/setupAccessTokens.ts +5 -6
- package/src/apps/cli/commands/project/setup/setupCloudRun.ts +5 -5
- package/src/apps/cli/commands/project/setup/setupContext.ts +4 -4
- package/src/apps/cli/commands/project/setup/setupKubernetes.ts +14 -14
- package/src/apps/cli/commands/project/setup/setupTopic.ts +4 -9
- package/src/apps/cli/commands/project/utils/autocompletions.ts +1 -1
- package/src/apps/cli/commands/project/utils/ensureCluster.ts +2 -2
- package/src/apps/cli/commands/project/utils/ensureNamespace.ts +5 -5
- package/src/apps/cli/utils/getGoogleAuthUserNumber.ts +1 -1
- package/src/config/getProjectConfig.ts +11 -11
- package/src/gcloud/artifactsRegistry.ts +1 -1
- package/src/gcloud/cloudRun/getCloudRunDomainSuffix.ts +2 -2
- package/src/gcloud/cloudRun/openCloudRunDashboards.ts +2 -2
- package/src/gcloud/cloudSql/copyDb.ts +1 -1
- package/src/gcloud/cloudSql/startProxy.ts +7 -7
- package/src/gcloud/enableServices.ts +2 -2
- package/src/gcloud/openDashboard.ts +1 -1
- package/src/gcloud/serviceAccounts.ts +8 -8
- package/src/kubernetes/index.ts +1 -1
- package/src/kubernetes/openKubernetesDashboards.ts +2 -2
- package/src/kubernetes/portForward.ts +2 -2
- package/src/types/child-process-promise.d.ts +3 -3
- package/src/utils/editAsFile.ts +2 -2
- package/src/utils/gitlab.ts +43 -27
- package/src/utils/log.ts +1 -1
- package/src/utils/portForwards.ts +1 -1
- package/src/utils/promise.ts +7 -5
|
@@ -15,7 +15,7 @@ import ensureNamespace from "../utils/ensureNamespace";
|
|
|
15
15
|
|
|
16
16
|
export const setupKubernetes = async (
|
|
17
17
|
instance: CommandInstance,
|
|
18
|
-
context: Context
|
|
18
|
+
context: Context,
|
|
19
19
|
) => {
|
|
20
20
|
const deployConfig = context.componentConfig.deploy;
|
|
21
21
|
if (!isOfDeployType(deployConfig, "kubernetes")) {
|
|
@@ -25,16 +25,16 @@ export const setupKubernetes = async (
|
|
|
25
25
|
const { id: projectId } = await getProjectInfo(instance);
|
|
26
26
|
const deploy_tokens = await doGitlabRequest(
|
|
27
27
|
instance,
|
|
28
|
-
`projects/${projectId}/deploy_tokens
|
|
28
|
+
`projects/${projectId}/deploy_tokens`,
|
|
29
29
|
);
|
|
30
30
|
|
|
31
31
|
if (
|
|
32
32
|
!deploy_tokens.find(
|
|
33
|
-
(v: { name: string }) => v.name === "gitlab-deploy-token"
|
|
33
|
+
(v: { name: string }) => v.name === "gitlab-deploy-token",
|
|
34
34
|
)
|
|
35
35
|
) {
|
|
36
36
|
instance.log(
|
|
37
|
-
"I will setup the 'GitLab Deploy Token', so Kubernetes can pull images from this project."
|
|
37
|
+
"I will setup the 'GitLab Deploy Token', so Kubernetes can pull images from this project.",
|
|
38
38
|
);
|
|
39
39
|
|
|
40
40
|
await doGitlabRequest(
|
|
@@ -45,7 +45,7 @@ export const setupKubernetes = async (
|
|
|
45
45
|
name: "gitlab-deploy-token",
|
|
46
46
|
scopes: ["read_registry"],
|
|
47
47
|
},
|
|
48
|
-
"POST"
|
|
48
|
+
"POST",
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -65,26 +65,26 @@ export const setupKubernetes = async (
|
|
|
65
65
|
instance.log("ensuring service accounts...");
|
|
66
66
|
const serviceAccountName = `cl-${context.componentName}-deploy`;
|
|
67
67
|
const KUBE_URL = await exec(
|
|
68
|
-
`TERM=dumb kubectl cluster-info | grep -E 'Kubernetes master|Kubernetes control plane' | awk '/http/ {print $NF}'
|
|
68
|
+
`TERM=dumb kubectl cluster-info | grep -E 'Kubernetes master|Kubernetes control plane' | awk '/http/ {print $NF}'`,
|
|
69
69
|
).then((s) => s.stdout.trim());
|
|
70
70
|
|
|
71
71
|
// first upsert service acount in the ns
|
|
72
72
|
try {
|
|
73
73
|
await exec(
|
|
74
|
-
`kubectl delete serviceaccount --namespace ${namespace} ${serviceAccountName}
|
|
74
|
+
`kubectl delete serviceaccount --namespace ${namespace} ${serviceAccountName}`,
|
|
75
75
|
);
|
|
76
76
|
await exec(
|
|
77
|
-
`kubectl delete rolebinding --namespace ${namespace} ${serviceAccountName}
|
|
77
|
+
`kubectl delete rolebinding --namespace ${namespace} ${serviceAccountName}`,
|
|
78
78
|
);
|
|
79
79
|
await exec(
|
|
80
|
-
`kubectl delete role --namespace ${namespace} ${serviceAccountName}
|
|
80
|
+
`kubectl delete role --namespace ${namespace} ${serviceAccountName}`,
|
|
81
81
|
);
|
|
82
82
|
} catch (e) {
|
|
83
83
|
// ignore
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
await exec(
|
|
87
|
-
`kubectl create serviceaccount --namespace ${namespace} ${serviceAccountName}
|
|
87
|
+
`kubectl create serviceaccount --namespace ${namespace} ${serviceAccountName}`,
|
|
88
88
|
);
|
|
89
89
|
|
|
90
90
|
// upsert role in the ns
|
|
@@ -132,10 +132,10 @@ EOF
|
|
|
132
132
|
`);
|
|
133
133
|
|
|
134
134
|
const KUBE_CA_PEM = await exec(
|
|
135
|
-
`kubectl get secret ${secretName} --namespace ${namespace} -o jsonpath="{['data']['ca\\.crt']}"
|
|
135
|
+
`kubectl get secret ${secretName} --namespace ${namespace} -o jsonpath="{['data']['ca\\.crt']}"`,
|
|
136
136
|
).then((c) => c.stdout.trim());
|
|
137
137
|
const KUBE_TOKEN = await exec(
|
|
138
|
-
`kubectl get secret ${secretName} --namespace ${namespace} -o jsonpath="{['data']['token']}" | base64 --decode
|
|
138
|
+
`kubectl get secret ${secretName} --namespace ${namespace} -o jsonpath="{['data']['token']}" | base64 --decode`,
|
|
139
139
|
).then((c) => c.stdout.trim());
|
|
140
140
|
|
|
141
141
|
const vars = {
|
|
@@ -151,7 +151,7 @@ EOF
|
|
|
151
151
|
missing.map((m) => m[0]).join(", ") +
|
|
152
152
|
". Check whether your local kubectl is still working for '" +
|
|
153
153
|
fullName +
|
|
154
|
-
"'"
|
|
154
|
+
"'",
|
|
155
155
|
);
|
|
156
156
|
}
|
|
157
157
|
|
|
@@ -165,7 +165,7 @@ EOF
|
|
|
165
165
|
vars,
|
|
166
166
|
context.environment.shortName,
|
|
167
167
|
context.componentName,
|
|
168
|
-
false // no backup
|
|
168
|
+
false, // no backup
|
|
169
169
|
);
|
|
170
170
|
instance.log("done!");
|
|
171
171
|
};
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import type { CommandInstance } from "vorpal";
|
|
2
2
|
import { doGitlabRequest, getProjectInfo } from "../../../../../utils/gitlab";
|
|
3
3
|
|
|
4
|
-
const catladderTopic = "catladder"
|
|
4
|
+
const catladderTopic = "catladder";
|
|
5
5
|
|
|
6
6
|
export const setupTopic = async (instance: CommandInstance) => {
|
|
7
|
-
const { id: projectId } = await getProjectInfo(
|
|
8
|
-
instance
|
|
9
|
-
);
|
|
7
|
+
const { id: projectId } = await getProjectInfo(instance);
|
|
10
8
|
|
|
11
|
-
const { topics } = await doGitlabRequest(
|
|
12
|
-
instance,
|
|
13
|
-
`projects/${projectId}`
|
|
14
|
-
);
|
|
9
|
+
const { topics } = await doGitlabRequest(instance, `projects/${projectId}`);
|
|
15
10
|
|
|
16
11
|
await doGitlabRequest(
|
|
17
12
|
instance,
|
|
18
13
|
`projects/${projectId}`,
|
|
19
14
|
{ topics: [catladderTopic, ...topics] },
|
|
20
|
-
"PUT"
|
|
15
|
+
"PUT",
|
|
21
16
|
);
|
|
22
17
|
};
|
|
@@ -17,13 +17,13 @@ export default async function (envComponent: string) {
|
|
|
17
17
|
throw new Error("can't ensure cluster for non-kubernetes deployments");
|
|
18
18
|
}
|
|
19
19
|
const cluster = getFullKubernetesClusterName(
|
|
20
|
-
context.componentConfig.deploy.cluster
|
|
20
|
+
context.componentConfig.deploy.cluster,
|
|
21
21
|
);
|
|
22
22
|
const connectedClusterName = await getCurrentConnectedClusterName();
|
|
23
23
|
|
|
24
24
|
if (cluster !== connectedClusterName) {
|
|
25
25
|
this.log(
|
|
26
|
-
`you are currently connected to cluster '${connectedClusterName}'
|
|
26
|
+
`you are currently connected to cluster '${connectedClusterName}'`,
|
|
27
27
|
);
|
|
28
28
|
this.log(`but the project requires cluster '${cluster}'`);
|
|
29
29
|
const { shouldContinue } = await this.prompt({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context} from "@catladder/pipeline";
|
|
1
|
+
import type { Context } from "@catladder/pipeline";
|
|
2
2
|
import { getKubernetesNamespace } from "@catladder/pipeline";
|
|
3
3
|
import type { V1ObjectMeta } from "@kubernetes/client-node";
|
|
4
4
|
import { V1Namespace } from "@kubernetes/client-node";
|
|
@@ -7,7 +7,7 @@ import { getk8sApi } from "../../../../../k8sApi";
|
|
|
7
7
|
export default async function (context: Context) {
|
|
8
8
|
const namespace = getKubernetesNamespace(
|
|
9
9
|
context.fullConfig,
|
|
10
|
-
context.environment.shortName
|
|
10
|
+
context.environment.shortName,
|
|
11
11
|
);
|
|
12
12
|
const namespaceBody = new V1Namespace();
|
|
13
13
|
const metadata: V1ObjectMeta = {
|
|
@@ -25,8 +25,8 @@ export default async function (context: Context) {
|
|
|
25
25
|
([componentName, config]) => [
|
|
26
26
|
"buildType_" + componentName,
|
|
27
27
|
config.build.type,
|
|
28
|
-
]
|
|
29
|
-
)
|
|
28
|
+
],
|
|
29
|
+
),
|
|
30
30
|
),
|
|
31
31
|
...(context.fullConfig.meta?.labels ?? {}),
|
|
32
32
|
},
|
|
@@ -44,7 +44,7 @@ export default async function (context: Context) {
|
|
|
44
44
|
undefined,
|
|
45
45
|
undefined,
|
|
46
46
|
undefined,
|
|
47
|
-
{ headers: { "content-type": "application/merge-patch+json" } } // see https://github.com/kubernetes-client/javascript/issues/443
|
|
47
|
+
{ headers: { "content-type": "application/merge-patch+json" } }, // see https://github.com/kubernetes-client/javascript/issues/443
|
|
48
48
|
); // update meta data
|
|
49
49
|
} catch (e) {
|
|
50
50
|
if (e.response?.body?.reason === "NotFound") {
|
|
@@ -8,7 +8,7 @@ const KEY = "googleAuthUserNumber";
|
|
|
8
8
|
export const getGoogleAuthUserNumber = async function () {
|
|
9
9
|
if (!(await hasPreference(KEY))) {
|
|
10
10
|
this.log(
|
|
11
|
-
"Please type in your google auth user number (0 if you have only one google account or maybe 1 if you have multiple)"
|
|
11
|
+
"Please type in your google auth user number (0 if you have only one google account or maybe 1 if you have multiple)",
|
|
12
12
|
);
|
|
13
13
|
|
|
14
14
|
const { authUserNumber } = await this.prompt({
|
|
@@ -50,7 +50,7 @@ export const getProjectComponents = async () => {
|
|
|
50
50
|
|
|
51
51
|
export const getPipelineContextByChoice = async (
|
|
52
52
|
env: string,
|
|
53
|
-
componentName: string
|
|
53
|
+
componentName: string,
|
|
54
54
|
) => {
|
|
55
55
|
const config = await getProjectConfig();
|
|
56
56
|
return await createContext({
|
|
@@ -67,7 +67,7 @@ export const getAllComponentsWithAllEnvsFlat = async (): Promise<
|
|
|
67
67
|
return [];
|
|
68
68
|
}
|
|
69
69
|
return Object.keys(config.components).flatMap((componentName) =>
|
|
70
|
-
getAllEnvs(config, componentName).map((env) => ({ env, componentName }))
|
|
70
|
+
getAllEnvs(config, componentName).map((env) => ({ env, componentName })),
|
|
71
71
|
);
|
|
72
72
|
};
|
|
73
73
|
|
|
@@ -83,7 +83,7 @@ export const getAllComponentsWithAllEnvsHierarchical = async (): Promise<{
|
|
|
83
83
|
Object.keys(config.components).map((componentName) => [
|
|
84
84
|
componentName,
|
|
85
85
|
getAllEnvs(config, componentName),
|
|
86
|
-
])
|
|
86
|
+
]),
|
|
87
87
|
);
|
|
88
88
|
};
|
|
89
89
|
|
|
@@ -92,8 +92,8 @@ export const getAllPipelineContexts = async () => {
|
|
|
92
92
|
(await getAllComponentsWithAllEnvsFlat())
|
|
93
93
|
.filter((c) => c.env !== "local")
|
|
94
94
|
.map(({ env, componentName }) =>
|
|
95
|
-
getPipelineContextByChoice(env, componentName)
|
|
96
|
-
)
|
|
95
|
+
getPipelineContextByChoice(env, componentName),
|
|
96
|
+
),
|
|
97
97
|
);
|
|
98
98
|
};
|
|
99
99
|
|
|
@@ -107,7 +107,7 @@ export const getGitlabVar = async (
|
|
|
107
107
|
vorpal: CommandInstance,
|
|
108
108
|
env: string,
|
|
109
109
|
componentName: string,
|
|
110
|
-
variableName: string
|
|
110
|
+
variableName: string,
|
|
111
111
|
) => {
|
|
112
112
|
const rawVariableName = getSecretVarName(env, componentName, variableName);
|
|
113
113
|
return await getVariableValueByRawName(vorpal, rawVariableName);
|
|
@@ -115,7 +115,7 @@ export const getGitlabVar = async (
|
|
|
115
115
|
|
|
116
116
|
const resolveSecrets = async (
|
|
117
117
|
vorpal: CommandInstance | null,
|
|
118
|
-
varSets: EnvironmentEnvVars[]
|
|
118
|
+
varSets: EnvironmentEnvVars[],
|
|
119
119
|
): Promise<Record<string, string>> => {
|
|
120
120
|
const allVariablesInGitlab = await getAllVariables(vorpal);
|
|
121
121
|
|
|
@@ -136,15 +136,15 @@ const resolveSecrets = async (
|
|
|
136
136
|
}
|
|
137
137
|
return [key, value];
|
|
138
138
|
})
|
|
139
|
-
.filter(Boolean)
|
|
140
|
-
)
|
|
139
|
+
.filter(Boolean),
|
|
140
|
+
),
|
|
141
141
|
);
|
|
142
142
|
};
|
|
143
143
|
|
|
144
144
|
export const getEnvVarsResolved = async (
|
|
145
145
|
vorpal: CommandInstance | null,
|
|
146
146
|
env: string,
|
|
147
|
-
componentName: string | null
|
|
147
|
+
componentName: string | null,
|
|
148
148
|
) => {
|
|
149
149
|
if (!componentName) {
|
|
150
150
|
return {};
|
|
@@ -173,7 +173,7 @@ export const getEnvVarsResolved = async (
|
|
|
173
173
|
export const getJobOnlyEnvVarsResolved = async (
|
|
174
174
|
vorpal: CommandInstance,
|
|
175
175
|
env: string,
|
|
176
|
-
componentName: string
|
|
176
|
+
componentName: string,
|
|
177
177
|
) => {
|
|
178
178
|
try {
|
|
179
179
|
const envionment = await getEnvironment(env, componentName);
|
|
@@ -7,7 +7,7 @@ export const upsertGcloudArtifactsRegistry = async (config: {
|
|
|
7
7
|
}) => {
|
|
8
8
|
try {
|
|
9
9
|
await exec(
|
|
10
|
-
`gcloud artifacts repositories create catladder-deploy --project="${config.projectId}" --repository-format=docker --location=${config.region}
|
|
10
|
+
`gcloud artifacts repositories create catladder-deploy --project="${config.projectId}" --repository-format=docker --location=${config.region}`,
|
|
11
11
|
);
|
|
12
12
|
} catch (e) {
|
|
13
13
|
// probably already exists
|
|
@@ -20,7 +20,7 @@ export const getCloudRunDomainSuffix = async (config: DeployConfigCloudRun) => {
|
|
|
20
20
|
const dummyServiceName = "cl-dummy-service-delete-me";
|
|
21
21
|
|
|
22
22
|
const existingServices = await exec(
|
|
23
|
-
`gcloud run services list --format=json --project="${config.projectId}" --region=${config.region} --limit=1
|
|
23
|
+
`gcloud run services list --format=json --project="${config.projectId}" --region=${config.region} --limit=1`,
|
|
24
24
|
).then((r) => JSON.parse(r.stdout));
|
|
25
25
|
|
|
26
26
|
if (existingServices.length > 0) {
|
|
@@ -28,7 +28,7 @@ export const getCloudRunDomainSuffix = async (config: DeployConfigCloudRun) => {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const result = await exec(
|
|
31
|
-
`gcloud run deploy ${dummyServiceName} --region=${config.region} --allow-unauthenticated --project ${config.projectId} --image=us-docker.pkg.dev/cloudrun/container/hello --format=json
|
|
31
|
+
`gcloud run deploy ${dummyServiceName} --region=${config.region} --allow-unauthenticated --project ${config.projectId} --image=us-docker.pkg.dev/cloudrun/container/hello --format=json`,
|
|
32
32
|
).then((r) => JSON.parse(r.stdout));
|
|
33
33
|
|
|
34
34
|
return await getSuffixFromService(result);
|
|
@@ -5,7 +5,7 @@ import { openGoogleCloudDashboard } from "../openDashboard";
|
|
|
5
5
|
|
|
6
6
|
export const openGoogleCloudRunDashboard = async (
|
|
7
7
|
instance: CommandInstance,
|
|
8
|
-
context: Context
|
|
8
|
+
context: Context,
|
|
9
9
|
) => {
|
|
10
10
|
if (!isOfDeployType(context.componentConfig.deploy, "google-cloudrun")) {
|
|
11
11
|
throw new Error("deploy type is not google-cloudrun ");
|
|
@@ -17,6 +17,6 @@ export const openGoogleCloudRunDashboard = async (
|
|
|
17
17
|
`run/detail/${region}/${fullName}/metrics`,
|
|
18
18
|
{
|
|
19
19
|
project: projectId,
|
|
20
|
-
}
|
|
20
|
+
},
|
|
21
21
|
);
|
|
22
22
|
};
|
|
@@ -41,7 +41,7 @@ const createCopyDbScript = ({
|
|
|
41
41
|
pg_dump --dbname=postgres://${sourceUsername}:${sourcePassword}@localhost:${sourcePort}/${sourceDbName} --no-owner --no-privileges > $dumptmp
|
|
42
42
|
echo "dump done"
|
|
43
43
|
${targetPSQL(
|
|
44
|
-
`-c 'drop database "${targetDbName}" WITH (FORCE)' 1> /dev/null || true
|
|
44
|
+
`-c 'drop database "${targetDbName}" WITH (FORCE)' 1> /dev/null || true`,
|
|
45
45
|
)}
|
|
46
46
|
${targetPSQL(`-c 'create database "${targetDbName}"' 1> /dev/null`)}
|
|
47
47
|
echo "Restoring dump..."
|
|
@@ -19,10 +19,10 @@ const getProxyCommandSpawnArgs = async ({
|
|
|
19
19
|
const commandString = (await commandExists("cloud-sql-proxy"))
|
|
20
20
|
? `cloud-sql-proxy --port ${localPort} ${instanceName}`
|
|
21
21
|
: (await commandExists(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
"cloud_sql_proxy", // v1
|
|
23
|
+
))
|
|
24
|
+
? `cloud_sql_proxy -instances ${instanceName}=tcp:${localPort}`
|
|
25
|
+
: null;
|
|
26
26
|
if (!commandString) {
|
|
27
27
|
throw new Error(ERROR_NOT_INSTALLED);
|
|
28
28
|
}
|
|
@@ -32,7 +32,7 @@ const getProxyCommandSpawnArgs = async ({
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
export const startCloudSqlProxyInCurrentShell = async (
|
|
35
|
-
opts: CloudSqlProxyOptions
|
|
35
|
+
opts: CloudSqlProxyOptions,
|
|
36
36
|
) => {
|
|
37
37
|
const { cmd, args } = await getProxyCommandSpawnArgs(opts);
|
|
38
38
|
|
|
@@ -43,7 +43,7 @@ export const startCloudSqlProxyInCurrentShell = async (
|
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
export const startCloudSqlProxyInBackground = async (
|
|
46
|
-
opts: CloudSqlProxyOptions
|
|
46
|
+
opts: CloudSqlProxyOptions,
|
|
47
47
|
): Promise<CloudSqlBackgroundProxy> => {
|
|
48
48
|
const { cmd, args } = await getProxyCommandSpawnArgs(opts);
|
|
49
49
|
|
|
@@ -57,7 +57,7 @@ export const startCloudSqlProxyInBackground = async (
|
|
|
57
57
|
echo -n "."
|
|
58
58
|
done 2>/dev/null`,
|
|
59
59
|
[],
|
|
60
|
-
{ shell: "bash" }
|
|
60
|
+
{ shell: "bash" },
|
|
61
61
|
);
|
|
62
62
|
const stop = () => {
|
|
63
63
|
proxyPromise.catch(() => {
|
|
@@ -4,11 +4,11 @@ export const enableGCloudServices = async (
|
|
|
4
4
|
services: string[],
|
|
5
5
|
config: {
|
|
6
6
|
projectId: string;
|
|
7
|
-
}
|
|
7
|
+
},
|
|
8
8
|
) => {
|
|
9
9
|
for (const service of services) {
|
|
10
10
|
await exec(
|
|
11
|
-
`gcloud services enable ${service} --project=${config.projectId}
|
|
11
|
+
`gcloud services enable ${service} --project=${config.projectId}`,
|
|
12
12
|
);
|
|
13
13
|
}
|
|
14
14
|
};
|
|
@@ -4,7 +4,7 @@ import open from "open";
|
|
|
4
4
|
export const openGoogleCloudDashboard = async (
|
|
5
5
|
instance: CommandInstance,
|
|
6
6
|
path: string,
|
|
7
|
-
params: Record<string, string
|
|
7
|
+
params: Record<string, string>,
|
|
8
8
|
) => {
|
|
9
9
|
const url = new URL("https://console.cloud.google.com/");
|
|
10
10
|
url.pathname = path;
|
|
@@ -23,7 +23,7 @@ type ServiceAccount = {
|
|
|
23
23
|
};
|
|
24
24
|
const upsertGcloudServiceAccount = async (
|
|
25
25
|
context: Context,
|
|
26
|
-
account: ServiceAccount
|
|
26
|
+
account: ServiceAccount,
|
|
27
27
|
): Promise<string> => {
|
|
28
28
|
const { projectId, name, displayName, roles, description } = account;
|
|
29
29
|
|
|
@@ -45,13 +45,13 @@ const upsertGcloudServiceAccount = async (
|
|
|
45
45
|
|
|
46
46
|
if (!existing) {
|
|
47
47
|
await exec(
|
|
48
|
-
`gcloud iam service-accounts create ${fullName} --display-name="${fullDisplayName}" --project="${projectId}" --description="${description}"
|
|
48
|
+
`gcloud iam service-accounts create ${fullName} --display-name="${fullDisplayName}" --project="${projectId}" --description="${description}"`,
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
51
|
const memberName = `serviceAccount:${fullIdentifier}`;
|
|
52
52
|
for (const role of roles) {
|
|
53
53
|
await exec(
|
|
54
|
-
`gcloud projects add-iam-policy-binding ${projectId} --member=${memberName} --role=${role}
|
|
54
|
+
`gcloud projects add-iam-policy-binding ${projectId} --member=${memberName} --role=${role} `,
|
|
55
55
|
);
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -59,18 +59,18 @@ const upsertGcloudServiceAccount = async (
|
|
|
59
59
|
|
|
60
60
|
// delete first all keys
|
|
61
61
|
const keys = await exec(
|
|
62
|
-
`gcloud iam service-accounts keys list --iam-account=${fullIdentifier} --managed-by=user --format=json
|
|
62
|
+
`gcloud iam service-accounts keys list --iam-account=${fullIdentifier} --managed-by=user --format=json`,
|
|
63
63
|
).then((o) => JSON.parse(o.stdout));
|
|
64
64
|
|
|
65
65
|
for (const key of keys) {
|
|
66
66
|
await exec(
|
|
67
|
-
`gcloud iam service-accounts keys delete ${key.name} --quiet --iam-account=${fullIdentifier}
|
|
67
|
+
`gcloud iam service-accounts keys delete ${key.name} --quiet --iam-account=${fullIdentifier}`,
|
|
68
68
|
);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
return await exec(
|
|
72
72
|
// on some platforms /dev/stdout is not available without the pipe
|
|
73
|
-
`gcloud iam service-accounts keys create /dev/stdout --iam-account=${fullIdentifier} | cat
|
|
73
|
+
`gcloud iam service-accounts keys create /dev/stdout --iam-account=${fullIdentifier} | cat`,
|
|
74
74
|
).then((o) => o.stdout);
|
|
75
75
|
};
|
|
76
76
|
|
|
@@ -78,7 +78,7 @@ export const upsertGcloudServiceAccountAndSaveSecret = async (
|
|
|
78
78
|
instance: CommandInstance,
|
|
79
79
|
context: Context,
|
|
80
80
|
account: ServiceAccount,
|
|
81
|
-
secretName: string
|
|
81
|
+
secretName: string,
|
|
82
82
|
): Promise<void> => {
|
|
83
83
|
instance.log("upserting service account " + account.name + "...");
|
|
84
84
|
const key = await upsertGcloudServiceAccount(context, account);
|
|
@@ -89,7 +89,7 @@ export const upsertGcloudServiceAccountAndSaveSecret = async (
|
|
|
89
89
|
[secretName]: key,
|
|
90
90
|
},
|
|
91
91
|
context.environment.shortName,
|
|
92
|
-
context.componentName
|
|
92
|
+
context.componentName,
|
|
93
93
|
);
|
|
94
94
|
instance.log("done!");
|
|
95
95
|
};
|
package/src/kubernetes/index.ts
CHANGED
|
@@ -9,7 +9,7 @@ export const getProjectPods = async (envComponent: string) => {
|
|
|
9
9
|
|
|
10
10
|
const { componentName } = parseChoice(envComponent);
|
|
11
11
|
return res.body.items.filter((item) =>
|
|
12
|
-
componentName ? item.metadata?.name?.includes(componentName + "-") : true
|
|
12
|
+
componentName ? item.metadata?.name?.includes(componentName + "-") : true,
|
|
13
13
|
);
|
|
14
14
|
};
|
|
15
15
|
|
|
@@ -5,7 +5,7 @@ import { openGoogleCloudDashboard } from "../gcloud/openDashboard";
|
|
|
5
5
|
|
|
6
6
|
export const openGoogleCloudLogs = async (
|
|
7
7
|
instance: CommandInstance,
|
|
8
|
-
context: Context
|
|
8
|
+
context: Context,
|
|
9
9
|
) => {
|
|
10
10
|
const deployConfig = context.componentConfig.deploy;
|
|
11
11
|
if (!isOfDeployType(deployConfig, "kubernetes")) {
|
|
@@ -31,7 +31,7 @@ export const openGoogleCloudLogs = async (
|
|
|
31
31
|
|
|
32
32
|
export const openGoogleCloudKubernetesDashboard = async (
|
|
33
33
|
instance: CommandInstance,
|
|
34
|
-
context: Context
|
|
34
|
+
context: Context,
|
|
35
35
|
) => {
|
|
36
36
|
const deployConfig = context.componentConfig.deploy;
|
|
37
37
|
if (!isOfDeployType(deployConfig, "kubernetes")) {
|
|
@@ -4,12 +4,12 @@ export const startKubePortForward = async (
|
|
|
4
4
|
podname: string,
|
|
5
5
|
localPort: number,
|
|
6
6
|
remotePort: number,
|
|
7
|
-
namespace: string
|
|
7
|
+
namespace: string,
|
|
8
8
|
) => {
|
|
9
9
|
const name = `kube/${namespace}/${podname}/${localPort}:${remotePort}`;
|
|
10
10
|
|
|
11
11
|
await startPortForwardCommand(
|
|
12
12
|
name,
|
|
13
|
-
`kubectl port-forward ${podname} ${localPort}:${remotePort} -n ${namespace}
|
|
13
|
+
`kubectl port-forward ${podname} ${localPort}:${remotePort} -n ${namespace}`,
|
|
14
14
|
);
|
|
15
15
|
};
|
|
@@ -5,7 +5,7 @@ declare module "child-process-promise" {
|
|
|
5
5
|
cmd: string,
|
|
6
6
|
options?: {
|
|
7
7
|
env?: Record<string, string>;
|
|
8
|
-
}
|
|
8
|
+
},
|
|
9
9
|
): Promise<{
|
|
10
10
|
stdout: string;
|
|
11
11
|
}>;
|
|
@@ -19,7 +19,7 @@ declare module "child-process-promise" {
|
|
|
19
19
|
|
|
20
20
|
function spawn(
|
|
21
21
|
cmd: string,
|
|
22
|
-
options?: SpawnOptions
|
|
22
|
+
options?: SpawnOptions,
|
|
23
23
|
): Promise<{
|
|
24
24
|
stdout: string;
|
|
25
25
|
}>;
|
|
@@ -27,7 +27,7 @@ declare module "child-process-promise" {
|
|
|
27
27
|
function spawn(
|
|
28
28
|
cmd: string,
|
|
29
29
|
args: string[],
|
|
30
|
-
options?: SpawnOptions
|
|
30
|
+
options?: SpawnOptions,
|
|
31
31
|
): Promise<unknown> & {
|
|
32
32
|
childProcess: {
|
|
33
33
|
stdout: ReadStream;
|
package/src/utils/editAsFile.ts
CHANGED
|
@@ -6,7 +6,7 @@ import getEditor from "./getEditor";
|
|
|
6
6
|
|
|
7
7
|
export const editAsFile = async <T>(
|
|
8
8
|
inObject: T,
|
|
9
|
-
preamble?: string
|
|
9
|
+
preamble?: string,
|
|
10
10
|
): Promise<T> => {
|
|
11
11
|
const fullPreamble = preamble
|
|
12
12
|
? `#
|
|
@@ -25,7 +25,7 @@ export const editAsFile = async <T>(
|
|
|
25
25
|
await (await getEditor()).open(tmpFilePath);
|
|
26
26
|
newContent = parse((await readFile(tmpFilePath)).toString("utf-8")) as T;
|
|
27
27
|
},
|
|
28
|
-
{ postfix: ".yml" }
|
|
28
|
+
{ postfix: ".yml" },
|
|
29
29
|
);
|
|
30
30
|
|
|
31
31
|
return newContent;
|