Skip to content

Commit

Permalink
[az-cli] - To separate the two methods of installation - using apt, u…
Browse files Browse the repository at this point in the history
…sing 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
  • Loading branch information
gauravsaini04 authored Apr 16, 2024
1 parent e7dd9fa commit b98f5a1
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 11 deletions.
2 changes: 1 addition & 1 deletion 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.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.",
Expand Down
10 changes: 6 additions & 4 deletions src/azure-cli/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down
21 changes: 21 additions & 0 deletions test/azure-cli/install_using_python_with_python_3_11_bullseye.sh
Original file line number Diff line number Diff line change
@@ -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
12 changes: 6 additions & 6 deletions test/azure-cli/install_with_python_3_12_bookworm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions test/azure-cli/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
}

0 comments on commit b98f5a1

Please sign in to comment.