aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/azure-cli/devcontainer-feature.json2
-rwxr-xr-xsrc/azure-cli/install.sh56
-rw-r--r--test/azure-cli/install_bicep.sh2
-rw-r--r--test/azure-cli/install_extensions.sh2
-rw-r--r--test/azure-cli/install_extensions_bookworm.sh8
-rw-r--r--test/azure-cli/scenarios.json10
6 files changed, 67 insertions, 13 deletions
diff --git a/src/azure-cli/devcontainer-feature.json b/src/azure-cli/devcontainer-feature.json
index 9ab2cc3..901ba4f 100644
--- a/src/azure-cli/devcontainer-feature.json
+++ b/src/azure-cli/devcontainer-feature.json
@@ -1,6 +1,6 @@
{
"id": "azure-cli",
- "version": "1.0.8",
+ "version": "1.1.0",
"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.",
diff --git a/src/azure-cli/install.sh b/src/azure-cli/install.sh
index 31bc6d8..181d62f 100755
--- a/src/azure-cli/install.sh
+++ b/src/azure-cli/install.sh
@@ -25,6 +25,13 @@ if [ "$(id -u)" -ne 0 ]; then
exit 1
fi
+if [ -z "${_REMOTE_USER}" ]; then
+ echo -e 'Feature script must be executed by a tool that implements the dev container specification. See https://containers.dev/ for more information.'
+ exit 1
+fi
+
+echo "Effective REMOTE_USER: ${_REMOTE_USER}"
+
# Get central common setting
get_common_setting() {
if [ "${common_settings_file_loaded}" != "true" ]; then
@@ -57,8 +64,6 @@ check_packages() {
fi
}
-export DEBIAN_FRONTEND=noninteractive
-
# Soft version matching that resolves a version for a given package in the *current apt-cache*
# Return value is stored in first argument (the unprocessed version)
apt_cache_version_soft_match() {
@@ -127,7 +132,39 @@ install_using_apt() {
fi
}
-install_using_pip() {
+install_using_pip_strategy() {
+ local ver=""
+ if [ "${AZ_VERSION}" = "latest" ] || [ "${AZ_VERSION}" = "lts" ] || [ "${AZ_VERSION}" = "stable" ]; then
+ # Empty, meaning grab the "latest" in the apt repo
+ ver=""
+ else
+ ver="==${AZ_VERSION}"
+ fi
+
+ install_with_pipx "${ver}" || install_with_complete_python_installation "${ver}" || return 1
+}
+
+install_with_pipx() {
+ echo "(*) Attempting to install globally with pipx..."
+ local ver="$1"
+ export
+ local
+
+ if ! type pipx > /dev/null 2>&1; then
+ echo "(*) Installing pipx..."
+ check_packages pipx
+ pipx ensurepath # Ensures PIPX_BIN_DIR is on the PATH
+ fi
+
+ PIPX_HOME="/usr/local/pipx" \
+ PIPX_BIN_DIR=/usr/local/bin \
+ pipx install azure-cli${ver}
+
+ echo "(*) Finished installing globally with pipx."
+}
+
+install_with_complete_python_installation() {
+ local ver="$1"
echo "(*) No pre-built binaries available in apt-cache. Installing via pip3."
if ! dpkg -s python3-minimal python3-pip libffi-dev python3-venv > /dev/null 2>&1; then
apt_get_update
@@ -144,25 +181,20 @@ install_using_pip() {
pipx_bin=/tmp/pip-tmp/bin/pipx
fi
- if [ "${AZ_VERSION}" = "latest" ] || [ "${AZ_VERSION}" = "lts" ] || [ "${AZ_VERSION}" = "stable" ]; then
- # Empty, meaning grab the "latest" in the apt repo
- ver=""
- else
- ver="==${AZ_VERSION}"
- fi
-
set +e
${pipx_bin} install --pip-args '--no-cache-dir --force-reinstall' -f azure-cli${ver}
# Fail gracefully
if [ "$?" != 0 ]; then
- echo "Could not install azure-cli${ver} via pip"
+ echo "Could not install azure-cli${ver} via pip3"
rm -rf /tmp/pip-tmp
return 1
fi
set -e
}
+export DEBIAN_FRONTEND=noninteractive
+
# See if we're on x86_64 and if so, install via apt-get, otherwise use pip3
echo "(*) Installing Azure CLI..."
. /etc/os-release
@@ -176,7 +208,7 @@ fi
if [ "${use_pip}" = "true" ]; then
AZ_VERSION=${CACHED_AZURE_VERSION}
- install_using_pip
+ install_using_pip_strategy
if [ "$?" != 0 ]; then
echo "Please provide a valid version for your distribution ${ID} ${VERSION_CODENAME} (${architecture})."
diff --git a/test/azure-cli/install_bicep.sh b/test/azure-cli/install_bicep.sh
index 955507f..0430c64 100644
--- a/test/azure-cli/install_bicep.sh
+++ b/test/azure-cli/install_bicep.sh
@@ -8,6 +8,8 @@ source dev-container-features-test-lib
# Check to make sure the user is vscode
check "user is vscode" whoami | grep vscode
+check "version" az --version
+
# Bicep-specific tests
check "bicep" bicep --version
check "az bicep" az bicep version
diff --git a/test/azure-cli/install_extensions.sh b/test/azure-cli/install_extensions.sh
index 1e66e26..58d1cff 100644
--- a/test/azure-cli/install_extensions.sh
+++ b/test/azure-cli/install_extensions.sh
@@ -8,6 +8,8 @@ source dev-container-features-test-lib
# Check to make sure the user is vscode
check "user is vscode" whoami | grep vscode
+check "version" az --version
+
# Extension-specific tests
check "aks-preview" az extension show --name aks-preview
check "amg" az extension show --name amg
diff --git a/test/azure-cli/install_extensions_bookworm.sh b/test/azure-cli/install_extensions_bookworm.sh
new file mode 100644
index 0000000..3c281e6
--- /dev/null
+++ b/test/azure-cli/install_extensions_bookworm.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+set -e
+
+# Import test library for `check` command
+source dev-container-features-test-lib
+
+./install_extensions.sh \ No newline at end of file
diff --git a/test/azure-cli/scenarios.json b/test/azure-cli/scenarios.json
index cc1fd75..2313452 100644
--- a/test/azure-cli/scenarios.json
+++ b/test/azure-cli/scenarios.json
@@ -9,6 +9,16 @@
}
}
},
+ "install_extensions_bookworm": {
+ "image": "mcr.microsoft.com/devcontainers/base:bookworm",
+ "user": "vscode",
+ "features": {
+ "azure-cli": {
+ "version": "latest",
+ "extensions": "aks-preview,amg,containerapp"
+ }
+ }
+ },
"install_bicep": {
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"user": "vscode",