This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cluster { | |
[ValidatePattern("^[A-z]+$")] | |
[string] $Service | |
[ValidateSet("TEST", "STAGE", "CANARY", "PROD")] | |
[string] $FlightingRing | |
[ValidateSet("EastUS", "WestUS", "NorthEurope")] | |
[string] $Region | |
[ValidateRange(0, 255)] | |
[int] $Index | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cluster { | |
[ValidatePattern("^[A-z]+$")] | |
[string] $Service | |
[ValidateSet("TEST", "STAGE", "CANARY", "PROD")] | |
[string] $FlightingRing | |
[ValidateSet("EastUS", "WestUS", "NorthEurope")] | |
[string] $Region | |
[ValidateRange(0, 255)] | |
[int] $Index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cluster { | |
[ValidatePattern("^[A-z]+$")] | |
[string] $Service | |
[ValidateSet("TEST", "STAGE", "CANARY", "PROD")] | |
[string] $FlightingRing | |
[ValidateSet("EastUS", "WestUS", "NorthEurope")] | |
[string] $Region | |
[ValidateRange(0, 255)] | |
[int] $Index | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Cluster]$cluster = Get-Content "./my-cluster.json" | ConvertFrom-Json | |
[Cluster[]]$clusters = Import-Csv "./my-clusters.csv" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node { | |
[ValidateLength(3, 7)] | |
[string] $Name | |
[ValidateSet("INT", "PPE", "PROD")] | |
[string] $FlightingRing | |
[ValidateSet("EastUS", "WestUS", "NorthEurope", "WestEurope")] | |
[string] $Region | |
Node([string] $Name) { | |
$Name -match "([a-z]+)(INT|PPE|PROD)([a-z]+)" | |
$_, $this.Service, $this.FlightingRing, $this.Region = $Matches |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ensure a path exists | |
[ValidateScript({Test-Path $_})] | |
$path | |
# Ensure a non-empty value | |
[ValidateNotNullOrEmpty()] | |
$value | |
# Ensure a string meets a certain convention | |
[ValidatePattern("^[a-z]+-[a-z]+-[a-z]+-[0-9]+$")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Serialize | |
$listOfStrings | Out-File "./listOfStrings.txt" | |
# Deserialize | |
$listOfStrings = Get-Content "./listOfStrings.txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Serialize | |
$listOfShallowObjects | Export-Csv "./listOfShallowObjects.csv" | |
# Deserialize | |
$listOfShallowObjects = Import-Csv "./listOfShallowObjects.csv" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$container = "./container" | |
# Serialize | |
$setOfDeepObjects | % {$_ | ConvertTo-Json | Out-File "$container/$($_.SomeUniqueKeyOnEachObject).json"} | |
# Deserialize | |
$setOfDeepObjects = Get-ChildItem "$container/*.json" | % {Get-Content $_ | ConvertFrom-Json} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$nodePropertyNames = "Tier1", "Tier2", "Tier2", "LeafName" | |
$container = "./container" | |
$treePath = ($nodePropertyNames | % {$obj.$_}) -join "/" | |
$fsPath = "$container/$treePath.json" | |
# Store | |
New-Item $fsPath -Force | |
$obj | ConvertTo-Json | Out-File $fsPath |