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 @@ -122,6 +122,16 @@ if (($collection -like '*puppetcore*-nightly*') -And -Not ($PSBoundParameters.Co
122122 $windows_source = ' https://nightlies.puppet.com/downloads'
123123} elseif (($collection -like ' *puppetcore*' ) -And -Not ($PSBoundParameters.ContainsKey (' windows_source' ))) {
124124 $windows_source = ' https://artifacts-puppetcore.puppet.com/v1/download'
125+
126+ # Puppetcore requires a version to be specified, so we will use the latest version if not specified.
127+ # Or if the version is set to "latest".
128+ if ($version -eq " " || ! $version || $version -eq " latest" ) {
129+ $response = Invoke-WebRequest - Uri " https://forgeapi.puppet.com/private/versions/puppet-agent" - UseBasicParsing
130+ $jsonData = $response.Content | ConvertFrom-Json
131+ $allVersions = $jsonData.PSObject.Properties.Name
132+ $version8x = $allVersions | Where-Object { $_ -like " 8.*" }
133+ $version = $version8x | Sort-Object { [Version ]$_ } | Select-Object - Last 1
134+ }
125135}
126136
127137if ($absolute_source ) {
@@ -133,6 +143,7 @@ if ($absolute_source) {
133143 } else {
134144 $dev = ' '
135145 }
146+
136147 $msi_source = " ${windows_source} ?type=native&version=${version} &os_name=windows&os_version=${major_os_version} &os_arch=${arch} &fips=${fips}${dev} "
137148} elseif ($collection -like ' puppetcore*-nightly' ) {
138149 $core_collection = $collection -replace " core" , " "
Original file line number Diff line number Diff line change @@ -830,24 +830,33 @@ case $platform in
830830 " mac_os_x" )
831831 info " Mac platform! Lets get you a DMG..."
832832 filetype=" dmg"
833- if test " $version " = " latest" ; then
834- filename=" puppet-agent-latest.dmg"
835- else
836- filename=" puppet-agent-${version} -1.osx${platform_version} .dmg"
837- fi
838-
839833 arch=" x86_64"
840834 if [[ $( uname -p) == " arm" ]]; then
841835 arch=" arm64"
842836 fi
843837 if [[ " $collection " =~ " puppetcore" ]]; then
838+ # Puppetcore requires a version to be specified, so we will use the latest version if not specified.
839+ # Or if the version is set to "latest".
840+ if [[ -z " $version " || " $version " == " latest" ]]; then
841+ version=$( curl -sL https://forgeapi.puppet.com/private/versions/puppet-agent | \
842+ jq -r ' keys_unsorted |
843+ map(select(startswith("8."))) |
844+ max_by(split(".") | map(tonumber))' )
845+ fi
846+
844847 dots=$( echo " ${version} " | grep -o ' \.' | wc -l)
845848 if (( dots >= 3 )) ; then
846- download_url=" ${mac_source} ?version=${version} &os_name=osx&os_version=${platform_version} &os_arch=${arch} &dev=true"
849+ download_url=" ${mac_source} ?type=native& version=${version} &os_name=osx&os_version=${platform_version} &os_arch=${arch} &dev=true"
847850 else
848- download_url=" ${mac_source} ?version=${version} &os_name=osx&os_version=${platform_version} &os_arch=${arch} "
851+ download_url=" ${mac_source} ?type=native& version=${version} &os_name=osx&os_version=${platform_version} &os_arch=${arch} "
849852 fi
850853 else
854+ if test " $version " = " latest" ; then
855+ filename=" puppet-agent-latest.dmg"
856+ else
857+ filename=" puppet-agent-${version} -1.osx${platform_version} .dmg"
858+ fi
859+
851860 download_url=" ${mac_source} /mac/${collection} /${platform_version} /${arch} /${filename} "
852861 fi
853862 ;;
You can’t perform that action at this time.
0 commit comments