Just "grep" what we're after

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2023-09-11 20:21:39 +01:00
parent 5a89789ba7
commit 2425620013
No known key found for this signature in database
GPG key ID: BB36BF6584A298FF
2 changed files with 4 additions and 10 deletions

View file

@ -107,11 +107,8 @@ if ( [String]::IsNullOrEmpty($Version) ) {
$yaml = Get-Content -Path "$PROJECT_DIR\cicd\shared-gh-workflows-context.yml"
$dict_versions = @{}
$yaml | ForEach-Object {
if ( $_.Name.Trim().EndsWith(":") ) { return } # This is likely a nested structure
$val1, $val2 = $_ -split ": "
$dict_versions[$val1] = $val2.Trim("""")
}
$dict_versions["python_version"]=($yaml | Select-String -Pattern "python_version: (.*)").matches.groups[1].Value.Trim("""")
$dict_versions["relenv_version"]=($yaml | Select-String -Pattern "relenv_version: (.*)").matches.groups[1].Value.Trim("""")
if ( [String]::IsNullOrEmpty($PythonVersion) ) {
$PythonVersion = $dict_versions["python_version"]

View file

@ -77,11 +77,8 @@ function Write-Result($result, $ForegroundColor="Green") {
$yaml = Get-Content -Path "$PROJECT_DIR\cicd\shared-gh-workflows-context.yml"
$dict_versions = @{}
$yaml | ForEach-Object {
if ( $_.Name.Trim().EndsWith(":") ) { return } # This is likely a nested structure
$val1, $val2 = $_ -split ": "
$dict_versions[$val1] = $val2.Trim("""")
}
$dict_versions["python_version"]=($yaml | Select-String -Pattern "python_version: (.*)").matches.groups[1].Value.Trim("""")
$dict_versions["relenv_version"]=($yaml | Select-String -Pattern "relenv_version: (.*)").matches.groups[1].Value.Trim("""")
if ( [String]::IsNullOrEmpty($Version) ) {
$Version = $dict_versions["python_version"]