@ibm-cloud/cd-tools 1.15.5 → 1.15.6
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/copy-toolchain.js +13 -8
- package/cmd/utils/requests.js +1 -1
- package/package.json +1 -1
package/cmd/copy-toolchain.js
CHANGED
|
@@ -109,13 +109,6 @@ async function main(options) {
|
|
|
109
109
|
bearer = await getBearerToken(apiKey);
|
|
110
110
|
const accountId = await getAccountId(bearer, apiKey);
|
|
111
111
|
|
|
112
|
-
// check for continuous delivery instance in target region
|
|
113
|
-
if (!await getCdInstanceByRegion(bearer, accountId, targetRegion)) {
|
|
114
|
-
// give users the option to bypass
|
|
115
|
-
logger.warn(`Warning! Could not find a Continuous Delivery instance in the target region ${targetRegion} or you do not have permission to view, please create one before proceeding if one does not exist already.`, LOG_STAGES.setup);
|
|
116
|
-
await promptUserConfirmation(`Do you want to proceed anyway?`, 'yes', 'Toolchain migration cancelled.');
|
|
117
|
-
}
|
|
118
|
-
|
|
119
112
|
// check for existing .tf files in output directory
|
|
120
113
|
if (fs.existsSync(outputDir)) {
|
|
121
114
|
let files = fs.readdirSync(outputDir, { recursive: true });
|
|
@@ -164,8 +157,20 @@ async function main(options) {
|
|
|
164
157
|
exit(1);
|
|
165
158
|
}
|
|
166
159
|
|
|
160
|
+
// check for continuous delivery instance in target region and resource group
|
|
161
|
+
const cdInstances = await getCdInstanceByRegion(bearer, accountId, targetRegion);
|
|
162
|
+
const cdInstanceFound = cdInstances?.some((instance) => {
|
|
163
|
+
return instance.doc?.resource_group_id === sourceToolchainData['resource_group_id'];
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
if (!cdInstanceFound) {
|
|
167
|
+
// give users the option to bypass
|
|
168
|
+
logger.warn(`Warning! Could not find a Continuous Delivery instance in the target region ${targetRegion} and toolchain's resource group or you do not have permission to view, please create one before proceeding if one does not exist already.`, LOG_STAGES.setup);
|
|
169
|
+
await promptUserConfirmation(`Do you want to proceed anyway?`, 'yes', 'Toolchain migration cancelled.');
|
|
170
|
+
}
|
|
171
|
+
|
|
167
172
|
const resourceGroups = await getResourceGroups(bearer, accountId, [targetRg || sourceToolchainData['resource_group_id']]);
|
|
168
|
-
({ id: targetRgId, name: targetRgName } = resourceGroups[0])
|
|
173
|
+
({ id: targetRgId, name: targetRgName } = resourceGroups[0]);
|
|
169
174
|
// reuse name if not provided
|
|
170
175
|
if (!targetToolchainName) targetToolchainName = sourceToolchainData['name'];
|
|
171
176
|
[targetToolchainName, targetTag] = await warnDuplicateName(bearer, accountId, targetToolchainName, sourceRegion, targetRegion, targetRgId, targetRgName, targetTag, skipUserConfirmation);
|
package/cmd/utils/requests.js
CHANGED
|
@@ -180,7 +180,7 @@ async function getCdInstanceByRegion(bearer, accountId, region) {
|
|
|
180
180
|
const response = await axios(options);
|
|
181
181
|
switch (response.status) {
|
|
182
182
|
case 200:
|
|
183
|
-
return response.data.items.length > 0;
|
|
183
|
+
return response.data.items.length > 0 ? response.data.items : null;
|
|
184
184
|
default:
|
|
185
185
|
throw Error('Get CD instance failed');
|
|
186
186
|
}
|