From 2bb75df319593055d49c51a16593ae4a1f6a5e7f Mon Sep 17 00:00:00 2001 From: Aaron Parker Date: Thu, 29 Feb 2024 09:15:18 +1100 Subject: [PATCH] Update KubernetesKubectl Align to project code standards --- Evergreen/Apps/Get-KubernetesKubectl.ps1 | 62 ++++++++++---------- Evergreen/Manifests/KubernetesKubectl.json | 66 ++++++++++------------ 2 files changed, 61 insertions(+), 67 deletions(-) diff --git a/Evergreen/Apps/Get-KubernetesKubectl.ps1 b/Evergreen/Apps/Get-KubernetesKubectl.ps1 index 8d14e5ac..2ebd0cb2 100644 --- a/Evergreen/Apps/Get-KubernetesKubectl.ps1 +++ b/Evergreen/Apps/Get-KubernetesKubectl.ps1 @@ -1,31 +1,31 @@ -Function Get-KubernetesKubectl { - <# - .SYNOPSIS - Returns the available Kubernetes Kubectl versions. - - .NOTES - Author: BornToBeRoot - Twitter: @_BornToBeRoot - #> - [OutputType([System.Management.Automation.PSObject])] - [CmdletBinding(SupportsShouldProcess = $False)] - param ( - [Parameter(Mandatory = $False, Position = 0)] - [ValidateNotNull()] - [System.Management.Automation.PSObject] - $res = (Get-FunctionResource -AppName ("$($MyInvocation.MyCommand)".Split("-"))[1]) - ) - - # Get the latest version for kubectl - $Version = Invoke-RestMethod -Uri $res.Get.Update.Uri - - # Build the download links for each platform & architecture - foreach ($DownloadUri in $res.Get.Download.Uri.GetEnumerator()) { - [pscustomobject] @{ - Version = $Version - Architecture = $DownloadUri.Name.Split("_")[1] - Platform = $DownloadUri.Name.Split("_")[0] - URI = $DownloadUri.Value -replace $res.Get.Download.ReplaceVersionText, $Version - } - } -} +function Get-KubernetesKubectl { + <# + .SYNOPSIS + Returns the available Kubernetes Kubectl versions. + + .NOTES + Author: BornToBeRoot + Twitter: @_BornToBeRoot + #> + [OutputType([System.Management.Automation.PSObject])] + [CmdletBinding(SupportsShouldProcess = $False)] + param ( + [Parameter(Mandatory = $False, Position = 0)] + [ValidateNotNull()] + [System.Management.Automation.PSObject] + $res = (Get-FunctionResource -AppName ("$($MyInvocation.MyCommand)".Split("-"))[1]) + ) + + # Get the latest version for kubectl + $Version = Invoke-RestMethod -Uri $res.Get.Update.Uri + + # Build the download links for each platform & architecture + foreach ($DownloadUri in $res.Get.Download.Uri.GetEnumerator()) { + [PSCustomObject] @{ + Version = $Version + Architecture = $DownloadUri.Name.Split("_")[1] + Platform = $DownloadUri.Name.Split("_")[0] + URI = $DownloadUri.Value -replace $res.Get.Download.ReplaceVersionText, $Version + } + } +} diff --git a/Evergreen/Manifests/KubernetesKubectl.json b/Evergreen/Manifests/KubernetesKubectl.json index 05436fc2..56368087 100644 --- a/Evergreen/Manifests/KubernetesKubectl.json +++ b/Evergreen/Manifests/KubernetesKubectl.json @@ -1,36 +1,30 @@ -{ - "Name": "Kubernetes Kubectl", - "Source": "https://kubernetes.io/", - "Get": { - "Update": { - "Uri": "https://cdn.dl.k8s.io/release/stable.txt" - }, - "Download": { - "Uri": { - "Windows_x64": "https://dl.k8s.io/release/#version/bin/windows/amd64/kubectl.exe", - "Windows_x86": "https://dl.k8s.io/release/#version/bin/windows/386/kubectl.exe", - "Windows_arm64": "https://dl.k8s.io/release/#version/bin/windows/arm64/kubectl.exe", - "Linux_x64": "https://dl.k8s.io/release/#version/bin/linux/amd64/kubectl", - "Linux_arm64": "https://dl.k8s.io/release/#version/bin/linux/arm64/kubectl", - "Darwin_x64": "https://dl.k8s.io/release/#version/bin/darwin/amd64/kubectl", - "Darwin_arm64": "https://dl.k8s.io/release/#version/bin/darwin/arm64/kubectl" - }, - "ReplaceVersionText": "#version" - } - }, - "Install": { - "Setup": { - "Windows": "kubectl.exe", - "Linux" : "kubectl", - "Darwin" : "kubectl" - }, - "Physical": { - "Arguments": "", - "PostInstall": [] - }, - "Virtual": { - "Arguments": "", - "PostInstall": [] - } - } -} +{ + "Name": "Kubernetes Kubectl", + "Source": "https://kubernetes.io/", + "Get": { + "Update": { + "Uri": "https://cdn.dl.k8s.io/release/stable.txt" + }, + "Download": { + "Uri": { + "Windows_x64": "https://dl.k8s.io/release/#version/bin/windows/amd64/kubectl.exe", + "Windows_x86": "https://dl.k8s.io/release/#version/bin/windows/386/kubectl.exe", + "Windows_arm64": "https://dl.k8s.io/release/#version/bin/windows/arm64/kubectl.exe" + }, + "ReplaceVersionText": "#version" + } + }, + "Install": { + "Setup": { + "Windows": "kubectl.exe" + }, + "Physical": { + "Arguments": "", + "PostInstall": [] + }, + "Virtual": { + "Arguments": "", + "PostInstall": [] + } + } +}