@ibm-cloud/cd-tools 1.15.21 → 1.15.23
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/cmd/utils/utils.js +13 -0
- package/cmd/utils/validate.js +11 -7
- package/package.json +1 -1
package/cmd/utils/utils.js
CHANGED
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
import * as readline from 'node:readline/promises';
|
|
11
11
|
import { randomInt } from 'node:crypto';
|
|
12
12
|
|
|
13
|
+
// Drain stdout before opening a readline prompt. When ora or console.log have
|
|
14
|
+
// queued writes to a TTY, readline's cursor-management sequences can overwrite
|
|
15
|
+
// the last printed lines if we don't wait for the stream to flush first.
|
|
16
|
+
function drainStdout() {
|
|
17
|
+
return new Promise(resolve => {
|
|
18
|
+
if (!process.stdout.writableNeedDrain) return resolve();
|
|
19
|
+
process.stdout.once('drain', resolve);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
13
23
|
import { logger } from './logger.js';
|
|
14
24
|
import { VAULT_REGEX } from '../../config.js';
|
|
15
25
|
|
|
@@ -22,6 +32,7 @@ export function parseEnvVar(name) {
|
|
|
22
32
|
};
|
|
23
33
|
|
|
24
34
|
export async function promptUserYesNo(question) {
|
|
35
|
+
await drainStdout();
|
|
25
36
|
const rl = readline.createInterface({
|
|
26
37
|
input: process.stdin,
|
|
27
38
|
output: process.stdout
|
|
@@ -48,6 +59,7 @@ export async function promptUserYesNo(question) {
|
|
|
48
59
|
}
|
|
49
60
|
|
|
50
61
|
export async function promptUserConfirmation(question, expectedAns, exitMsg) {
|
|
62
|
+
await drainStdout();
|
|
51
63
|
const rl = readline.createInterface({
|
|
52
64
|
input: process.stdin,
|
|
53
65
|
output: process.stdout
|
|
@@ -70,6 +82,7 @@ export async function promptUserConfirmation(question, expectedAns, exitMsg) {
|
|
|
70
82
|
}
|
|
71
83
|
|
|
72
84
|
export async function promptUserInput(question, initialInput, validationFn) {
|
|
85
|
+
await drainStdout();
|
|
73
86
|
const rl = readline.createInterface({
|
|
74
87
|
input: process.stdin,
|
|
75
88
|
output: process.stdout,
|
package/cmd/utils/validate.js
CHANGED
|
@@ -218,16 +218,16 @@ async function validateTools(token, tcId, region, skipPrompt) {
|
|
|
218
218
|
if (tool.tool_type_id === 'pipeline' && tool.parameters?.type === 'tekton') { // Check for secrets in Tekton pipeline
|
|
219
219
|
const pipelineData = await getPipelineData(token, tool.id, region);
|
|
220
220
|
|
|
221
|
-
pipelineData.properties
|
|
222
|
-
if (prop.type === 'secure' && !isSecretReference(prop.value) && prop.value
|
|
221
|
+
pipelineData.properties?.forEach((prop) => {
|
|
222
|
+
if (prop.type === 'secure' && !isSecretReference(prop.value) && prop.value?.length > 0)
|
|
223
223
|
secrets.push(['properties', prop.name].join('.').replace(/\s+/g, '+'));
|
|
224
224
|
});
|
|
225
225
|
|
|
226
|
-
pipelineData.triggers
|
|
226
|
+
pipelineData.triggers?.forEach((trigger) => {
|
|
227
227
|
if ((trigger?.secret?.type === 'token_matches' || trigger?.secret?.type === 'digest_matches') && !isSecretReference(trigger.secret?.value) && trigger.secret?.value?.length > 0)
|
|
228
228
|
secrets.push([trigger.name, trigger.secret.key_name].join('.').replace(/\s+/g, '+'));
|
|
229
229
|
trigger.properties?.forEach((prop) => {
|
|
230
|
-
if (prop.type === 'secure' && !isSecretReference(prop.value) && prop.value
|
|
230
|
+
if (prop.type === 'secure' && !isSecretReference(prop.value) && prop.value?.length > 0)
|
|
231
231
|
secrets.push([trigger.name, 'properties', prop.name].join('.').replace(/\s+/g, '+'));
|
|
232
232
|
});
|
|
233
233
|
});
|
|
@@ -239,10 +239,14 @@ async function validateTools(token, tcId, region, skipPrompt) {
|
|
|
239
239
|
});
|
|
240
240
|
}
|
|
241
241
|
if (secrets.length > 0) {
|
|
242
|
+
const MAX_SECRETS_DISPLAY = 10;
|
|
243
|
+
const displaySecrets = secrets.length > MAX_SECRETS_DISPLAY
|
|
244
|
+
? [...secrets.slice(0, MAX_SECRETS_DISPLAY), `... and ${secrets.length - MAX_SECRETS_DISPLAY} more`]
|
|
245
|
+
: secrets;
|
|
242
246
|
toolsWithHashedParams.push({
|
|
243
247
|
tool_name: toolName,
|
|
244
248
|
type: tool.tool_type_id,
|
|
245
|
-
secret_params:
|
|
249
|
+
secret_params: displaySecrets,
|
|
246
250
|
url: toolUrl
|
|
247
251
|
});
|
|
248
252
|
}
|
|
@@ -279,9 +283,9 @@ async function validateTools(token, tcId, region, skipPrompt) {
|
|
|
279
283
|
logger.table(toolsWithHashedParams);
|
|
280
284
|
}
|
|
281
285
|
|
|
282
|
-
if (!skipPrompt && (classicPipelines.length > 0 || hasInvalidConfig))
|
|
286
|
+
if (!skipPrompt && (classicPipelines.length > 0 || hasInvalidConfig)) {
|
|
283
287
|
await promptUserConfirmation('Caution: The above tool(s) will not be properly configured post migration. Do you want to proceed?', 'yes', 'Toolchain migration cancelled.');
|
|
284
|
-
|
|
288
|
+
}
|
|
285
289
|
return allTools.tools;
|
|
286
290
|
}
|
|
287
291
|
|