@catladder/cli 1.145.0 → 1.146.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/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/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
package/src/utils/gitlab.ts
CHANGED
|
@@ -42,7 +42,7 @@ export const getGitlabToken = async (vorpal: CommandInstance | null) => {
|
|
|
42
42
|
if (!(await hasGitlabToken())) {
|
|
43
43
|
if (!vorpal) {
|
|
44
44
|
console.error(
|
|
45
|
-
"⚠️ gitlab token missing, please run catladder to set it up"
|
|
45
|
+
"⚠️ gitlab token missing, please run catladder to set it up",
|
|
46
46
|
);
|
|
47
47
|
process.exit(1);
|
|
48
48
|
}
|
|
@@ -56,7 +56,7 @@ export const doGitlabRequest = async <T = any>(
|
|
|
56
56
|
vorpal: CommandInstance | null,
|
|
57
57
|
path: string,
|
|
58
58
|
data: any = undefined,
|
|
59
|
-
method: Method = "GET"
|
|
59
|
+
method: Method = "GET",
|
|
60
60
|
): Promise<T> => {
|
|
61
61
|
const rootToken = await getGitlabToken(vorpal);
|
|
62
62
|
|
|
@@ -84,23 +84,23 @@ export const doGitlabRequest = async <T = any>(
|
|
|
84
84
|
throw new Error(
|
|
85
85
|
`Could not send request to gitlab api ${path}: ${result.status} "${
|
|
86
86
|
result.statusText
|
|
87
|
-
}".\nResponse: ${JSON.stringify(await result.json(), null, 2)}
|
|
87
|
+
}".\nResponse: ${JSON.stringify(await result.json(), null, 2)}`,
|
|
88
88
|
);
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
export const getProjectInfo = async (
|
|
92
|
-
vorpal: CommandInstance | null
|
|
92
|
+
vorpal: CommandInstance | null,
|
|
93
93
|
): Promise<{ id: string; web_url: string }> => {
|
|
94
94
|
const gitRemoteOriginUrl = (
|
|
95
95
|
await exec("git config --get remote.origin.url")
|
|
96
96
|
).stdout.trim();
|
|
97
97
|
const projectPath =
|
|
98
98
|
/(https:\/\/|git@)git\.panter\.ch[:/]([^.]*)(\.git)?/g.exec(
|
|
99
|
-
gitRemoteOriginUrl
|
|
99
|
+
gitRemoteOriginUrl,
|
|
100
100
|
);
|
|
101
101
|
const project = await doGitlabRequest(
|
|
102
102
|
vorpal,
|
|
103
|
-
`projects/${encodeURIComponent(projectPath[2])}
|
|
103
|
+
`projects/${encodeURIComponent(projectPath[2])}`,
|
|
104
104
|
);
|
|
105
105
|
return project;
|
|
106
106
|
};
|
|
@@ -114,28 +114,44 @@ type GitlabVariable = {
|
|
|
114
114
|
environment_scope: string;
|
|
115
115
|
};
|
|
116
116
|
export const getAllVariables = memoizee(
|
|
117
|
-
async (
|
|
117
|
+
async (
|
|
118
|
+
vorpal: CommandInstance | null,
|
|
119
|
+
n = 5, // how many requests to do in parallel, 5 seems a good value for many projects, ideally we would do one request in parallel per component
|
|
120
|
+
): Promise<Array<GitlabVariable>> => {
|
|
118
121
|
const { id } = await getProjectInfo(vorpal);
|
|
122
|
+
|
|
119
123
|
let all: Array<GitlabVariable> = [];
|
|
120
|
-
let result: Array<GitlabVariable
|
|
124
|
+
let result: Array<Array<GitlabVariable>> = [];
|
|
121
125
|
let page = 1;
|
|
126
|
+
|
|
122
127
|
do {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
// Create an array of promises for N pages
|
|
129
|
+
const promises = Array.from({ length: n }, (_, i) => {
|
|
130
|
+
return doGitlabRequest(
|
|
131
|
+
vorpal,
|
|
132
|
+
`projects/${id}/variables?per_page=100&page=${page + i}`,
|
|
133
|
+
);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// Wait for all promises to resolve
|
|
137
|
+
result = await Promise.all(promises);
|
|
138
|
+
|
|
139
|
+
// Increment the page by N
|
|
140
|
+
page += n;
|
|
141
|
+
|
|
142
|
+
// Flatten the result array and add it to 'all'
|
|
143
|
+
all = [...all, ...result.flat()];
|
|
144
|
+
// Continue only if the last page had results
|
|
145
|
+
} while (result.length > 0 && result[result.length - 1].length > 0);
|
|
146
|
+
|
|
131
147
|
return all;
|
|
132
148
|
},
|
|
133
|
-
{ promise: true }
|
|
149
|
+
{ promise: true },
|
|
134
150
|
);
|
|
135
151
|
|
|
136
152
|
export const getVariableValueByRawName = async (
|
|
137
153
|
vorpal: CommandInstance,
|
|
138
|
-
rawName: string
|
|
154
|
+
rawName: string,
|
|
139
155
|
) => {
|
|
140
156
|
const allVariables = await getAllVariables(vorpal);
|
|
141
157
|
return allVariables.find((v) => v.key === rawName)?.value;
|
|
@@ -150,7 +166,7 @@ const createVariable = async (
|
|
|
150
166
|
key: string,
|
|
151
167
|
value: string,
|
|
152
168
|
masked = true,
|
|
153
|
-
environment_scope = "*"
|
|
169
|
+
environment_scope = "*",
|
|
154
170
|
) => {
|
|
155
171
|
return await doGitlabRequest(
|
|
156
172
|
vorpal,
|
|
@@ -161,7 +177,7 @@ const createVariable = async (
|
|
|
161
177
|
masked: masked && isMaskable(value),
|
|
162
178
|
environment_scope,
|
|
163
179
|
},
|
|
164
|
-
"POST"
|
|
180
|
+
"POST",
|
|
165
181
|
);
|
|
166
182
|
};
|
|
167
183
|
|
|
@@ -170,7 +186,7 @@ const updateVariable = async (
|
|
|
170
186
|
projectId: string,
|
|
171
187
|
key: string,
|
|
172
188
|
value: string,
|
|
173
|
-
masked = true
|
|
189
|
+
masked = true,
|
|
174
190
|
) => {
|
|
175
191
|
return await doGitlabRequest(
|
|
176
192
|
vorpal,
|
|
@@ -179,20 +195,20 @@ const updateVariable = async (
|
|
|
179
195
|
value,
|
|
180
196
|
masked: masked && isMaskable(value),
|
|
181
197
|
},
|
|
182
|
-
"PUT"
|
|
198
|
+
"PUT",
|
|
183
199
|
);
|
|
184
200
|
};
|
|
185
201
|
|
|
186
202
|
const deleteVariable = async (
|
|
187
203
|
vorpal: CommandInstance,
|
|
188
204
|
projectId: string,
|
|
189
|
-
key: string
|
|
205
|
+
key: string,
|
|
190
206
|
) => {
|
|
191
207
|
return await doGitlabRequest(
|
|
192
208
|
vorpal,
|
|
193
209
|
`projects/${projectId}/variables/${key}`,
|
|
194
210
|
undefined,
|
|
195
|
-
"DELETE"
|
|
211
|
+
"DELETE",
|
|
196
212
|
);
|
|
197
213
|
};
|
|
198
214
|
|
|
@@ -233,7 +249,7 @@ const getAllCatladderEnvVarsInGitlab = async (vorpal: CommandInstance) => {
|
|
|
233
249
|
}
|
|
234
250
|
|
|
235
251
|
return acc;
|
|
236
|
-
}, {})
|
|
252
|
+
}, {}),
|
|
237
253
|
);
|
|
238
254
|
return allVariables;
|
|
239
255
|
};
|
|
@@ -260,7 +276,7 @@ export const upsertAllVariables = async (
|
|
|
260
276
|
env: string,
|
|
261
277
|
componentName: string,
|
|
262
278
|
backup = true,
|
|
263
|
-
masked = true // FIXME: would be better to have this per variable
|
|
279
|
+
masked = true, // FIXME: would be better to have this per variable
|
|
264
280
|
): Promise<void> => {
|
|
265
281
|
const { id } = await getProjectInfo(vorpal);
|
|
266
282
|
|
|
@@ -286,7 +302,7 @@ export const upsertAllVariables = async (
|
|
|
286
302
|
getBackupKey(fullKey, new Date().getTime()),
|
|
287
303
|
oldValue,
|
|
288
304
|
masked,
|
|
289
|
-
"_backup"
|
|
305
|
+
"_backup",
|
|
290
306
|
);
|
|
291
307
|
}
|
|
292
308
|
} else {
|
package/src/utils/log.ts
CHANGED
package/src/utils/promise.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export async function filter<T>(
|
|
2
2
|
arr: T[],
|
|
3
|
-
iterator: (item: T) => Promise<boolean
|
|
3
|
+
iterator: (item: T) => Promise<boolean>,
|
|
4
4
|
) {
|
|
5
5
|
const fail = Symbol("fail");
|
|
6
|
-
return (
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
return (
|
|
7
|
+
await Promise.all(
|
|
8
|
+
arr.map(async (item) => ((await iterator(item)) ? item : fail)),
|
|
9
|
+
)
|
|
10
|
+
).filter((i) => i !== fail) as any as Promise<T[]>;
|
|
9
11
|
}
|
|
10
12
|
|
|
11
|
-
export const delay = (ms: number) => new Promise(res => setTimeout(res, ms));
|
|
13
|
+
export const delay = (ms: number) => new Promise((res) => setTimeout(res, ms));
|