@ibm-cloud/cd-tools 1.15.4 → 1.15.5

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.
@@ -253,8 +253,21 @@ export async function importTerraform(token, apiKey, region, toolchainId, toolch
253
253
  newTfFileObj['resource'][key][k]['value'] = `\${${toolIdMap[propValue].type}.${toolIdMap[propValue].name}.tool_id}`;
254
254
  } else if (propValue) {
255
255
  // escape newlines, double quotes and backslashes
256
- if (propValue.includes('\n')) logger.warn(`Warning! Multi-line values for pipeline and trigger properties are not yet supported in the provider, newlines will be replaced with '\\\\n': "${k}"`, LOG_STAGES.import, true);
257
- newTfFileObj['resource'][key][k]['value'] = propValue.replace(/\\/g, '\\\\').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/"/g, '\\"');
256
+
257
+ let newValue = propValue;
258
+
259
+ const START_INDICATOR = '${jsonencode(';
260
+ const END_INDICATOR = ')}';
261
+
262
+ if (propValue.startsWith(START_INDICATOR) && propValue.endsWith(END_INDICATOR)) {
263
+ // skip substitution for jsonencode case, don't want to mangle it
264
+ } else {
265
+ if (propValue.includes('\n')) logger.warn(`Warning! Multi-line values for pipeline and trigger properties are not yet supported in the provider, newlines will be replaced with '\\\\n': "${k}"`, LOG_STAGES.import, true);
266
+
267
+ // TODO: remove extra backslash in newline replacement once provider is updated
268
+ newValue = newValue.replace(/\\/g, '\\\\').replace(/\n/g, '\\\\n').replace(/\r/g, '\\\\r').replace(/"/g, '\\"');
269
+ }
270
+ newTfFileObj['resource'][key][k]['value'] = newValue;
258
271
  }
259
272
  }
260
273
 
@@ -341,8 +341,16 @@ async function setupTerraformFiles(config) {
341
341
  newTfFileObj['resource']['ibm_cd_tekton_pipeline_property'][k]['value'] = `\${ibm_cd_toolchain_tool_githubconsolidated.${thisTfName}.tool_id}`;
342
342
  } else if (thisValue) {
343
343
  // escape newlines, double quotes and backslashes
344
- // TODO: remove extra backslash in newline replacement once provider is updated
345
- newTfFileObj['resource']['ibm_cd_tekton_pipeline_property'][k]['value'] = thisValue.replace(/\\/g, '\\\\').replace(/\n/g, '\\\\n').replace(/\r/g, '\\\\r').replace(/"/g, '\\"');
344
+
345
+ const START_INDICATOR = '${jsonencode(';
346
+ const END_INDICATOR = ')}';
347
+
348
+ if (thisValue.startsWith(START_INDICATOR) && thisValue.endsWith(END_INDICATOR)) {
349
+ // skip newline substitution for jsonencode case, don't want to mangle it
350
+ } else {
351
+ // TODO: remove extra backslash in newline replacement once provider is updated
352
+ newTfFileObj['resource']['ibm_cd_tekton_pipeline_property'][k]['value'] = thisValue.replace(/\\/g, '\\\\').replace(/\n/g, '\\\\n').replace(/\r/g, '\\\\r').replace(/"/g, '\\"');
353
+ }
346
354
  }
347
355
  }
348
356
  catch {
@@ -363,8 +371,16 @@ async function setupTerraformFiles(config) {
363
371
  newTfFileObj['resource']['ibm_cd_tekton_pipeline_trigger_property'][k]['value'] = `\${ibm_cd_toolchain_tool_githubconsolidated.${thisTfName}.tool_id}`;
364
372
  } else if (thisValue) {
365
373
  // escape newlines, double quotes and backslashes
366
- // TODO: remove extra backslash in newline replacement once provider is updated
367
- newTfFileObj['resource']['ibm_cd_tekton_pipeline_trigger_property'][k]['value'] = thisValue.replace(/\\/g, '\\\\').replace(/\n/g, '\\\\n').replace(/\r/g, '\\\\r').replace(/"/g, '\\"');
374
+
375
+ const START_INDICATOR = '${jsonencode(';
376
+ const END_INDICATOR = ')}';
377
+
378
+ if (thisValue.startsWith(START_INDICATOR) && thisValue.endsWith(END_INDICATOR)) {
379
+ // skip newline substitution for jsonencode case, don't want to mangle it
380
+ } else {
381
+ // TODO: remove extra backslash in newline replacement once provider is updated
382
+ newTfFileObj['resource']['ibm_cd_tekton_pipeline_trigger_property'][k]['value'] = thisValue.replace(/\\/g, '\\\\').replace(/\n/g, '\\\\n').replace(/\r/g, '\\\\r').replace(/"/g, '\\"');
383
+ }
368
384
  }
369
385
  }
370
386
  catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibm-cloud/cd-tools",
3
- "version": "1.15.4",
3
+ "version": "1.15.5",
4
4
  "description": "Tools and utilities for the IBM Cloud Continuous Delivery service and resources",
5
5
  "repository": {
6
6
  "type": "git",
@@ -168,7 +168,30 @@ describe('copy-toolchain: Test functionalities', function () {
168
168
  'Only \'yes\' will be accepted to proceed. (Ctrl-C to abort)': 'yes'
169
169
  },
170
170
  }
171
- }
171
+ },
172
+ {
173
+ name: 'Handles special characters in names',
174
+ cmd: [CLI_PATH, COMMAND, '-c', TEST_TOOLCHAINS['special-chars'].crn, '-r', TEST_TOOLCHAINS['special-chars'].region, '-D', '-f'],
175
+ expected: null,
176
+ options: {
177
+ timeout: 100000,
178
+ cwd: TEMP_DIR + '/' + 'special-chars'
179
+ },
180
+ assertionFunc: () => {
181
+ assert.isTrue(
182
+ areFilesInDir(TEMP_DIR + '/' + 'special-chars', [
183
+ 'cd_tekton_pipeline.tf',
184
+ 'cd_tekton_pipeline_definition.tf',
185
+ 'cd_tekton_pipeline_property.tf',
186
+ 'cd_tekton_pipeline_trigger.tf',
187
+ 'cd_tekton_pipeline_trigger_property.tf',
188
+ 'cd_toolchain.tf',
189
+ 'cd_toolchain_tool_hostedgit.tf',
190
+ 'cd_toolchain_tool_pipeline.tf',
191
+ ])
192
+ );
193
+ }
194
+ },
172
195
  ];
173
196
 
174
197
  for (const { name, cmd, expected, options, assertionFunc } of testCases) {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Licensed Materials - Property of IBM
3
- * (c) Copyright IBM Corporation 2025. All Rights Reserved.
3
+ * (c) Copyright IBM Corporation 2025, 2026. All Rights Reserved.
4
4
  *
5
5
  * Note to U.S. Government Users Restricted Rights:
6
6
  * Use, duplication or disclosure restricted by GSA ADP Schedule
@@ -52,6 +52,11 @@ export const TEST_TOOLCHAINS = {
52
52
  name: 'KEEP-SINGLE-PIPELINE-TOOLCHAIN',
53
53
  crn: 'crn:v1:bluemix:public:toolchain:us-east:a/9e8559fac61ee9fc74d3e595fa75d147:5ef88780-1e0f-4cda-94c7-f78909cc1140::',
54
54
  region: 'us-east'
55
+ },
56
+ 'special-chars': {
57
+ name: 'KEEP-SPECIAL-CHARS-_ .TOOLCHAIN',
58
+ crn: 'crn:v1:bluemix:public:toolchain:ca-tor:a/9e8559fac61ee9fc74d3e595fa75d147:bda05ed4-7092-4c7c-970a-7be53f1c1796::',
59
+ region: 'ca-tor'
55
60
  }
56
61
  };
57
62