AugmentR icon indicating copy to clipboard operation
AugmentR copied to clipboard

postprovision.ps1 breaks when values contains '=', such as an AppInsights connection string containing (IngestionEndpoint= and LiveEndpoint=)

Open pascostefan opened this issue 1 year ago • 9 comments

A solution could be something like this perhaps? foreach ($line in $lines) { $index = $line.IndexOf('=') $name = $line.Substring(0, $index) $value = $line.Substring($index + 1) $value = $value.Replace('"', '') $name = $name.Replace('__', '') if ($value -ne '') { dotnet user-secrets set $name $value | Out-Null } }

pascostefan avatar Feb 07 '24 10:02 pascostefan

curious, were you planning on submitting a pull request inclusive of application insights?

bradygaster avatar Feb 08 '24 05:02 bradygaster

yeah, that was my idea

pascostefan avatar Feb 08 '24 11:02 pascostefan

cc @jongio on what he'd suggest as the safest way to terminate strings like that on the incoming. thanks for the contribution idea, let's get it in there. any chance you could optimize for making the app produce a nice app map, too?

bradygaster avatar Feb 08 '24 16:02 bradygaster

the app insights, I can make a pr on that, but don't have access to the preview 3 packages, should I request to merge into '02-end'?

pascostefan avatar Feb 10 '24 11:02 pascostefan

@pascostefan - Can you test this?

function Set-DotnetUserSecrets {
    param ($path, $lines)
    Push-Location
    cd $path
    dotnet user-secrets init
    dotnet user-secrets clear
    foreach ($line in $lines) {
        # Split the line at the first equal sign only
        $parts = $line -split '=', 2
        $name = $parts[0]
        $value = $parts[1]

        # Remove quotes from the value
        $value = $value -replace '"', ''
        
        # Replace double underscores with colon in the name
        $name = $name -replace '__', ':'

        # Set the secret if the value is not empty
        if ($value -ne '') {
            dotnet user-secrets set $name $value | Out-Null
        }
    }
    Pop-Location
}

jongio avatar Feb 12 '24 18:02 jongio

@jongio hi, yes tested, and it worked for me 👍

pascostefan avatar Feb 13 '24 17:02 pascostefan

Cool, do you want to do a PR with that code or should I?

jongio avatar Feb 14 '24 19:02 jongio

Please do 👍

pascostefan avatar Feb 14 '24 20:02 pascostefan

Here: https://github.com/bradygaster/AugmentR/pull/10

jongio avatar Mar 04 '24 20:03 jongio