From 61416e9b35083a6bb77bd4259011ad82b4249d7d Mon Sep 17 00:00:00 2001 From: Stuart Leeks Date: Wed, 7 Jan 2026 12:02:54 +0000 Subject: [PATCH 1/2] Add extensions option to the azd devcontainer feature to allow specifying extensions to install --- ext/devcontainer/Makefile | 12 +++++ .../src/azd/devcontainer-feature.json | 49 ++++++++++--------- ext/devcontainer/src/azd/install.sh | 13 +++++ ext/devcontainer/test/azd/scenarios.json | 10 ++++ ext/devcontainer/test/azd/with_extensions.sh | 17 +++++++ 5 files changed, 79 insertions(+), 22 deletions(-) create mode 100644 ext/devcontainer/Makefile create mode 100644 ext/devcontainer/test/azd/scenarios.json create mode 100644 ext/devcontainer/test/azd/with_extensions.sh diff --git a/ext/devcontainer/Makefile b/ext/devcontainer/Makefile new file mode 100644 index 00000000000..e6e2834f3cc --- /dev/null +++ b/ext/devcontainer/Makefile @@ -0,0 +1,12 @@ +.PHONY: test + +help: ## show this help + @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) \ + | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%s\033[0m|%s\n", $$1, $$2}' \ + | column -t -s '|' + +install-devcontainer-cli: + @if ! [ -x "$$(command -v devcontainer)" ]; then echo "Installing devcontainer CLI"; npm install -g @devcontainers/cli; else echo "devcontainer CLI is already installed"; fi + +test: install-devcontainer-cli ## run tests + devcontainer features test --base-image mcr.microsoft.com/devcontainers/base:ubuntu \ No newline at end of file diff --git a/ext/devcontainer/src/azd/devcontainer-feature.json b/ext/devcontainer/src/azd/devcontainer-feature.json index 57a6d8ed812..a4c7e2fd064 100644 --- a/ext/devcontainer/src/azd/devcontainer-feature.json +++ b/ext/devcontainer/src/azd/devcontainer-feature.json @@ -1,25 +1,30 @@ { - "id": "azd", - "version": "0.1.0", - "name": "Azure Developer CLI", - "documentationURL": "https://github.com/azure/azure-dev/tree/main/ext/devcontainer/src/azd", - "description": "Installs the Azure Developer CLI along with needed dependencies.", - "options": { - "version": { - "type": "string", - "proposals": [ - "stable" - ], - "default": "stable", - "description": "Select or enter an Azure Developer CLI version. (Available versions may vary by Linux distribution.)" - } + "id": "azd", + "version": "0.2.0", + "name": "Azure Developer CLI", + "documentationURL": "https://github.com/azure/azure-dev/tree/main/ext/devcontainer/src/azd", + "description": "Installs the Azure Developer CLI along with needed dependencies.", + "options": { + "version": { + "type": "string", + "proposals": [ + "stable" + ], + "default": "stable", + "description": "Select or enter an Azure Developer CLI version. (Available versions may vary by Linux distribution.)" }, - "customizations": { - "vscode": { - "extensions": [ - "ms-azuretools.vscode-bicep", - "ms-vscode.vscode-node-azure-pack" - ] - } + "extensions": { + "type": "string", + "default": "", + "description": "Optional comma separated list of Azure Developer CLI extensions to install." } - } \ No newline at end of file + }, + "customizations": { + "vscode": { + "extensions": [ + "ms-azuretools.vscode-bicep", + "ms-vscode.vscode-node-azure-pack" + ] + } + } +} \ No newline at end of file diff --git a/ext/devcontainer/src/azd/install.sh b/ext/devcontainer/src/azd/install.sh index 0a35250052a..43d8de5e447 100644 --- a/ext/devcontainer/src/azd/install.sh +++ b/ext/devcontainer/src/azd/install.sh @@ -5,6 +5,7 @@ #------------------------------------------------------------------------------------------------------------- AZD_VERSION=${VERSION:-"stable"} +AZD_EXTENSIONS=${EXTENSIONS} check_packages() { if ! dpkg -s "$@" > /dev/null 2>&1; then @@ -24,3 +25,15 @@ check_packages $(apt-cache search '^libicu[0-9]+$' | cut -d' ' -f1) echo "(*) Installing Azure Developer CLI" curl -fsSL https://aka.ms/install-azd.sh | bash -s -- --version $AZD_VERSION -a $(dpkg --print-architecture) + + +# If Azure CLI extensions are requested, loop through and install +if [ ${#AZD_EXTENSIONS[@]} -gt 0 ]; then + echo "Installing Azure Developer CLI extensions: ${AZD_EXTENSIONS}" + extensions=(`echo ${AZD_EXTENSIONS} | tr ',' ' '`) + for i in "${extensions[@]}" + do + echo "Installing ${i}" + su ${_REMOTE_USER} -c "azd extension install ${i}" || continue + done +fi \ No newline at end of file diff --git a/ext/devcontainer/test/azd/scenarios.json b/ext/devcontainer/test/azd/scenarios.json new file mode 100644 index 00000000000..d43a3506450 --- /dev/null +++ b/ext/devcontainer/test/azd/scenarios.json @@ -0,0 +1,10 @@ +{ + "with_extensions": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "azd": { + "extensions": "azure.coding-agent" + } + } + } +} \ No newline at end of file diff --git a/ext/devcontainer/test/azd/with_extensions.sh b/ext/devcontainer/test/azd/with_extensions.sh new file mode 100644 index 00000000000..f420d608108 --- /dev/null +++ b/ext/devcontainer/test/azd/with_extensions.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +check "version" azd version + +azd extension list --installed + +matching_extension_count=$(azd extension list --installed | grep "^azure.coding-agent" | wc -l) +check "check extensions" bash -c "test $matching_extension_count -eq 1" + +# Report result +reportResults From c2fce9c40052407188d06a38c2cd1864afd1742f Mon Sep 17 00:00:00 2001 From: Stuart Leeks Date: Wed, 7 Jan 2026 12:15:03 +0000 Subject: [PATCH 2/2] Review updates --- ext/devcontainer/Makefile | 2 +- ext/devcontainer/src/azd/README.md | 1 + ext/devcontainer/src/azd/install.sh | 8 ++++---- ext/devcontainer/test/azd/with_extensions.sh | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ext/devcontainer/Makefile b/ext/devcontainer/Makefile index e6e2834f3cc..aeb29296ae8 100644 --- a/ext/devcontainer/Makefile +++ b/ext/devcontainer/Makefile @@ -9,4 +9,4 @@ install-devcontainer-cli: @if ! [ -x "$$(command -v devcontainer)" ]; then echo "Installing devcontainer CLI"; npm install -g @devcontainers/cli; else echo "devcontainer CLI is already installed"; fi test: install-devcontainer-cli ## run tests - devcontainer features test --base-image mcr.microsoft.com/devcontainers/base:ubuntu \ No newline at end of file + devcontainer features test --base-image mcr.microsoft.com/devcontainers/base:ubuntu diff --git a/ext/devcontainer/src/azd/README.md b/ext/devcontainer/src/azd/README.md index 2369b507515..db8390e2f1c 100644 --- a/ext/devcontainer/src/azd/README.md +++ b/ext/devcontainer/src/azd/README.md @@ -27,6 +27,7 @@ Select a specific `azd` version [here](https://github.com/Azure/azure-dev/releas | Options Id | Description | Type | Default Value | |-----|-----|-----|-----| | version | Select or enter an Azure Developer CLI version. (Available versions may vary by Linux distribution.) | string | stable | +| extensions | Comma-separated list of Azure Developer CLI extensions to install. | string | (empty) | ## Customizations diff --git a/ext/devcontainer/src/azd/install.sh b/ext/devcontainer/src/azd/install.sh index 43d8de5e447..df4ed0ec0cf 100644 --- a/ext/devcontainer/src/azd/install.sh +++ b/ext/devcontainer/src/azd/install.sh @@ -27,13 +27,13 @@ echo "(*) Installing Azure Developer CLI" curl -fsSL https://aka.ms/install-azd.sh | bash -s -- --version $AZD_VERSION -a $(dpkg --print-architecture) -# If Azure CLI extensions are requested, loop through and install -if [ ${#AZD_EXTENSIONS[@]} -gt 0 ]; then +# If Azure Developer CLI extensions are requested, loop through and install +if [ -n "${AZD_EXTENSIONS}" ]; then echo "Installing Azure Developer CLI extensions: ${AZD_EXTENSIONS}" - extensions=(`echo ${AZD_EXTENSIONS} | tr ',' ' '`) + extensions=(`echo "${AZD_EXTENSIONS}" | tr ',' ' '`) for i in "${extensions[@]}" do echo "Installing ${i}" - su ${_REMOTE_USER} -c "azd extension install ${i}" || continue + su "${_REMOTE_USER}" -c "azd extension install ${i}" || continue done fi \ No newline at end of file diff --git a/ext/devcontainer/test/azd/with_extensions.sh b/ext/devcontainer/test/azd/with_extensions.sh index f420d608108..70389dd7357 100644 --- a/ext/devcontainer/test/azd/with_extensions.sh +++ b/ext/devcontainer/test/azd/with_extensions.sh @@ -11,7 +11,7 @@ check "version" azd version azd extension list --installed matching_extension_count=$(azd extension list --installed | grep "^azure.coding-agent" | wc -l) -check "check extensions" bash -c "test $matching_extension_count -eq 1" +check "check extensions" bash -c "test \"$matching_extension_count\" -eq 1" # Report result reportResults