Skip to content

Commit

Permalink
Rename constants (microsoft#939)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenWeatherford authored Sep 2, 2020
1 parent 7834281 commit 45fa631
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ export namespace templateKeys {
export const apiProfile = 'apiProfile';

// Copy blocks
export const loopVarCopy = "copy";
export const loopVarName = 'name';
export const loopVarInput = 'input';
export const loopVarCount = 'count';
export const copyLoop = "copy";
export const copyName = 'name';
export const copyInput = 'input';
export const copyCount = 'count';

// Resources
export const properties = 'properties';
Expand Down
12 changes: 6 additions & 6 deletions src/documents/templates/VariableDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class TopLevelVariableDefinition extends VariableDefinition {

return mapJsonObjectValue(valueAsObject, prop => {
const arrayValue = Json.asArrayValue(prop.value);
if (!!arrayValue && prop.nameValue.unquotedValue.toLowerCase() === templateKeys.loopVarCopy) {
if (!!arrayValue && prop.nameValue.unquotedValue.toLowerCase() === templateKeys.copyLoop) {
// The property is an array with the name "copy" - process it as a copy block

// CONSIDER: Azure actually leaves the COPY property's value alone if all of its elements doesn't
Expand All @@ -113,9 +113,9 @@ export class TopLevelVariableDefinition extends VariableDefinition {
// Element has to be an object
const loopVarObject = Json.asObjectValue(copyElement);
if (loopVarObject) {
const name = Json.asStringValue(loopVarObject.getPropertyValue(templateKeys.loopVarName));
const input = loopVarObject.getPropertyValue(templateKeys.loopVarInput);
const count = loopVarObject.getPropertyValue(templateKeys.loopVarCount);
const name = Json.asStringValue(loopVarObject.getPropertyValue(templateKeys.copyName));
const input = loopVarObject.getPropertyValue(templateKeys.copyInput);
const count = loopVarObject.getPropertyValue(templateKeys.copyCount);

// If both name and count are there, ARM processes this as a copy block, otherwise it considers
// it to simply be a member with the name "copy".
Expand Down Expand Up @@ -207,9 +207,9 @@ export class TopLevelCopyBlockVariableDefinition extends VariableDefinition {

const asObject = Json.asObjectValue(copyVariableObject);
if (asObject) {
const nameValue = Json.asStringValue(asObject.getPropertyValue(templateKeys.loopVarName));
const nameValue = Json.asStringValue(asObject.getPropertyValue(templateKeys.copyName));
if (nameValue) {
const value = asObject.getPropertyValue(templateKeys.loopVarInput);
const value = asObject.getPropertyValue(templateKeys.copyInput);
return new TopLevelCopyBlockVariableDefinition(asObject, nameValue, value);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/documents/templates/scopes/templateScopes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function getVariableDefinitionsFromObject(objectValue: Json.ObjectValue | undefi
if (variables) {
const varDefs: IVariableDefinition[] = [];
for (let prop of variables.properties) {
if (prop.nameValue.unquotedValue.toLowerCase() === templateKeys.loopVarCopy) {
if (prop.nameValue.unquotedValue.toLowerCase() === templateKeys.copyLoop) {
// We have a top-level copy block, e.g.:
//
// "copy": [
Expand Down

0 comments on commit 45fa631

Please sign in to comment.