Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename constants #939

Merged
merged 1 commit into from
Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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