41 lines
1.1 KiB
PowerShell
41 lines
1.1 KiB
PowerShell
function Register-ConfigurationDataSecretProvider {
|
|
[CmdletBinding()]
|
|
Param(
|
|
[Parameter(Mandatory=$true)]
|
|
[string]
|
|
$Name,
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
[string[]]
|
|
$SupportedTypes,
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
[scriptblock]
|
|
$Resolver
|
|
)
|
|
|
|
if([string]::IsNullOrWhiteSpace($Name)){
|
|
throw "Secret provider [Name] must not be empty."
|
|
}
|
|
|
|
if($SupportedTypes.Count -eq 0){
|
|
throw "Secret provider [$Name] must define at least one supported type."
|
|
}
|
|
|
|
foreach($Type in $SupportedTypes){
|
|
if($Type -notin @("credential", "securestring", "string")){
|
|
throw "Secret provider [$Name] uses unsupported type [$Type]."
|
|
}
|
|
}
|
|
|
|
if($null -eq $script:ConfigurationDataSecretProviders){
|
|
$script:ConfigurationDataSecretProviders = @{}
|
|
}
|
|
|
|
$script:ConfigurationDataSecretProviders[$Name.ToLowerInvariant()] = [PSCustomObject]@{
|
|
Name = $Name
|
|
SupportedTypes = @($SupportedTypes | ForEach-Object { $_.ToLowerInvariant() })
|
|
Resolver = $Resolver
|
|
}
|
|
}
|