-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[ACR] az acr login: Support Podman for --name parameter #33115
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |||||||||||||||||||||||||||||||||||||
| # -------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| import re | ||||||||||||||||||||||||||||||||||||||
| import json | ||||||||||||||||||||||||||||||||||||||
| from knack.util import CLIError | ||||||||||||||||||||||||||||||||||||||
| from knack.log import get_logger | ||||||||||||||||||||||||||||||||||||||
| from .custom import get_docker_command | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -73,11 +74,11 @@ def _subprocess_communicate(command_parts, shell=False): | |||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # Checks for the environment | ||||||||||||||||||||||||||||||||||||||
| # Checks docker command, docker daemon, docker version and docker pull | ||||||||||||||||||||||||||||||||||||||
| # Checks container command, daemon, version and image pull | ||||||||||||||||||||||||||||||||||||||
| def _get_docker_status_and_version(ignore_errors, yes): | ||||||||||||||||||||||||||||||||||||||
| from ._errors import DOCKER_DAEMON_ERROR, DOCKER_PULL_ERROR, DOCKER_VERSION_ERROR | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # Docker command and docker daemon check | ||||||||||||||||||||||||||||||||||||||
| # Container command and daemon check | ||||||||||||||||||||||||||||||||||||||
| docker_command, error = get_docker_command(is_diagnostics_context=True) | ||||||||||||||||||||||||||||||||||||||
| docker_daemon_available = True | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
@@ -88,18 +89,31 @@ def _get_docker_status_and_version(ignore_errors, yes): | |||||||||||||||||||||||||||||||||||||
| docker_daemon_available = False | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| if docker_daemon_available: | ||||||||||||||||||||||||||||||||||||||
| logger.warning("Docker daemon status: available") | ||||||||||||||||||||||||||||||||||||||
| logger.warning("%s daemon status: available", docker_command.title()) | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # Docker version check | ||||||||||||||||||||||||||||||||||||||
| output, warning, stderr, succeeded = _subprocess_communicate( | ||||||||||||||||||||||||||||||||||||||
| [docker_command, "version", "--format", "'Docker version {{.Server.Version}}, " | ||||||||||||||||||||||||||||||||||||||
| "build {{.Server.GitCommit}}, platform {{.Server.Os}}/{{.Server.Arch}}'"]) | ||||||||||||||||||||||||||||||||||||||
| output, warning, stderr, succeeded = _subprocess_communicate([docker_command, "version", "--format", "json"]) | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
| output, warning, stderr, succeeded = _subprocess_communicate([docker_command, "version", "--format", "json"]) | |
| format_arg = "{{json .}}" if docker_command == "docker" else "json" | |
| output, warning, stderr, succeeded = _subprocess_communicate( | |
| [docker_command, "version", "--format", format_arg] | |
| ) |
Copilot
AI
Apr 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes the diagnostic from reporting the daemon/server version (previously {{.Server.Version}}) to reporting the client version (Client.Version). That’s a behavior regression for a health check that’s validating the daemon. If the intent is to keep reporting daemon version, prefer parsing Server when present/when the daemon is available (and fall back to Client only when server info is absent).
| json_output = json.loads(output).get("Client") | |
| except json.decoder.JSONDecodeError: | |
| docker_info = json.loads(output) | |
| except json.decoder.JSONDecodeError: | |
| docker_info = {} | |
| if isinstance(docker_info, dict): | |
| json_output = docker_info.get("Server") or docker_info.get("Client") or {} | |
| else: |
Copilot
AI
Apr 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using os as a local variable name is ambiguous in Python because os commonly refers to the standard library module. Renaming it to something like platform_os (and possibly platform_arch) would make the intent clearer and avoid confusion in future edits.
| os = json_output.get("Os", "unknown") | |
| arch = json_output.get("Arch", "unknown") | |
| else: | |
| try: | |
| os, arch = json_output.get("OsArch", "unknown").split("/") | |
| except ValueError: | |
| os = "unknown" | |
| arch = "unknown" | |
| logger.warning("%s version: %s, build %s, platform %s/%s", docker_command.title(), version, commit, os, arch) | |
| platform_os = json_output.get("Os", "unknown") | |
| platform_arch = json_output.get("Arch", "unknown") | |
| else: | |
| try: | |
| platform_os, platform_arch = json_output.get("OsArch", "unknown").split("/") | |
| except ValueError: | |
| platform_os = "unknown" | |
| platform_arch = "unknown" | |
| logger.warning("%s version: %s, build %s, platform %s/%s", docker_command.title(), version, commit, platform_os, platform_arch) |
Copilot
AI
Apr 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using docker_command.title() can produce odd display names (e.g., docker.exe -> Docker.Exe, or titles for full paths if DOCKER_COMMAND is a path). Consider deriving a stable display label from the executable basename (and stripping .exe), or explicitly mapping known values (docker/podman) to user-facing names.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
|
|
||
| import os | ||
| import re | ||
| import shutil | ||
| from knack.util import CLIError | ||
| from knack.log import get_logger | ||
| from azure.cli.core.azclierror import InvalidArgumentValueError, RequiredArgumentMissingError | ||
|
|
@@ -396,6 +397,8 @@ def get_docker_command(is_diagnostics_context=False): | |
| docker_command = os.getenv('DOCKER_COMMAND') | ||
| else: | ||
| docker_command = 'docker' | ||
| if not shutil.which('docker') and shutil.which('podman'): | ||
| docker_command = 'podman' | ||
|
|
||
| from subprocess import PIPE, Popen, CalledProcessError | ||
| try: | ||
|
|
@@ -405,7 +408,7 @@ def get_docker_command(is_diagnostics_context=False): | |
| logger.debug("Could not run '%s' command. Exception: %s", docker_command, str(e)) | ||
| # The executable may not be discoverable in WSL so retry *.exe once | ||
| try: | ||
| docker_command = 'docker.exe' | ||
| docker_command = f'{docker_command}.exe' | ||
| p = Popen([docker_command, "ps"], stdout=PIPE, stderr=PIPE) | ||
|
Comment on lines
+411
to
412
|
||
| _, stderr = p.communicate() | ||
| except OSError as inner: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
docker_command.title()can produce odd display names (e.g.,docker.exe->Docker.Exe, or titles for full paths ifDOCKER_COMMANDis a path). Consider deriving a stable display label from the executable basename (and stripping.exe), or explicitly mapping known values (docker/podman) to user-facing names.