[Ubuntu] Add select_by_arch helper and use it in build scripts#14190
Open
enescakir wants to merge 1 commit into
Open
[Ubuntu] Add select_by_arch helper and use it in build scripts#14190enescakir wants to merge 1 commit into
enescakir wants to merge 1 commit into
Conversation
Add a select_by_arch helper to images/ubuntu/scripts/helpers/os.sh that returns the caller-provided value for the current architecture, removing the duplicated x64/arm64 if/else blocks scattered across the build scripts. This is similar to the macOS get_arch helper in images/macos/scripts/helpers/utils.sh, but instead of returning a fixed arch string it lets the caller pass the value to return for each architecture, so the same helper covers the many different per-arch values (suffixes, URLs, asset names) the scripts need.
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR centralizes Ubuntu image architecture selection logic by introducing a shared helper and replacing repeated per-script is_x64/is_arm64 branching.
Changes:
- Added
select_by_archhelper toos.shfor choosing architecture-specific values. - Replaced duplicated
if is_x64 ... elif is_arm64 ...blocks across multiple install/config scripts withselect_by_arch(...)calls.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| images/ubuntu/scripts/helpers/os.sh | Adds shared select_by_arch helper used by build scripts. |
| images/ubuntu/scripts/build/install-yq.sh | Uses select_by_arch to select yq arch string. |
| images/ubuntu/scripts/build/install-terraform.sh | Uses select_by_arch to select Terraform arch string. |
| images/ubuntu/scripts/build/install-swift.sh | Uses select_by_arch for Swift release name and download URL selection. |
| images/ubuntu/scripts/build/install-pulumi.sh | Uses select_by_arch to select Pulumi arch string. |
| images/ubuntu/scripts/build/install-powershell.sh | Uses select_by_arch to select PowerShell arch string. |
| images/ubuntu/scripts/build/install-packer.sh | Uses select_by_arch to select Packer arch string. |
| images/ubuntu/scripts/build/install-oc-cli.sh | Uses select_by_arch to select oc client download URL. |
| images/ubuntu/scripts/build/install-ninja.sh | Uses select_by_arch to select Ninja asset name. |
| images/ubuntu/scripts/build/install-kubernetes-tools.sh | Uses select_by_arch to select tools arch string. |
| images/ubuntu/scripts/build/install-java-tools.sh | Uses select_by_arch to select Java arch string. |
| images/ubuntu/scripts/build/install-github-cli.sh | Uses select_by_arch to select GitHub CLI arch string. |
| images/ubuntu/scripts/build/install-firefox.sh | Uses select_by_arch to select Firefox driver arch string. |
| images/ubuntu/scripts/build/install-docker.sh | Uses select_by_arch to select Docker repo arch string. |
| images/ubuntu/scripts/build/install-cmake.sh | Uses select_by_arch to select CMake arch string. |
| images/ubuntu/scripts/build/install-azcopy.sh | Uses select_by_arch to select AzCopy download URL. |
| images/ubuntu/scripts/build/install-aws-tools.sh | Uses select_by_arch for multiple AWS-related architecture suffixes. |
| images/ubuntu/scripts/build/configure-image-data.sh | Uses select_by_arch to select image labels and URLs based on arch. |
Comment on lines
+51
to
+60
| select_by_arch() { | ||
| if is_x64; then | ||
| echo "$1" | ||
| elif is_arm64; then | ||
| echo "$2" | ||
| else | ||
| echo "Unsupported architecture" | ||
| exit 1 | ||
| fi | ||
| } |
| echo "Unsupported architecture" | ||
| exit 1 | ||
| fi | ||
| yq_arch=$(select_by_arch "amd64" "arm64") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a select_by_arch helper to images/ubuntu/scripts/helpers/os.sh that returns the caller-provided value for the current architecture, removing the duplicated x64/arm64 if/else blocks scattered across the build scripts.
This is similar to the macOS get_arch helper in
images/macos/scripts/helpers/utils.sh, but instead of returning a fixed arch string it lets the caller pass the value to return for each architecture, so the same helper covers the many different per-arch values (suffixes, URLs, asset names) the scripts need.
Description
Improvement
Related issue:
Check list