@ibm-cloud/cd-tools 1.15.11 → 1.15.13

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.
@@ -15,7 +15,7 @@ import { jsonToTf } from 'json-to-tf';
15
15
  import { getPipelineData, getToolchainTools } from './requests.js';
16
16
  import { runTerraformPlanGenerate, setTerraformEnv } from './terraform.js';
17
17
  import { getRandChars, isSecretReference, normalizeName } from './utils.js';
18
- import { LOG_STAGES, logger } from './logger.js';
18
+ import { logger } from './logger.js';
19
19
 
20
20
  import { SECRET_KEYS_MAP, SUPPORTED_TOOLS_MAP } from '../../config.js';
21
21
 
@@ -331,13 +331,20 @@ export async function importTerraform(token, apiKey, region, toolchainId, toolch
331
331
 
332
332
  if (!isCompact) {
333
333
  for (const [key, value] of Object.entries(newTfFileObj['resource'])) {
334
- if (!key.startsWith('ibm_')) continue;
335
- const newFileName = key.split('ibm_')[1];
336
-
337
- const newFileContents = { 'resource': { [key]: value } };
338
- const newFileContentsJson = jsonToTf(JSON.stringify(newFileContents));
339
-
340
- fs.writeFileSync(`${dir}/generated/${newFileName}.tf`, newFileContentsJson);
334
+ try {
335
+ if (!key.startsWith('ibm_')) continue;
336
+ const newFileName = key.split('ibm_')[1];
337
+
338
+ const newFileContentsJson = { 'resource': { [key]: value } };
339
+ const newFileContentsTf = jsonToTf(JSON.stringify(newFileContentsJson));
340
+
341
+ fs.writeFileSync(`${dir}/generated/${newFileName}.tf`, newFileContentsTf);
342
+ } catch (err) {
343
+ // some extra error logging
344
+ logger.dump(`\nCurrent resource: ${key}`);
345
+ logger.dump(`\n Current resource value: ${JSON.stringify(value, null, 2)}`);
346
+ throw err;
347
+ }
341
348
  }
342
349
  } else {
343
350
  const generatedFileNew = jsonToTf(JSON.stringify(newTfFileObj));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibm-cloud/cd-tools",
3
- "version": "1.15.11",
3
+ "version": "1.15.13",
4
4
  "description": "Tools and utilities for the IBM Cloud Continuous Delivery service and resources",
5
5
  "repository": {
6
6
  "type": "git",