From e479e41aeee3b95e778d0d7e77b3c5de8d8e260c Mon Sep 17 00:00:00 2001 From: itsconquest Date: Thu, 24 Sep 2020 19:19:41 +1200 Subject: [PATCH] feat(ci): add missing powershell scripts & fix related grunt code (#4345) * feat(ci): add missing powershell scripts & fix related grunt code * feat(ci): download binaries direct to dist directory * feat(ci): correctly pass in binary versions * feat(ci): fix powershell errors * feat(ci): fix cmdlet syntax * feat(ci): fix typo * feat(ci): fix additonal typo --- build/download_kompose_binary.ps1 | 7 +++++++ build/download_kubectl_binary.ps1 | 7 +++++++ gruntfile.js | 19 +++++++++++-------- 3 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 build/download_kompose_binary.ps1 create mode 100644 build/download_kubectl_binary.ps1 diff --git a/build/download_kompose_binary.ps1 b/build/download_kompose_binary.ps1 new file mode 100644 index 000000000..4c6246d00 --- /dev/null +++ b/build/download_kompose_binary.ps1 @@ -0,0 +1,7 @@ +param ( + [string]$kompose_version +) + +$ErrorActionPreference = "Stop"; + +Invoke-WebRequest -O "dist/kompose.exe" "https://github.com/kubernetes/kompose/releases/download/$($kompose_version)/kompose-windows-amd64.exe" diff --git a/build/download_kubectl_binary.ps1 b/build/download_kubectl_binary.ps1 new file mode 100644 index 000000000..fe12c8273 --- /dev/null +++ b/build/download_kubectl_binary.ps1 @@ -0,0 +1,7 @@ +param ( + [string]$kubectl_version +) + +$ErrorActionPreference = "Stop"; + +Invoke-WebRequest -O "dist/kubectl.exe" "https://storage.googleapis.com/kubernetes-release/release/$($kubectl_version)/bin/windows/amd64/kubectl.exe" diff --git a/gruntfile.js b/gruntfile.js index 37c095e8f..c9da104db 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -194,8 +194,9 @@ function shell_download_docker_binary(p, a) { return ['if [ -f dist/docker ]; then', 'echo "docker binary exists";', 'else', 'build/download_docker_binary.sh ' + ip + ' ' + ia + ' ' + binaryVersion + ';', 'fi'].join(' '); } else { return [ - 'powershell -Command "& {if (Get-Item -Path dist/docker.exe -ErrorAction:SilentlyContinue) {', - 'Write-Host "Docker binary exists"', + 'powershell -Command "& {if (Test-Path -Path "dist/docker.exe") {', + 'Write-Host "Skipping download, Docker binary exists"', + 'return', '} else {', '& ".\\build\\download_docker_binary.ps1" -docker_version ' + binaryVersion + '', '}}"', @@ -210,10 +211,11 @@ function shell_download_kompose_binary(p, a) { return ['if [ -f dist/kompose ]; then', 'echo "kompose binary exists";', 'else', 'build/download_kompose_binary.sh ' + p + ' ' + a + ' ' + binaryVersion + ';', 'fi'].join(' '); } else { return [ - 'powershell -Command "& {if (Get-Item -Path dist/kompose.exe -ErrorAction:SilentlyContinue) {', - 'Write-Host "Docker binary exists"', + 'powershell -Command "& {if (Test-Path -Path "dist/kompose.exe") {', + 'Write-Host "Skipping download, Kompose binary exists"', + 'return', '} else {', - '& ".\\build\\download_kompose_binary.ps1" -docker_version ' + binaryVersion + '', + '& ".\\build\\download_kompose_binary.ps1" -kompose_version ' + binaryVersion + '', '}}"', ].join(' '); } @@ -226,10 +228,11 @@ function shell_download_kubectl_binary(p, a) { return ['if [ -f dist/kubectl ]; then', 'echo "kubectl binary exists";', 'else', 'build/download_kubectl_binary.sh ' + p + ' ' + a + ' ' + binaryVersion + ';', 'fi'].join(' '); } else { return [ - 'powershell -Command "& {if (Get-Item -Path dist/kubectl.exe -ErrorAction:SilentlyContinue) {', - 'Write-Host "Docker binary exists"', + 'powershell -Command "& {if (Test-Path -Path "dist/kubectl.exe") {', + 'Write-Host "Skipping download, Kubectl binary exists"', + 'return', '} else {', - '& ".\\build\\download_kubectl_binary.ps1" -docker_version ' + binaryVersion + '', + '& ".\\build\\download_kubectl_binary.ps1" -kubectl_version ' + binaryVersion + '', '}}"', ].join(' '); }