diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 92616229d..2e69ec80f 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -9,6 +9,7 @@ Release with new features and bugfixes: * https://github.com/devonfw/IDEasy/issues/589[#589]: Fix NLS Bundles for Linux and MacOS * https://github.com/devonfw/IDEasy/issues/637[#637]: Added option to disable updates * https://github.com/devonfw/IDEasy/issues/764[#764]: IDEasy not working properly in CMD +* https://github.com/devonfw/IDEasy/issues/81[#81]: Implement Toolcommandlet for Kubernetes * https://github.com/devonfw/IDEasy/issues/754[#754]: Again messages break processable command output The full list of changes for this release can be found in https://github.com/devonfw/IDEasy/milestone/16?closed=1[milestone 2024.12.001]. diff --git a/cli/src/main/java/com/devonfw/tools/ide/commandlet/CommandletManagerImpl.java b/cli/src/main/java/com/devonfw/tools/ide/commandlet/CommandletManagerImpl.java index 2c4601735..2af9a4e03 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/commandlet/CommandletManagerImpl.java +++ b/cli/src/main/java/com/devonfw/tools/ide/commandlet/CommandletManagerImpl.java @@ -26,6 +26,7 @@ import com.devonfw.tools.ide.tool.jmc.Jmc; import com.devonfw.tools.ide.tool.kotlinc.Kotlinc; import com.devonfw.tools.ide.tool.kotlinc.KotlincNative; +import com.devonfw.tools.ide.tool.kubectl.KubeCtl; import com.devonfw.tools.ide.tool.lazydocker.LazyDocker; import com.devonfw.tools.ide.tool.mvn.Mvn; import com.devonfw.tools.ide.tool.node.Node; @@ -96,6 +97,7 @@ public CommandletManagerImpl(IdeContext context) { add(new Quarkus(context)); add(new Kotlinc(context)); add(new KotlincNative(context)); + add(new KubeCtl(context)); add(new Tomcat(context)); add(new Vscode(context)); add(new Azure(context)); diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/DelegatingToolCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/tool/DelegatingToolCommandlet.java new file mode 100644 index 000000000..ffe188212 --- /dev/null +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/DelegatingToolCommandlet.java @@ -0,0 +1,75 @@ +package com.devonfw.tools.ide.tool; + +import java.util.Set; + +import com.devonfw.tools.ide.common.Tag; +import com.devonfw.tools.ide.context.IdeContext; +import com.devonfw.tools.ide.environment.EnvironmentVariablesFiles; +import com.devonfw.tools.ide.process.EnvironmentContext; +import com.devonfw.tools.ide.version.VersionIdentifier; + +/** + * {@link ToolCommandlet} that delegates to another ToolCommandlet. + */ +public abstract class DelegatingToolCommandlet extends ToolCommandlet { + + private Class delegateClass; + + /** + * The constructor. + * + * @param context the {@link IdeContext}. + * @param tool the {@link #getName() tool name}. + * @param tags the {@link #getTags() tags} classifying the tool. Should be created via {@link Set#of(Object) Set.of} method. + * @param delegateClass the {@link ToolCommandlet}. + */ + public DelegatingToolCommandlet(IdeContext context, String tool, Set tags, Class delegateClass) { + + super(context, tool, tags); + this.delegateClass = delegateClass; + } + + private D getDelegate() { + return getCommandlet(this.delegateClass); + } + + @Override + public final boolean install(boolean silent, EnvironmentContext environmentContext) { + return getDelegate().install(silent, environmentContext); + } + + @Override + public VersionIdentifier getInstalledVersion() { + return getDelegate().getInstalledVersion(); + } + + @Override + public String getInstalledEdition() { + return getDelegate().getInstalledEdition(); + } + + @Override + public void uninstall() { + getDelegate().uninstall(); + } + + @Override + public void listEditions() { + getDelegate().listEditions(); + } + + @Override + public void listVersions() { + getDelegate().listVersions(); + } + + @Override + public void setVersion(VersionIdentifier version, boolean hint, EnvironmentVariablesFiles destination) { + getDelegate().setVersion(version, hint, destination); + } + + @Override + public void setEdition(String edition, boolean hint, EnvironmentVariablesFiles destination) { + getDelegate().setEdition(edition, hint, destination); + } +} diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/kubectl/KubeCtl.java b/cli/src/main/java/com/devonfw/tools/ide/tool/kubectl/KubeCtl.java new file mode 100644 index 000000000..c976413ee --- /dev/null +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/kubectl/KubeCtl.java @@ -0,0 +1,25 @@ +package com.devonfw.tools.ide.tool.kubectl; + +import java.util.Set; + +import com.devonfw.tools.ide.common.Tag; +import com.devonfw.tools.ide.context.IdeContext; +import com.devonfw.tools.ide.tool.DelegatingToolCommandlet; +import com.devonfw.tools.ide.tool.docker.Docker; + +/** + * {@link DelegatingToolCommandlet} for Kubectl. + */ +public class KubeCtl extends DelegatingToolCommandlet { + + + /** + * The constructor. + * + * @param context the {@link IdeContext}. + */ + public KubeCtl(IdeContext context) { + + super(context, "kubectl", Set.of(Tag.KUBERNETES), Docker.class); + } +} diff --git a/cli/src/main/resources/nls/Help.properties b/cli/src/main/resources/nls/Help.properties index c7cfa44cc..b4805b684 100644 --- a/cli/src/main/resources/nls/Help.properties +++ b/cli/src/main/resources/nls/Help.properties @@ -62,6 +62,8 @@ cmd.kotlinc=Tool commandlet for Kotlin (compiler for JRE language). cmd.kotlinc.detail=Kotlin Compiler (kotlinc) is the command-line tool for compiling Kotlin code. Detailed documentation can be found at https://kotlinlang.org/docs/home.html cmd.kotlincnative=Tool commandlet for Kotlin-Native (compiler for JRE language). cmd.kotlincnative.detail=Kotlin/Native Compiler (kotlincnative) compiles Kotlin code to native executables. Detailed documentation can be found at https://kotlinlang.org/docs/reference/native-overview.html +cmd.kubectl=Tool commandlet for kubernetes. Detailed documentation can be found at https://kubernetes.io/docs/home/ +cmd.kubectl.detail=The kubectl commandlet allows to install and use kubernetes. On Windows WSL 2 (Windows Subsystem for Linux) has to be installed properly as a prerequisite. cmd.lazydocker=Tool commandlet for LazyDocker. cmd.lazydocker.detail=Lazydocker is a simple terminal UI for both docker and docker-compose. Detailed documentation can be found at https://github.com/jesseduffield/lazydocker cmd.list-editions=List the available editions of the selected tool. diff --git a/cli/src/main/resources/nls/Help_de.properties b/cli/src/main/resources/nls/Help_de.properties index b6210648a..f8f70be95 100644 --- a/cli/src/main/resources/nls/Help_de.properties +++ b/cli/src/main/resources/nls/Help_de.properties @@ -62,6 +62,8 @@ cmd.kotlinc=Werkzeug Kommando für Kotlin (Compiler für JRE Sprache). cmd.kotlinc.detail=Der Kotlin-Compiler (kotlinc) ist das Befehlszeilentool zum Kompilieren von Kotlin-Code. Detaillierte Dokumentation ist zu finden unter https://kotlinlang.org/docs/home.html cmd.kotlincnative=Werkzeug Kommando für Kotlin-Native (Compiler für JRE Sprache). cmd.kotlincnative.detail=Der Kotlin/Native-Compiler (kotlincnative) kompiliert Kotlin-Code in native ausführbare Dateien. Detaillierte Dokumentation ist zu finden unter https://kotlinlang.org/docs/reference/native-overview.html +cmd.kubectl=Werkzeug Kommando für Kubernetes. Detaillierte Dokumentation ist zu finden unter https://kubernetes.io/docs/home/ +cmd.kubectl.detail=Der Befehl kubectl ermöglicht die Installation und Nutzung von Kubernetes. Unter Windows muss WSL 2 (Windows Subsystem for Linux) ordnungsgemäß installiert sein. cmd.lazydocker=Werkzeug Kommando für LazyDocker. cmd.lazydocker.detail=Lazydocker ist ein einfaches Kommandozeilen-Benutzer-Interface für Docker und Docker-compose. Detaillierte Dokumentation ist zu finden unter https://github.com/jesseduffield/lazydocker cmd.list-editions=Listet die verfügbaren Editionen des selektierten Werkzeugs auf.