Last active
April 14, 2019 18:52
-
-
Save chriskuech/8ff2f70feab4fb1d9eda79e08f2d71bc to your computer and use it in GitHub Desktop.
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 | |
} | |
function New-Cluster { | |
[OutputType([Cluster])] | |
Param( | |
[Parameter(Mandatory, ParameterSetName = "Id", Position = 0)] | |
[ValidateNotNullOrEmpty()] | |
[string] $Id, | |
[Parameter(Mandatory, ParameterSetName = "Components")] | |
[string] $Service, | |
[Parameter(Mandatory, ParameterSetName = "Components")] | |
[string] $FlightingRing, | |
[Parameter(Mandatory, ParameterSetName = "Components")] | |
[string] $Region, | |
[Parameter(Mandatory, ParameterSetName = "Components")] | |
[int] $Index | |
) | |
if ($Id) { | |
$Service, $FlightingRing, $Region, $Index = $Id -split "-" | |
} | |
[Cluster]@{ | |
Service = $Service | |
FlightingRing = $FlightingRing | |
Region = $Region | |
Index = $Index | |
} | |
} | |
Export-ModuleMember New-Cluster |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment