Unverified Commit eafa2828 authored by Paul Yu's avatar Paul Yu Committed by GitHub

Add new option to install azure-cli extensions (#165)

* Add new option for azure-cli extensions

* Update to install az extensions as $_REMOTE_USER

* Skip unknown extensions

* Change azure cli extension option type to string

* Adding test for azure-cli extensions
parent e00724a0
{
"id": "azure-cli",
"version": "1.0.5",
"version": "1.0.6",
"name": "Azure CLI",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/azure-cli",
"description": "Installs the Azure CLI along with needed dependencies. Useful for base Dockerfiles that often are missing required install dependencies like gpg.",
......@@ -12,16 +12,21 @@
],
"default": "latest",
"description": "Select or enter an Azure CLI version. (Available versions may vary by Linux distribution.)"
},
"extensions": {
"type": "string",
"default": "",
"description": "Optional comma separated list of Azure CLI extensions to install in profile."
}
},
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.azurecli"
]
}
"vscode": {
"extensions": [
"ms-vscode.azurecli"
]
}
},
"installsAfter": [
"ghcr.io/devcontainers/features/common-utils"
]
}
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ set -e
rm -rf /var/lib/apt/lists/*
AZ_VERSION=${VERSION:-"latest"}
AZ_EXTENSIONS=${EXTENSIONS}
MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc"
AZCLI_ARCHIVE_ARCHITECTURES="amd64"
......@@ -185,6 +186,17 @@ if [ "${use_pip}" = "true" ]; then
fi
fi
# If Azure CLI extensions are requested, loop through and install
if [ ${#AZ_EXTENSIONS[@]} -gt 0 ]; then
echo "Installing Azure CLI extensions: ${AZ_EXTENSIONS}"
extensions=(`echo ${AZ_EXTENSIONS} | tr ',' ' '`)
for i in "${extensions[@]}"
do
echo "Installing ${i}"
su ${_REMOTE_USER} -c "az extension add --name ${i} -y" || continue
done
fi
# Clean up
rm -rf /var/lib/apt/lists/*
......
#!/bin/bash
set -e
# Import test library for `check` command
source dev-container-features-test-lib
# Check to make sure the user is vscode
check "user is vscode" whoami | grep vscode
# Extension-specific tests
check "aks-preview" az extension show --name aks-preview
check "amg" az extension show --name amg
check "containerapp" az extension show --name containerapp
# Report result
reportResults
\ No newline at end of file
{
"install_extensions": {
"image": "ubuntu:focal",
"user": "vscode",
"features": {
"azure-cli": {
"version": "latest",
"extensions": "aks-preview,amg,containerapp"
}
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment