Skip to content

Commit

Permalink
Update KubernetesKubectl
Browse files Browse the repository at this point in the history
Align to project code standards
  • Loading branch information
aaronparker committed Feb 28, 2024
1 parent 3073bf6 commit 2bb75df
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 67 deletions.
62 changes: 31 additions & 31 deletions Evergreen/Apps/Get-KubernetesKubectl.ps1
Original file line number Diff line number Diff line change
@@ -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
}
}
}
66 changes: 30 additions & 36 deletions Evergreen/Manifests/KubernetesKubectl.json
Original file line number Diff line number Diff line change
@@ -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": []
}
}
}

0 comments on commit 2bb75df

Please sign in to comment.