• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 12254902365

10 Dec 2024 11:12AM UTC coverage: 67.103% (+0.005%) from 67.098%
12254902365

Pull #883

github

web-flow
Merge 600c99537 into f19f36088
Pull Request #883: #875: fix lazydocker

2554 of 4154 branches covered (61.48%)

Branch coverage included in aggregate %.

6627 of 9528 relevant lines covered (69.55%)

3.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

15.38
cli/src/main/java/com/devonfw/tools/ide/tool/lazydocker/LazyDocker.java
1
package com.devonfw.tools.ide.tool.lazydocker;
2

3
import java.util.Set;
4

5
import com.devonfw.tools.ide.cli.CliException;
6
import com.devonfw.tools.ide.common.Tag;
7
import com.devonfw.tools.ide.context.IdeContext;
8
import com.devonfw.tools.ide.process.ProcessContext;
9
import com.devonfw.tools.ide.process.ProcessErrorHandling;
10
import com.devonfw.tools.ide.process.ProcessMode;
11
import com.devonfw.tools.ide.process.ProcessResult;
12
import com.devonfw.tools.ide.tool.LocalToolCommandlet;
13
import com.devonfw.tools.ide.tool.ToolCommandlet;
14
import com.devonfw.tools.ide.tool.docker.Docker;
15
import com.devonfw.tools.ide.version.VersionIdentifier;
16

17
/**
18
 * {@link ToolCommandlet} for <a href="https://github.com/jesseduffield/lazydocker">lazydocker</a>.
19
 */
20
public class LazyDocker extends LocalToolCommandlet {
21

22
  public static final VersionIdentifier MIN_API_VERSION = VersionIdentifier.of("1.25");
3✔
23
  public static final VersionIdentifier MIN_COMPOSE_VERSION = VersionIdentifier.of("1.23.2");
4✔
24

25
  /**
26
   * The constructor.
27
   *
28
   * @param context the {@link IdeContext}.
29
   */
30
  public LazyDocker(IdeContext context) {
31

32
    super(context, "lazydocker", Set.of(Tag.DOCKER, Tag.ADMIN));
7✔
33
  }
1✔
34

35
  @Override
36
  protected void installDependencies() {
37

38
    // TODO create lazydocker/lazydocker/dependencies.json file in ide-urls and delete this method
39
    getCommandlet(Docker.class).install();
×
40
    // verify docker API version requirements
41
    ProcessContext pc = this.context.newProcess().errorHandling(ProcessErrorHandling.NONE).executable("docker")
×
42
        .addArg("version").addArg("--format").addArg("'{{.Client.APIVersion}}'");
×
43
    ProcessResult result = pc.run(ProcessMode.DEFAULT_CAPTURE);
×
44
    verifyDockerVersion(result, MIN_API_VERSION, "docker API");
×
45

46
    // verify docker compose version requirements
47
    pc = this.context.newProcess().errorHandling(ProcessErrorHandling.NONE).executable("docker-compose").addArg("version")
×
48
        .addArg("--short");
×
49
    result = pc.run(ProcessMode.DEFAULT_CAPTURE);
×
50
    verifyDockerVersion(result, MIN_COMPOSE_VERSION, "docker-compose");
×
51
  }
×
52

53
  private static void verifyDockerVersion(ProcessResult result, VersionIdentifier minimumVersion, String kind) {
54
    // we have this pattern a lot that we want to get a single line output of a successful ProcessResult.
55
    // we should create a generic method in ProcessResult for this use-case.
56
    if (!result.isSuccessful() || result.getOut().isEmpty()) {
×
57
      throw new CliException("Docker is not installed, but required for lazydocker.\n" //
×
58
          + "To install docker, call the following command:\n" //
59
          + "ide install docker");
60
    }
61
    VersionIdentifier installedVersion = VersionIdentifier.of(result.getOut().get(0).toString());
×
62
    if (installedVersion.isLess(minimumVersion)) {
×
63
      throw new CliException("The installed " + kind + " version is '" + installedVersion + "'.\n" + //
×
64
          "But lazydocker requires at least " + kind + " version '" + minimumVersion + "'.\n" //
65
          + "Please upgrade your installation of docker, before installing lazydocker.");
66
    }
67
  }
×
68

69
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc