Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new option to install azure-cli extensions #165

Merged
merged 5 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/azure-cli/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"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.",
Expand All @@ -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"
]
}
}
12 changes: 12 additions & 0 deletions src/azure-cli/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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/*

Expand Down
17 changes: 17 additions & 0 deletions test/azure-cli/install_extensions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/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
12 changes: 12 additions & 0 deletions test/azure-cli/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"install_extensions": {
"image": "ubuntu:focal",
"user": "vscode",
"features": {
"azure-cli": {
"version": "latest",
"extensions": "aks-preview,amg,containerapp"
}
}
}
}