Skip to content

Commit

Permalink
Fix issue with PS type mismatch
Browse files Browse the repository at this point in the history
This commit fixes an issue which would be seen when the cni config file
was created with no content. When using the -replace operator with
$null, an empty object array was returned. This caused comparison issues
with the expected config as it was comparing an array with a string.
  • Loading branch information
sebsoto authored and openshift-cherrypick-robot committed Feb 5, 2024
1 parent 09678c7 commit a57a035
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pkg/nodeconfig/payload/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ $cni_template=$cni_template.Replace("provider_address",$provider_address)
# Compare CNI config with existing file, and replace if necessary
$existing_config=""
if(Test-Path -Path CNI_CONFIG_PATH) {
` + " $existing_config=((Get-Content -Path \"CNI_CONFIG_PATH\" -Raw) -Replace \"`r\",\"\")" + `
$config_file_content=(Get-Content -Path CNI_CONFIG_PATH -Raw)
if($config_file_content -ne $null) {
` + " $existing_config=$config_file_content.Replace(\"`r\",\"\")" + `
}
}
if($existing_config -ne $cni_template){
Set-Content -Path "CNI_CONFIG_PATH" -Value $cni_template -NoNewline
Expand Down
5 changes: 4 additions & 1 deletion pkg/nodeconfig/payload/payload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ $cni_template=$cni_template.Replace("provider_address",$provider_address)
# Compare CNI config with existing file, and replace if necessary
$existing_config=""
if(Test-Path -Path c:\k\cni.conf) {
` + " $existing_config=((Get-Content -Path \"c:\\k\\cni.conf\" -Raw) -Replace \"`r\",\"\")" + `
$config_file_content=(Get-Content -Path c:\k\cni.conf -Raw)
if($config_file_content -ne $null) {
` + " $existing_config=$config_file_content.Replace(\"`r\",\"\")" + `
}
}
if($existing_config -ne $cni_template){
Set-Content -Path "c:\k\cni.conf" -Value $cni_template -NoNewline
Expand Down

0 comments on commit a57a035

Please sign in to comment.