File tree Expand file tree Collapse file tree 2 files changed +28
-8
lines changed Expand file tree Collapse file tree 2 files changed +28
-8
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,16 @@ if (($collection -like '*nightly*') -And -Not ($PSBoundParameters.ContainsKey('w
120120 $windows_source = ' https://nightlies.puppet.com/downloads'
121121} elseif (($collection -like ' *puppetcore*' ) -And -Not ($PSBoundParameters.ContainsKey (' windows_source' ))) {
122122 $windows_source = ' https://artifacts-puppetcore.puppet.com/v1/download'
123+
124+ # Puppetcore requires a version to be specified, so we will use the latest version if not specified.
125+ # Or if the version is set to "latest".
126+ if ($version -eq " " || ! $version || $version -eq " latest" ) {
127+ $response = Invoke-WebRequest - Uri " https://forgeapi.puppet.com/private/versions/puppet-agent" - UseBasicParsing
128+ $jsonData = $response.Content | ConvertFrom-Json
129+ $allVersions = $jsonData.PSObject.Properties.Name
130+ $version8x = $allVersions | Where-Object { $_ -like " 8.*" }
131+ $version = $version8x | Sort-Object { [Version ]$_ } | Select-Object - Last 1
132+ }
123133}
124134
125135if ($absolute_source ) {
@@ -131,6 +141,7 @@ if ($absolute_source) {
131141 } else {
132142 $dev = ' '
133143 }
144+
134145 $msi_source = " ${windows_source} ?type=native&version=${version} &os_name=windows&os_version=${major_os_version} &os_arch=${arch} &fips=${fips}${dev} "
135146} else {
136147 $msi_source = " $windows_source /windows/${collection} /${msi_name} "
Original file line number Diff line number Diff line change @@ -823,24 +823,33 @@ case $platform in
823823 " mac_os_x" )
824824 info " Mac platform! Lets get you a DMG..."
825825 filetype=" dmg"
826- if test " $version " = " latest" ; then
827- filename=" puppet-agent-latest.dmg"
828- else
829- filename=" puppet-agent-${version} -1.osx${platform_version} .dmg"
830- fi
831-
832826 arch=" x86_64"
833827 if [[ $( uname -p) == " arm" ]]; then
834828 arch=" arm64"
835829 fi
836830 if [[ " $collection " =~ " puppetcore" ]]; then
831+ # Puppetcore requires a version to be specified, so we will use the latest version if not specified.
832+ # Or if the version is set to "latest".
833+ if [[ -z " $version " || " $version " == " latest" ]]; then
834+ version=$( curl -sL https://forgeapi.puppet.com/private/versions/puppet-agent | \
835+ jq -r ' keys_unsorted |
836+ map(select(startswith("8."))) |
837+ max_by(split(".") | map(tonumber))' )
838+ fi
839+
837840 dots=$( echo " ${version} " | grep -o ' \.' | wc -l)
838841 if (( dots >= 3 )) ; then
839- download_url=" ${mac_source} ?version=${version} &os_name=osx&os_version=${platform_version} &os_arch=${arch} &dev=true"
842+ download_url=" ${mac_source} ?type=native& version=${version} &os_name=osx&os_version=${platform_version} &os_arch=${arch} &dev=true"
840843 else
841- download_url=" ${mac_source} ?version=${version} &os_name=osx&os_version=${platform_version} &os_arch=${arch} "
844+ download_url=" ${mac_source} ?type=native& version=${version} &os_name=osx&os_version=${platform_version} &os_arch=${arch} "
842845 fi
843846 else
847+ if test " $version " = " latest" ; then
848+ filename=" puppet-agent-latest.dmg"
849+ else
850+ filename=" puppet-agent-${version} -1.osx${platform_version} .dmg"
851+ fi
852+
844853 download_url=" ${mac_source} /mac/${collection} /${platform_version} /${arch} /${filename} "
845854 fi
846855 ;;
You can’t perform that action at this time.
0 commit comments