forked from devonfw/IDEasy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
devonfw#81: Implement ToolCommandlet for Kubernetes (devonfw#702)
- Loading branch information
Showing
6 changed files
with
107 additions
and
0 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
75 changes: 75 additions & 0 deletions
75
cli/src/main/java/com/devonfw/tools/ide/tool/DelegatingToolCommandlet.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,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
25
cli/src/main/java/com/devonfw/tools/ide/tool/kubectl/KubeCtl.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,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); | ||
} | ||
} |
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