Skip to content

Commit

Permalink
Merge pull request actions#98 from akamai/feature/WEEPKRK-1069
Browse files Browse the repository at this point in the history
[Fix] Creating sandbox from recipe with CPCode is not using provided CPCode
  • Loading branch information
herzykj authored May 31, 2021
2 parents 9c587fe + 84ce453 commit 984ea15
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/cli-main.ts
Original file line number Diff line number Diff line change
@@ -356,8 +356,9 @@ function resolveRulesPath(recipeFilePath, rulesPath) {
}

async function createFromPropertiesRecipe(recipe, cpcode) {
const sandboxRecipe = recipe.sandbox;
const properties = sandboxRecipe.properties;
const cloneable = recipe.sandbox.clonable
const sandboxName = recipe.sandbox.name
const properties = recipe.sandbox.properties;

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

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

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

function createRecipeSandboxAndProperty(rp, propertyForRules, recipe, cpcode) {
function createRecipeSandboxAndProperty(rp, propertyForRules, isCloneable, sandboxName, cpcode) {
if (rp.property) {
return createFromProperty(rp.property, rp.requestHostnames, recipe.clonable, recipe.name, cpcode);
return createFromProperty(rp.property, rp.requestHostnames, isCloneable, sandboxName, cpcode);
} else if (rp.hostname) {
return createFromHostname(rp.hostname, rp.requestHostnames, recipe.clonable, recipe.name, cpcode);
return createFromHostname(rp.hostname, rp.requestHostnames, isCloneable, sandboxName, cpcode);
} else if (rp.rulesPath) {
return createFromRules(rp.rulesPath, propertyForRules, rp.requestHostnames, recipe.clonable, recipe.name, cpcode);
return createFromRules(rp.rulesPath, propertyForRules, rp.requestHostnames, isCloneable, sandboxName, cpcode);
} else {
cliUtils.logAndExit(1, 'Critical error with recipe property. Define the rulesPath or property.');
}

0 comments on commit 984ea15

Please sign in to comment.