Skip to content

Commit

Permalink
#81: Implement ToolCommandlet for Kubernetes (#702)
Browse files Browse the repository at this point in the history
  • Loading branch information
KianRolf authored Nov 25, 2024
1 parent e719a05 commit a667129
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
@@ -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<D extends ToolCommandlet> extends ToolCommandlet {

private Class<D> 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<Tag> tags, Class<D> 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);
}
}
25 changes: 25 additions & 0 deletions cli/src/main/java/com/devonfw/tools/ide/tool/kubectl/KubeCtl.java
Original file line number Diff line number Diff line change
@@ -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 <a href="https://kubernetes.io/de/docs/tasks/tools/install-kubectl/">Kubectl</a>.
*/
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);
}
}
2 changes: 2 additions & 0 deletions cli/src/main/resources/nls/Help.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions cli/src/main/resources/nls/Help_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit a667129

Please sign in to comment.