Skip to content

Instantly share code, notes, and snippets.

View chriskuech's full-sized avatar

Chris Kuech chriskuech

  • Datum Source, ex MSFT
View GitHub Profile
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
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
function div($n, $d) {$n / $d} # a seemingly pure function
div 1 0 # throws 'Attempted to divide by zero' error
$ErrorActionPreference = "Stop"
function Assert-True {
[CmdletBinding()] # add ErrorAction support
Param([boolean]$Value)
if (-not $Value) {
throw "Failed assertion"
}
}
Select-ClusterSetPartialConfig ".\Configs" "PROD-EU-NorthEurope" `
| Sort-Object `
| % {$_ | Get-Content | ConvertFrom-Json} `
| Merge-Object -Strategy Override
Select-ClusterSetPartialConfig ".\Configs" "PROD-EU-NorthEurope" `
| % {$_ | Get-Content | ConvertFrom-Json} `
| Merge-Object -Strategy Fail
function Select-ClusterSetPartialConfig([string]$Container, [string[]]$Vector) {
$clusterId = $Vector -join "-"
Get-ChildItem $Container `
| ? {$clusterId -like ($_.BaseName -replace "_", "*")}
}
# constant parameters
$org = "MyAzureDevOpsOrgName"
$project = "MyAzureDevOpsProjectName"
$areaPath = "/the/area/path/containing/my/work/items"
$tag = "the-tag-that-identifies-work-items-as-automanaged"
$query = @"
SELECT *
FROM WorkItems
WHERE [Tags] CONTAINS '$tag'
Param(
# Path to the repo containing TODO-annotated files
[Parameter(Mandatory)]
[ValidateScript({Test-Path $_ -PathType Container})]
[string]$RepoRoot
)
& {
enum Priority {
Low = 3
... # previous param definition
& {
... # previous class and enum definitions
... # previous transformations
} | Sort Priority, FilePath, Line