Skip to content

Commit

Permalink
Implemented Array conversion and MaxDepth
Browse files Browse the repository at this point in the history
  • Loading branch information
ykuijs committed Jun 4, 2024
1 parent 50cb3f5 commit 49a7f0e
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 19 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"files.trimTrailingWhitespace": true,
"files.trimFinalNewlines": true,
"files.insertFinalNewline": true,
"files.encoding": "utf8",
"files.associations": {
"*.ps1xml": "xml"
},
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Updated StringArray data type into an actual array with string values in the ExampleDataFile
- Changed the MaxDepth from 5 to 8, so resources are generated on a lower level

## [0.1.14] - 2024-03-26

- Added CICD parameter under the Environment branch in the Example data
Expand Down
42 changes: 38 additions & 4 deletions source/Private/Get-AttributeString.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,29 @@ function Get-AttributeString

if ($null -eq $embeddedProperty.ValueMap)
{
$ConfigData.$($property.Name)[0].$($embeddedProperty.Name) = ('{0} | {1} | {2}' -f $embeddedProperty.DataType, $state, $embeddedProperty.Description)
if ($embeddedProperty.DataType -like "*Array")
{
$dataType = $embeddedProperty.DataType -replace "Array"
$result = @(('{0} | {1} | {2}' -f $dataType, $state, $embeddedProperty.Description))
}
else
{
$result = ('{0} | {1} | {2}' -f $embeddedProperty.DataType, $state, $embeddedProperty.Description)
}
}
else
{
$ConfigData.$($property.Name)[0].$($embeddedProperty.Name) = ('{0} | {1} | {2} | {3}' -f $embeddedProperty.DataType, $state, $embeddedProperty.Description, ($embeddedProperty.ValueMap -join ' / '))
if ($embeddedProperty.DataType -like "*Array")
{
$dataType = $embeddedProperty.DataType -replace "Array"
$result = @(('{0} | {1} | {2} | {3}' -f $dataType, $state, $embeddedProperty.Description, ($embeddedProperty.ValueMap -join ' / ')))
}
else
{
$result = ('{0} | {1} | {2} | {3}' -f $embeddedProperty.DataType, $state, $embeddedProperty.Description, ($embeddedProperty.ValueMap -join ' / '))
}
}
$ConfigData.$($property.Name)[0].$($embeddedProperty.Name) = $result
}
else
{
Expand All @@ -98,12 +115,29 @@ function Get-AttributeString

if ($null -eq $embeddedProperty.ValueMap)
{
$ConfigData.$($property.Name).$($embeddedProperty.Name) = ('{0} | {1} | {2}' -f $embeddedProperty.DataType, $state, $embeddedProperty.Description)
if ($embeddedProperty.DataType -like "*Array")
{
$dataType = $embeddedProperty.DataType -replace "Array"
$result = @(('{0} | {1} | {2}' -f $dataType, $state, $embeddedProperty.Description))
}
else
{
$result = ('{0} | {1} | {2}' -f $embeddedProperty.DataType, $state, $embeddedProperty.Description)
}
}
else
{
$ConfigData.$($property.Name).$($embeddedProperty.Name) = ('{0} | {1} | {2} | {3}' -f $embeddedProperty.DataType, $state, $embeddedProperty.Description, ($embeddedProperty.ValueMap -join ' / '))
if ($embeddedProperty.DataType -like "*Array")
{
$dataType = $embeddedProperty.DataType -replace "Array"
$result = @(('{0} | {1} | {2} | {3}' -f $dataType, $state, $embeddedProperty.Description, ($embeddedProperty.ValueMap -join ' / ')))
}
else
{
$result = ('{0} | {1} | {2} | {3}' -f $embeddedProperty.DataType, $state, $embeddedProperty.Description, ($embeddedProperty.ValueMap -join ' / '))
}
}
$ConfigData.$($property.Name).$($embeddedProperty.Name) = $result
}
else
{
Expand Down
23 changes: 20 additions & 3 deletions source/Public/New-CompositeResourceModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ function New-CompositeResourceModule
[void]$configString.AppendLine(('{0}{1}' -f (Get-IndentationString -Indentation $indent), '}'))

$script:currentDepth = 0
$script:maxDepth = 5
$script:maxDepth = 8

# Process all parameters, but handle embedded parameters separately
$result = Get-EmbeddedPropertyString -Properties $resourceSchema.Attributes -Indentation $indent -ParameterName '$parameters'
Expand Down Expand Up @@ -464,12 +464,29 @@ function New-CompositeResourceModule

if ($null -eq $property.ValueMap)
{
$currentDataObject.$($property.Name) = ('{0} | {1} | {2}' -f $propertyDataType, $state, $property.Description)
if ($propertyDataType -like "*Array")
{
$propertyDataType = $propertyDataType -replace "Array"
$result = @(('{0} | {1} | {2}' -f $propertyDataType, $state, $property.Description))
}
else
{
$result = ('{0} | {1} | {2}' -f $propertyDataType, $state, $property.Description)
}
}
else
{
$currentDataObject.$($property.Name) = ('{0} | {1} | {2} | {3}' -f $propertyDataType, $state, $property.Description, ($property.ValueMap -join ' / '))
if ($propertyDataType -like "*Array")
{
$propertyDataType = $propertyDataType -replace "Array"
$result = ('{0} | {1} | {2} | {3}' -f $propertyDataType, $state, $property.Description, ($property.ValueMap -join ' / '))
}
else
{
$result = ('{0} | {1} | {2} | {3}' -f $propertyDataType, $state, $property.Description, ($property.ValueMap -join ' / '))
}
}
$currentDataObject.$($property.Name) = $result
}
}
}
Expand Down
Loading

0 comments on commit 49a7f0e

Please sign in to comment.