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
#!/bin/bash | |
# ensure there are no uncommitted changes | |
git diff-index --quiet HEAD -- || { echo "Untracked changes" >&2; exit 1; } | |
# derive variables | |
branch="$(git symbolic-ref --short HEAD)" | |
timestamp="$(date +%Y%m%dT%H%M%S)" | |
# do work on a separate branch |
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
## | |
# Export PFX from Windows as Base64 string without password | |
# | |
$thumbprint = "" | |
[Convert]::ToBase64String((Get-Item Cert:\CurrentUser\My\$thumbprint).Export("pkcs12")) |
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
# declarative | |
[ValidateRange(0, 10)] | |
[int]$n = Read-Host | |
# imperative | |
[int]$n = Read-Host | |
if ($n -lt 0 -or $n -gt 10) { | |
throw [IndexOutOfRangeException]::new() | |
} |
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
$ErrorActionPreference = "Stop" |
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
[AttributeName("param1", "param2")] $value |
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
[AttributeName("param1", "param2")] | |
$name = "value" |
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
[ValidateSet("ca", "eu", "us")] | |
$region = Read-Host |
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
function Deploy-Cluster { | |
Param( | |
[Parameter(Mandatory)] | |
[ValidatePattern("^[a-z]+-[a-z]+-[a-z]+-[0-9]+$")] | |
[string] $ClusterId | |
) | |
... |
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
function Get-Cluster { | |
[OutputType([Cluster]) | |
Param( | |
[ValidateNotNullOrEmpty()] | |
[string[]] $serviceIds | |
) | |
$serviceIds | ForEach-Object { | |
$service, $flightingRing, $region, $idx = $_ -split "-" | |
[Cluster]@{ |
OlderNewer