Skip to content

Conversation

@hkosim
Copy link
Contributor

@hkosim hkosim commented Dec 22, 2025

This PR fixes #1653

Implemented changes:

  • getVersion() and getEdition() for Docker as well as kubectl is now working properly on Windows and Linux.

Note:

  • The functionalities has been tested on Windows and Linux using Hyper-V.
  • The used commands to check Docker Desktop version are:
OS Exec. Details Full Commands
Windows cmd through reg and checks for installation in windows registry reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Docker Desktop" /v DisplayVersion
Linux bash through apt and filtered using grep apt list --installed | grep docker-desktop | awk '{print $2}'
  • There are however some alternatives using different Terminals that could be used if the above implemented version are not working as intended.
OS Exec. Details Full Commands
Windows powershell Get-CimInstance Get-CimInstance -ClassName CIM_DataFile -Filter "Name='C:\Program Files\Docker\Docker\Docker Desktop.exe'"
Linux dpkg debian package dpkg -l | grep docker-desktop | awk '{print $3}'
MacOS (Not yet tested) brew Homebrew - additional package manager for MacOS brew list --cask docker --versions | awk '{print $2}'

Pseudocode:

FUNCTION getInstalledVersion():

IF isRancherDesktopInstalled() THEN
        RETURN getRancherDesktopClientVersion()
    ELSE
        osType ← context.getSystemInfo().getOs()

        SWITCH osType
            CASE WINDOWS:
                parsedVersion ← getDockerDesktopVersionWindows()
            CASE LINUX:
                parsedVersion ← getDockerDesktopVersionLinux()
            DEFAULT:
                parsedVersion ← null
        END SWITCH

        IF parsedVersion IS null THEN
            context.error("Couldn't get installed version of " + getName())
        END IF

        RETURN parsedVersion
    END IF
END FUNCTION

FUNCTION getInstalledEdition():

    IF NOT isDockerInstalled() THEN
        context.error("Couldn't get installed edition of " + getName())
        RETURN null
    END IF

    IF isRancherDesktopInstalled() THEN
        RETURN "rancher"
    ELSE
        RETURN "desktop"
    END IF
END FUNCTION

Findings about Testcases

Testcases was not yet implemented correctly. The idea that has been tested:

What could work:

  1. Setting up DockerTest.java with path for mocked rdctl and bash path* on custom environment.properties (*hard-coded) .
    -> getVersion() is working properly.

Still in progress:
Mocking cmd and reg for checking DockerDesktop version.

  • mocking windows executable requires custom or external tools
  • Not yet tested: reg might also be mocked with file with .cmd extension.

Checklist for this PR

Make sure everything is checked before merging this PR. For further info please also see
our DoD.

  • When running mvn clean test locally all tests pass and build is successful
  • PR title is of the form #«issue-id»: «brief summary» (e.g. #921: fixed setup.bat). If no issue ID exists, title only.
  • PR top-level comment summarizes what has been done and contains link to addressed issue(s)
  • PR and issue(s) have suitable labels
  • Issue is set to In Progress and assigned to you or there is no issue (might happen for very small PRs)
  • You followed all coding conventions
  • You have added the issue implemented by your PR in CHANGELOG.adoc unless issue is labeled
    with internal

@github-project-automation github-project-automation bot moved this to 🆕 New in IDEasy board Dec 22, 2025
@hkosim hkosim requested a review from hohwille December 22, 2025 13:31
@hkosim hkosim moved this from 🆕 New to 🏗 In progress in IDEasy board Dec 22, 2025
@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 20433382941

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 84 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.2%) to 69.904%

Files with Coverage Reduction New Missed Lines %
com/devonfw/tools/ide/tool/kubectl/KubeCtl.java 5 30.0%
com/devonfw/tools/ide/tool/ToolCommandlet.java 35 74.5%
com/devonfw/tools/ide/tool/docker/Docker.java 44 5.88%
Totals Coverage Status
Change from base Build 20341999990: -0.2%
Covered Lines: 10192
Relevant Lines: 14003

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🏗 In progress

Development

Successfully merging this pull request may close these issues.

Implementation of get-version and get-edition commands for Docker

2 participants