-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
5 changed files
with
165 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
cli/src/main/java/com/devonfw/tools/ide/tool/PackageManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.devonfw.tools.ide.tool; | ||
|
||
public enum PackageManager { | ||
APT, ZYPPER, YUM, DNF | ||
} |
79 changes: 79 additions & 0 deletions
79
cli/src/main/java/com/devonfw/tools/ide/tool/docker/Docker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.devonfw.tools.ide.tool.docker; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import com.devonfw.tools.ide.common.Tag; | ||
import com.devonfw.tools.ide.context.IdeContext; | ||
import com.devonfw.tools.ide.os.SystemArchitecture; | ||
import com.devonfw.tools.ide.repo.ToolRepository; | ||
import com.devonfw.tools.ide.tool.GlobalToolCommandlet; | ||
import com.devonfw.tools.ide.tool.PackageManager; | ||
import com.devonfw.tools.ide.version.VersionIdentifier; | ||
|
||
public class Docker extends GlobalToolCommandlet { | ||
/** | ||
* The constructor. | ||
* | ||
* @param context the {@link IdeContext}. | ||
*/ | ||
public Docker(IdeContext context) { | ||
|
||
super(context, "docker", Set.of(Tag.DOCKER)); | ||
} | ||
|
||
@Override | ||
public boolean isExtract() { | ||
|
||
return switch (context.getSystemInfo().getOs()) { | ||
case WINDOWS -> false; | ||
case MAC -> context.getSystemInfo().getArchitecture().equals(SystemArchitecture.ARM64); | ||
case LINUX -> true; | ||
}; | ||
} | ||
|
||
@Override | ||
protected boolean doInstall(boolean silent) { | ||
|
||
if (context.getSystemInfo().isLinux()) { | ||
return installWithPackageManger(getPackageMangerCommands(), silent); | ||
} else { | ||
return super.doInstall(silent); | ||
} | ||
} | ||
|
||
private Map<PackageManager, List<String>> getPackageMangerCommands() { | ||
|
||
Map<PackageManager, List<String>> commands = new HashMap<>(); | ||
|
||
String edition = getEdition(); | ||
ToolRepository toolRepository = this.context.getDefaultToolRepository(); | ||
VersionIdentifier configuredVersion = getConfiguredVersion(); | ||
String resolvedVersion = toolRepository.resolveVersion(this.tool, edition, configuredVersion).toString(); | ||
|
||
commands.put(PackageManager.ZYPPER, Arrays.asList( | ||
"sudo zypper addrepo https://download.opensuse.org/repositories/isv:/Rancher:/stable/rpm/isv:Rancher:stable.repo", | ||
String.format("sudo zypper --no-gpg-checks install rancher-desktop=%s*", resolvedVersion))); | ||
|
||
commands.put(PackageManager.APT, Arrays.asList( | ||
"curl -s https://download.opensuse.org/repositories/isv:/Rancher:/stable/deb/Release.key | gpg --dearmor | sudo dd status=none of=/usr/share/keyrings/isv-rancher-stable-archive-keyring.gpg", | ||
"echo 'deb [signed-by=/usr/share/keyrings/isv-rancher-stable-archive-keyring.gpg] https://download.opensuse.org/repositories/isv:/Rancher:/stable/deb/ ./' | sudo dd status=none of=/etc/apt/sources.list.d/isv-rancher-stable.list", | ||
"sudo apt update", | ||
String.format("sudo apt install -y --allow-downgrades rancher-desktop=%s*", resolvedVersion))); | ||
|
||
return commands; | ||
} | ||
|
||
@Override | ||
protected String getBinaryName() { | ||
|
||
if (context.getSystemInfo().isLinux()) { | ||
return "rancher-desktop"; | ||
} else { | ||
return super.getBinaryName(); | ||
} | ||
} | ||
} |