Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: install.ps1 The variable '$AIRGAP_CHECKSUMS_URL' cannot be retrieved because it has not been set #1804

Closed
rgl opened this issue Sep 10, 2021 · 1 comment

Comments

@rgl
Copy link
Contributor

rgl commented Sep 10, 2021

The following code uses an unknown variable:

$AIRGAP_CHECKSUM_EXPECTED = Get-AirgapChecksums -CommitHash $Commit -AirgapChecksumsUrl $AIRGAP_CHECKSUMS_URL -StorageUrl $STORAGE_URL -TempAirgapChecksums $TMP_AIRGAP_CHECKSUMS

I was able to catch this because my powershell is in strict-mode.

To catch these kind of problems, I would modify this script to have something alike:

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
trap {
    Write-Host "ERROR: $_"
    Write-Host (($_.ScriptStackTrace -split '\r?\n') -replace '^(.*)$','ERROR: $1')
    Write-Host (($_.Exception.ToString() -split '\r?\n') -replace '^(.*)$','ERROR EXCEPTION: $1')
    Exit 1
}
@brandond
Copy link
Contributor

cc @phillipsj @rosskirkpat

rgl added a commit to rgl/rke2 that referenced this issue Sep 11, 2021
this allows for better error handling/reporting like mentioned in rancher#1804
rgl added a commit to rgl/rke2 that referenced this issue Sep 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants