Skip to content

Commit

Permalink
(kubernetes-cli) Updates to use GitHub REST API for ChangeLog Retrieval
Browse files Browse the repository at this point in the history
This improves performance for updating this package from ~164 seconds to ~86.
  • Loading branch information
JPRuskin committed Jul 4, 2024
1 parent 48f08b7 commit 675ea2b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions automatic/kubernetes-cli/update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ param($IncludeStream, [switch] $Force)

Import-Module Chocolatey-AU

$changelogs = 'https://raw.githubusercontent.com/kubernetes/kubernetes/master/CHANGELOG/README.md'
$changelogRepository = @{
Owner = 'kubernetes'
Repository = 'kubernetes'
}

function global:au_BeforeUpdate { Get-RemoteFiles -Purge -NoSuffix }

Expand All @@ -27,7 +30,7 @@ function global:au_SearchReplace {
function global:au_GetLatest {
# Only report the supported Kubernetes streams.

$changelogs = (Invoke-WebRequest -Uri $changelogs -UseBasicParsing).content
$changelogs = Get-GitHubRepositoryFileContent @changelogRepository CHANGELOG/README.md

# There is quite a few versions that do not exist on chocolatey.org
# and since the limit of pushed packages is 10, we need to limit the amount
Expand All @@ -45,8 +48,8 @@ function global:au_GetLatest {
continue
}

$minor_changelog_page = Invoke-WebRequest -UseBasicParsing -Uri "https://raw.githubusercontent.com/kubernetes/kubernetes/master/CHANGELOG/CHANGELOG-$($minor_version).md"
$url64 = $minor_changelog_page.content `
$minor_changelog_page = Get-GitHubRepositoryFileContent @changelogRepository "CHANGELOG/CHANGELOG-$($minor_version).md"
$url64 = $minor_changelog_page `
| Select-String -Pattern "(?<=\[.+\]\()(?<href>.+/v(?<version>\d+(\.\d+)+)/kubernetes-client-windows-amd64\.tar\.gz)\)" `
| ForEach-Object {$_.Matches.Groups.Where{$_.Name -eq 'href'}.value} `
| Select-Object -First 1
Expand All @@ -59,7 +62,7 @@ function global:au_GetLatest {
$patch_version = $matches.version
}

$url32 = $minor_changelog_page.content `
$url32 = $minor_changelog_page `
| Select-String -Pattern "(?<=\[.+\]\()(?<href>.+/v(?<version>\d+(\.\d+)+)/kubernetes-client-windows-386\.tar\.gz)\)" `
| ForEach-Object {$_.Matches.Groups.Where{$_.Name -eq 'href'}.value} `
| Select-Object -First 1
Expand Down

0 comments on commit 675ea2b

Please sign in to comment.