Skip to content

Commit

Permalink
[crc-support] fix: issues evaluating params to run remote scripts on …
Browse files Browse the repository at this point in the history
…non linux envs.

    This commit also fix the pusher issue with the task filename

Signed-off-by: Adrian Riobo <[email protected]>
  • Loading branch information
adrianriobo committed Nov 29, 2024
1 parent bdd8706 commit f70da47
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 24 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/crc-support-pusher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ jobs:
curl -LO "https://github.com/tektoncd/cli/releases/download/v${TKN_VERSION}/tkn_${TKN_VERSION}_Linux_x86_64.tar.gz"
tar xvzf "tkn_${TKN_VERSION}_Linux_x86_64.tar.gz" tkn
./tkn bundle push ${{ env.image }}-tkn \
-f crc-support-installer.yaml \
-f crc-support.yaml
-f task.yaml
29 changes: 10 additions & 19 deletions crc-support/oci/lib/windows/run.ps1
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
aBaseURL=''
aName=''
aSHAName='sha256sum.txt'
targetPath=''
freshEnv='true'
download='true'
install='false'


param(
[Parameter(HelpMessage='download base url')]
$aBaseURL,
[Parameter(HelpMessage='asset name to be downloaded')]
$aName,
[Parameter(HelpMessage='shasumFile file name Default value: sha256sum.txt')]
$aSHAName="sha256sum.txt",
$aSHAName='sha256sum.txt',
[Parameter(Mandatory,HelpMessage='target folder for download')]
$targetPath,
[Parameter(HelpMessage='force fresh, remove any previous existing instance for crc. Default False')]
$forceFresh='false',
$freshEnv='false',
[Parameter(HelpMessage='download if False not download. Default True')]
$download='true',
[Parameter(HelpMessage='install after downloading if False not install. Default False')]
Expand All @@ -32,7 +23,7 @@ function Force-Fresh-Environment {
# Wait to be cleared before uninstalling
Pause-Until-Other-Installations-Finish
pushd $latestPath
Start-Process C:\Windows\System32\msiexec.exe -ArgumentList "/qb /x crc-windows-${arch}.msi /norestart" -wait
Start-Process C:\Windows\System32\msiexec.exe -ArgumentList "/qb /x crc-windows-amd64.msi /norestart" -wait
popd
}
Start-Process powershell -Verb runAs -ArgumentList "Remove-Item -Recurse -Force $HOME\.crc"
Expand All @@ -41,11 +32,11 @@ function Force-Fresh-Environment {
}

function Require-Download {
if (!(Test-Path $downloadItemName)) {
if (!(Test-Path $aName)) {
return $true
}
$hashValue=Get-FileHash $downloadItemName | Select-Object -ExpandProperty Hash
$hashMatch=Select-String $shasumFile -Pattern $hashValue -Quiet
$hashValue=Get-FileHash $aName | Select-Object -ExpandProperty Hash
$hashMatch=Select-String $aSHAName -Pattern $hashValue -Quiet
return !$hashMatch
}

Expand All @@ -59,8 +50,8 @@ function Download ($binaryURL) {
}

function Check-Download() {
$hashValue=Get-FileHash $downloadItemName | Select-Object -ExpandProperty Hash
$hashMatch=Select-String $shasumFile -Pattern $hashValue -Quiet
$hashValue=Get-FileHash $aName | Select-Object -ExpandProperty Hash
$hashMatch=Select-String $aSHAName -Pattern $hashValue -Quiet
return $hashMatch
}

Expand All @@ -87,10 +78,10 @@ $latestPath="$HOME\OpenshiftLocal\crc\latest"
# Transform params to bool
$install = If ($install -eq 'true') {$true} Else {$false}
$download = If ($download -eq 'true') {$true} Else {$false}
$forceFresh = If ($forceFresh -eq 'true') {$true} Else {$false}
$freshEnv = If ($freshEnv -eq 'true') {$true} Else {$false}

# FORCE FRESH
if ($forceFresh) {
if ($freshEnv) {
Force-Fresh-Environment
}

Expand Down
5 changes: 2 additions & 3 deletions crc-support/tkn/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ spec:
runner="run.ps1"
fi
# Path for assets on remote target
tPath='/Users/${TARGET_HOST_USERNAME}/OpenshiftLocal'
tPath="/Users/${TARGET_HOST_USERNAME}/OpenshiftLocal"
if [[ $(params.os) == 'linux' ]]; then
tPath="/home/${TARGET_HOST_USERNAME}/OpenshiftLocal"
fi
Expand All @@ -114,7 +114,7 @@ spec:
nameArr=(${name//_/ })
tPath+="/bundle/${nameArr[2]}"
else
tPath+='/crc/$(params.crc-version)'
tPath+="/crc/$(params.crc-version)"
fi
Expand All @@ -125,7 +125,6 @@ spec:
cmd+="-freshEnv $(params.force-fresh) "
cmd+="-download $(params.download) "
cmd+="-install $(params.install) "
cmd+="-debug $(params.debug) "
# Exec
. entrypoint.sh "${cmd}"
Expand Down

0 comments on commit f70da47

Please sign in to comment.