Skip to content

Commit 984ea15

Browse files
authored
Merge pull request actions#98 from akamai/feature/WEEPKRK-1069
[Fix] Creating sandbox from recipe with CPCode is not using provided CPCode
2 parents 9c587fe + 84ce453 commit 984ea15

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/cli-main.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,9 @@ function resolveRulesPath(recipeFilePath, rulesPath) {
356356
}
357357

358358
async function createFromPropertiesRecipe(recipe, cpcode) {
359-
const sandboxRecipe = recipe.sandbox;
360-
const properties = sandboxRecipe.properties;
359+
const cloneable = recipe.sandbox.clonable
360+
const sandboxName = recipe.sandbox.name
361+
const properties = recipe.sandbox.properties;
361362

362363
const firstProp = properties[0];
363364
let propForRules;
@@ -372,7 +373,8 @@ async function createFromPropertiesRecipe(recipe, cpcode) {
372373
}
373374

374375
console.log(`Creating sandbox and property 1 from recipe.`);
375-
const r = await cliUtils.spinner(createRecipeSandboxAndProperty(firstProp, propForRules, sandboxRecipe, cpcode));
376+
const r = await cliUtils.spinner(createRecipeSandboxAndProperty(firstProp, propForRules, cloneable, sandboxName,
377+
cpcode || firstProp.cpcode));
376378

377379
for (let i = 1; i < properties.length; i++) {
378380
try {
@@ -527,13 +529,13 @@ function createRecipeProperty(rp, sandboxId) {
527529
}
528530
}
529531

530-
function createRecipeSandboxAndProperty(rp, propertyForRules, recipe, cpcode) {
532+
function createRecipeSandboxAndProperty(rp, propertyForRules, isCloneable, sandboxName, cpcode) {
531533
if (rp.property) {
532-
return createFromProperty(rp.property, rp.requestHostnames, recipe.clonable, recipe.name, cpcode);
534+
return createFromProperty(rp.property, rp.requestHostnames, isCloneable, sandboxName, cpcode);
533535
} else if (rp.hostname) {
534-
return createFromHostname(rp.hostname, rp.requestHostnames, recipe.clonable, recipe.name, cpcode);
536+
return createFromHostname(rp.hostname, rp.requestHostnames, isCloneable, sandboxName, cpcode);
535537
} else if (rp.rulesPath) {
536-
return createFromRules(rp.rulesPath, propertyForRules, rp.requestHostnames, recipe.clonable, recipe.name, cpcode);
538+
return createFromRules(rp.rulesPath, propertyForRules, rp.requestHostnames, isCloneable, sandboxName, cpcode);
537539
} else {
538540
cliUtils.logAndExit(1, 'Critical error with recipe property. Define the rulesPath or property.');
539541
}

0 commit comments

Comments
 (0)