I am currently sending in a list of key value variables from octopus to my project into my prompt. These are read and set in my environment by the code below.
$testKeys = $OctopusParameters.keys | Where-Object {$_ -like "test.env.*"}
ForEach ($key in $testKeys)
{
$value = $OctopusParameters[$key]
$name = $key.subString(9) # remove test.env prefix
$kubectlArgs += "--env=`"$name=$value`""
}
This is coming back as follows:
> --env="ASPNETCORE_ENVIRONMENT=integration"
> --env="ConnectionStrings__MongoDB=my mongo connectgion string"
> --env="ServiceConfiguration__MyJSONObjectConfiguration=[ {'MyID': 23, 'URL': 'http://google.com/', 'User': 'MyUser',
> 'Password': 'test', 'Domain': 'MyDomain', 'Key': 'myKey'} ]"
So as you can see, this works perfectly when it is a one to one, key = string value. The problem is that for the serviceConfiguration I am passing in a JSON object.
My code is grabbing the values I need like so
"ServiceConfiguration:MyJSONObjectConfiguration:0"
How do I configure me PS1 script to treat the serviceConfiguration as JSON object and not a string? Is it even possible?
PS1is a string, it can contain some escape sequences to display special values, but it doesn't know anything about JSON.