Copilot commented on code in PR #14033:
URL: https://github.com/apache/cloudstack/pull/14033#discussion_r4022511823


##########
scripts/installer/export-templates.sh:
##########
@@ -16,11 +16,23 @@
 # specific language governing permissions and limitations
 # under the License.
 
+# Kept in sync with CloudStackVersion.NEW_VERSIONING_CUTOVER_MAJOR_VERSION 
(utils module) and the
+# same constant in engine/schema/templateConfig.sh.
+NEW_VERSIONING_CUTOVER_MAJOR_VERSION=24
+
 METADATA_FILE="metadata.ini"
 IMAGE_PATH=${3:-"/usr/share/cloudstack-management/templates/systemvm/"}
 TEMPLATE_VERSION=$(awk -F "=" '/version/ {print $2}' 
${IMAGE_PATH}${METADATA_FILE} | xargs)
 TEMPLATE_PATH="/usr/share/cloudstack-management/templates/systemvm/"
-VERSION="${TEMPLATE_VERSION%.*}"
+TEMPLATE_MAJOR_VERSION="$(cut -d'.' -f1 <<<"$TEMPLATE_VERSION")"
+if [[ "$TEMPLATE_MAJOR_VERSION" -ge "$NEW_VERSIONING_CUTOVER_MAJOR_VERSION" 
]]; then
+  # New versioning (major.minor.security): the generated template files use 
the full version as-is.
+  VERSION="${TEMPLATE_VERSION}"
+else
+  # Legacy versioning (major.minor.patch.security): the generated template 
files drop the trailing
+  # security component.
+  VERSION="${TEMPLATE_VERSION%.*}"
+fi

Review Comment:
   The legacy branch still assumes every metadata version has four components. 
`templateConfig.sh` now deliberately emits `FULL_VERSION=4.23.1` for the valid 
three-component legacy form (the new smoke test covers this), so this expansion 
changes it to `4.23` and `export-templates.sh` looks for 
`systemvmtemplate-4.23-*` instead of the generated `systemvmtemplate-4.23.1-*`. 
Only strip the final component when the metadata value actually has four 
components; otherwise keep the three-component value unchanged.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to