Private/Config/Read-SecretRotationConfigFile.ps1

function Read-SecretRotationConfigFile {
    <#
    .SYNOPSIS
        Reads and parses the Posh-SecretRotation configuration file.
    .DESCRIPTION
        Reads fresh from disk on every call - no in-memory cache, so editing the JSON file
        takes effect on the next call without reloading the module. Returns a default,
        target-less config object (version 1.0, empty targets) when the file does not exist
        yet, rather than throwing, so a fresh install doesn't require pre-creating a config
        file before Get-SecretRotationLoggingConfig's own defaulting can kick in.
    .PARAMETER Path
        Overrides the resolved live config path (Get-SecretRotationConfigPath). Exists mainly
        so tests can point this at a fixture file without touching the real user-profile config.
    .OUTPUTS
        PSCustomObject.
    .EXAMPLE
        Read-SecretRotationConfigFile
        Reads the live user-profile config, or returns the version-1.0/empty-targets default
        if it doesn't exist yet.
    #>

    [CmdletBinding()]
    [OutputType([PSCustomObject])]
    param(
        [Parameter()]
        [string] $Path = (Get-SecretRotationConfigPath)
    )

    if (-not (Test-Path -Path $Path -PathType Leaf)) {
        return [PSCustomObject]@{
            version = '1.0'
            targets = [PSCustomObject]@{}
        }
    }

    $raw = Get-Content -Path $Path -Raw -Encoding UTF8
    $raw | ConvertFrom-Json
}