diff --git a/scripts/Common/Scripts/Config.ps1 b/scripts/Common/Scripts/Config.ps1 index 6f7dccc4..f615514f 100644 --- a/scripts/Common/Scripts/Config.ps1 +++ b/scripts/Common/Scripts/Config.ps1 @@ -156,6 +156,14 @@ $null = New-Module { Invoke-ConfigScript "getConfig $Name --json $ArgumentList"; } + <# + .SYNOPSIS + Gets the name of the config root. + #> + function Get-ConfigRootName { + return "valhalla$($IsWindows ? ".windows" : '')"; + } + <# .SYNOPSIS Gets a user configuration. @@ -168,13 +176,13 @@ $null = New-Module { #> function Get-UserConfig { param( - [string] $UserName = $env:UserName, + [string] $UserName = ($IsWindows ? $env:UserName : $env:USER), [Parameter(Mandatory, Position = 0)] [string] $Name ) if ((Get-Users) -contains $UserName) { - Get-Config "valhalla.windows.users.$UserName.$Name"; + Get-Config "$(Get-ConfigRootName).users.$UserName.$Name"; } else { return $null; } @@ -202,7 +210,7 @@ $null = New-Module { function Get-Users { [OutputType([string[]])] param() - Get-Attributes "valhalla.windows.users"; + Get-Attributes "$(Get-ConfigRootName).users"; } <# @@ -212,7 +220,7 @@ $null = New-Module { function Get-SetupUser { [OutputType([string])] param() - Get-Config "valhalla.windows.setupUser"; + Get-Config "$(Get-ConfigRootName).setupUser"; } <# @@ -416,7 +424,7 @@ $null = New-Module { Checks whether the current user is the setup user. #> function Test-SetupUser { - ($IsWindows ? $env:UserName : $env:USER) -eq (Get-Config "valhalla.windows.setupUser"); + ($IsWindows ? $env:UserName : $env:USER) -eq (Get-SetupUser); } <#