From b98f5a164be78317af27118e9491d38c17eb16a4 Mon Sep 17 00:00:00 2001 From: Gaurav Saini <147703805+gauravsaini04@users.noreply.github.com> Date: Wed, 17 Apr 2024 04:28:57 +0530 Subject: [PATCH] [az-cli] - To separate the two methods of installation - using apt, using python (#922) * [az-cli] - To separate the two methods of installation - apt & python * bump patch version * changes as requested by review comments * no need to keep * added test script missing * changes for review comment --- src/azure-cli/devcontainer-feature.json | 2 +- src/azure-cli/install.sh | 10 +++++---- ..._using_python_with_python_3_11_bullseye.sh | 21 +++++++++++++++++++ .../install_with_python_3_12_bookworm.sh | 12 +++++------ test/azure-cli/scenarios.json | 10 +++++++++ 5 files changed, 44 insertions(+), 11 deletions(-) create mode 100644 test/azure-cli/install_using_python_with_python_3_11_bullseye.sh diff --git a/src/azure-cli/devcontainer-feature.json b/src/azure-cli/devcontainer-feature.json index f25e5f9a2..6b26ef6fc 100644 --- a/src/azure-cli/devcontainer-feature.json +++ b/src/azure-cli/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "azure-cli", - "version": "1.2.3", + "version": "1.2.4", "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 7f4c4ff1c..a1b254779 100755 --- a/src/azure-cli/install.sh +++ b/src/azure-cli/install.sh @@ -15,7 +15,7 @@ rm -rf /var/lib/apt/lists/* AZ_VERSION=${VERSION:-"latest"} AZ_EXTENSIONS=${EXTENSIONS} AZ_INSTALLBICEP=${INSTALLBICEP:-false} -INSTALL_USING_PYTHON=${INSTALL_USING_PYTHON:-false} +INSTALL_USING_PYTHON=${INSTALLUSINGPYTHON:-false} MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc" AZCLI_ARCHIVE_ARCHITECTURES="amd64 arm64" AZCLI_ARCHIVE_VERSION_CODENAMES="stretch bookworm buster bullseye bionic focal jammy" @@ -188,13 +188,15 @@ echo "(*) Installing Azure CLI..." . /etc/os-release architecture="$(dpkg --print-architecture)" CACHED_AZURE_VERSION="${AZ_VERSION}" # In case we need to fallback to pip and the apt path has modified the AZ_VERSION variable. -if [[ "${AZCLI_ARCHIVE_ARCHITECTURES}" = *"${architecture}"* ]] && [[ "${AZCLI_ARCHIVE_VERSION_CODENAMES}" = *"${VERSION_CODENAME}"* ]]; then - install_using_apt || use_pip="true" +if [ "${INSTALL_USING_PYTHON}" != "true" ]; then + if [[ "${AZCLI_ARCHIVE_ARCHITECTURES}" = *"${architecture}"* ]] && [[ "${AZCLI_ARCHIVE_VERSION_CODENAMES}" = *"${VERSION_CODENAME}"* ]]; then + install_using_apt || use_pip="true" + fi else use_pip="true" fi -if [ "${use_pip}" = "true" ]; then +if [ "${use_pip}" = "true" ]; then AZ_VERSION=${CACHED_AZURE_VERSION} install_using_pip_strategy diff --git a/test/azure-cli/install_using_python_with_python_3_11_bullseye.sh b/test/azure-cli/install_using_python_with_python_3_11_bullseye.sh new file mode 100644 index 000000000..b9957843e --- /dev/null +++ b/test/azure-cli/install_using_python_with_python_3_11_bullseye.sh @@ -0,0 +1,21 @@ +#!/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 +check "version" az --version + +echo -e "\n\nšŸ”„ Testing 'O.S'" +if cat /etc/os-release | grep -q 'PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"'; then + echo -e "\n\nāœ… Passed 'O.S is Linux 11 (bullseye)'!" +else + echo -e "\n\nāŒ Failed 'O.S is other than Linux 11 (bullseye)'!" +fi + + +# Report result +reportResults \ No newline at end of file diff --git a/test/azure-cli/install_with_python_3_12_bookworm.sh b/test/azure-cli/install_with_python_3_12_bookworm.sh index 074876148..2c8e1fd72 100644 --- a/test/azure-cli/install_with_python_3_12_bookworm.sh +++ b/test/azure-cli/install_with_python_3_12_bookworm.sh @@ -5,17 +5,17 @@ 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 -check "version" az --version -echo -e "\n\nšŸ”„ Testing 'O.S'" +echo -e "\nšŸ”„ Testing 'O.S'" if cat /etc/os-release | grep -q 'PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"'; then - echo -e "\n\nāœ… Passed 'O.S is Linux 12 (bookworm)'!" + echo -e "\nāœ… Passed 'O.S is Linux 12 (bookworm)'!\n" else - echo -e "\n\nāŒ Failed 'O.S is other than Linux 12 (bookworm)'!" + echo -e "\nāŒ Failed 'O.S is other than Linux 12 (bookworm)'!\n" fi +# Check to make sure the user is vscode +check "user is vscode" whoami | grep vscode +check "version" az --version # Report result reportResults \ No newline at end of file diff --git a/test/azure-cli/scenarios.json b/test/azure-cli/scenarios.json index 041f50731..3ec910399 100644 --- a/test/azure-cli/scenarios.json +++ b/test/azure-cli/scenarios.json @@ -47,5 +47,15 @@ "version": "latest" } } + }, + "install_using_python_with_python_3_11_bullseye": { + "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", + "user": "vscode", + "features": { + "azure-cli": { + "version": "latest", + "installUsingPython": "true" + } + } } } \ No newline at end of file