Skip to content

Commit

Permalink
refactor: cleanup unused Docker Maven Plugin features
Browse files Browse the repository at this point in the history
Removes mostly configuration and services related to the run tasks.

In the context of the Kubernetes/OpenShift plugins, containers are run in a remote cluster.
It no longer makes sense to provide run logic to deal with containers in a local Docker daemon.

Signed-off-by: Marc Nuri <[email protected]>
  • Loading branch information
manusa committed Nov 28, 2023
1 parent 031bca4 commit 636a94c
Show file tree
Hide file tree
Showing 86 changed files with 286 additions and 8,373 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Usage:
* Fix #2444: Add support for Spring Boot application properties placeholders
* Fix #2456: Add utility class to decompress archive files
* Fix #2472: Support for Helm Chart.yaml appVersion field defaulting to project version
* Fix #2474: Remove Docker-related classes providing unused functionality

### 1.15.0 (2023-11-10)
* Fix #2138: Support for Spring Boot Native Image
Expand Down
38 changes: 0 additions & 38 deletions gradle-plugin/doc/src/main/asciidoc/inc/_groovy-configuration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -410,12 +410,6 @@ Defaults to `false`.
| Boolean attribute for switching on verbose output like the build steps when doing a Docker build. Default is `false`.
| `jkube.docker.verbose`

| *watchAutoCreateCustomNetworks*
| Whether to create the customs networks (user-defined bridge networks) before starting automatically

Defaults to `false`.
| `jkube.watch.autoCreateCustomNetworks`

| *watchMode*
a|
How to watch for image changes.
Expand All @@ -436,44 +430,12 @@ Defaults to `both`.
Defaults to `5000`.
| `jkube.watch.interval`

| *watchKeepRunning*
| If set to true all containers will be kept running after {goal-prefix}:watch has been stopped.

Defaults to `false`.
| `jkube.watch.keepRunning`

| *watchPostExec*
| A command which is executed within the container after files are copied into this container
when watchMode is copy. Note that this container must be running.

| `jkube.watch.postExec`

| *watchKeepContainer*
| If this is set to `false` (and `watchKeepRunning` is disabled) then all containers will be removed after
they have been stopped.

Defaults to `false`.
| `jkube.watch.keepContainer`

| *watchRemoveVolumes*
| If set to `true` remove any volumes associated with the container as well.

This option will be ignored if either `watchKeepContainer` or `watchKeepRunning` is `true`.

Defaults to `false`.
| `jkube.watch.removeVolumes`

| *watchShowLogs*
| If set to `true`, logs will be shown for watched container.
| `jkube.watch.showLogs`

| *watchFollow*
| If `watchShowLogs` is set to `false`, and there is a run image configuration, logs are followed
if set to `true`.

Defaults to `false`.
| `jkube.watch.follow`

| *workDirectory*
| The JKube working directory. Defaults to `${project.build.directory}/jkube-temp`.
| `jkube.workDir`
Expand Down
7 changes: 0 additions & 7 deletions gradle-plugin/it/src/it/extension-configuration/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,7 @@ kubernetes {
kubernetesTemplate = file('build/META-INF/jkube/kubernetes')
watchMode = 'copy'
watchInterval = 1000
watchKeepRunning = true
watchPostExec = 'ls -lt'
watchAutoCreateCustomNetworks = true
watchKeepContainer = true
watchRemoveVolumes = true
watchContainerNamePattern = '%g-%l'
watchFollow = true
watchShowLogs = 'true'
access {
namespace = 'default'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,7 @@ pushretries: 5
kubernetestemplate: "@endsWith('extension-configuration/build/META-INF/jkube/kubernetes')@"
watchMode: "copy"
watchinterval: 1000
watchkeeprunning: true
watchpostexec: "ls -lt"
watchautocreatecustomnetworks: true
watchkeepcontainer: true
watchremovevolumes: true
watchcontainernamepattern: "%g-%l"
watchfollow: true
watchshowlogs: "true"
access:
namespace: "default"
enricher:
Expand Down Expand Up @@ -79,12 +72,6 @@ images:
dockerFileFile: "@endsWith('extension-configuration/src/main/context-dir/Dockerfile')@"
dockerFileMode: true
contextDirRaw: "@endsWith('extension-configuration/src/main/context-dir')@"
runConfiguration:
restartPolicy:
retry: 0
networkingConfig:
standardNetwork: false
default: true
buildConfiguration:
contextDir: "@endsWith('extension-configuration/src/main/context-dir')@"
dockerFile: "@endsWith('extension-configuration/src/main/context-dir/Dockerfile')@"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.stream.Collectors;

import org.eclipse.jkube.kit.build.service.docker.config.DockerMachineConfiguration;
import org.eclipse.jkube.kit.build.service.docker.helper.ContainerNamingUtil;
import org.eclipse.jkube.kit.common.JavaProject;
import org.eclipse.jkube.kit.common.KitLogger;
import org.eclipse.jkube.kit.common.ResourceFileType;
Expand Down Expand Up @@ -241,24 +240,10 @@ public abstract class KubernetesExtension {

public abstract Property<Boolean> getSkipBuild();

public abstract Property<Boolean> getWatchKeepRunning();

public abstract Property<Integer> getWatchInterval();

public abstract Property<String> getWatchPostExec();

public abstract Property<Boolean> getWatchAutoCreateCustomNetworks();

public abstract Property<Boolean> getWatchKeepContainer();

public abstract Property<Boolean> getWatchRemoveVolumes();

public abstract Property<Boolean> getWatchFollow();

public abstract Property<String> getWatchShowLogs();

public abstract Property<String> getWatchContainerNamePattern();

public WatchMode watchMode;

public JKubeBuildStrategy buildStrategy;
Expand Down Expand Up @@ -692,38 +677,10 @@ public Integer getWatchIntervalOrDefault() {
return getOrDefaultInteger("jkube.watch.interval", this::getWatchInterval, 5000);
}

public boolean getWatchKeepRunningOrDefault() {
return getOrDefaultBoolean("jkube.watch.keepRunning", this::getWatchKeepRunning, false);
}

public String getWatchPostExecOrNull() {
return getOrDefaultString("jkube.watch.postExec", this::getWatchPostExec, null);
}

public boolean getWatchAutoCreateCustomNetworksOrDefault() {
return getOrDefaultBoolean("jkube.watch.autoCreateCustomNetworks", this::getWatchAutoCreateCustomNetworks, false);
}

public boolean getWatchKeepContainerOrDefault() {
return getOrDefaultBoolean("jkube.watch.keepContainer", this::getWatchKeepContainer, false);
}

public boolean getWatchRemoveVolumesOrDefault() {
return getOrDefaultBoolean("jkube.watch.removeVolumes", this::getWatchRemoveVolumes, false);
}

public String getWatchContainerNamePatternOrDefault() {
return getOrDefaultString("jkube.watch.containerNamePattern", this::getWatchContainerNamePattern, ContainerNamingUtil.DEFAULT_CONTAINER_NAME_PATTERN);
}

public boolean getWatchFollowOrDefault() {
return getOrDefaultBoolean("jkube.watch.follow", this::getWatchFollow, false);
}

public String getWatchShowLogsOrNull() {
return getOrDefaultString("jkube.watch.showLogs", this::getWatchShowLogs, null);
}

protected boolean getOrDefaultBoolean(String property, Supplier<Property<Boolean>> dslGetter, boolean defaultValue) {
return getOrDefault(property, Boolean::parseBoolean, dslGetter, defaultValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.eclipse.jkube.gradle.plugin.GradleLogger;
import org.eclipse.jkube.gradle.plugin.GradleUtil;
import org.eclipse.jkube.gradle.plugin.KubernetesExtension;
import org.eclipse.jkube.kit.build.service.docker.access.log.LogOutputSpecFactory;
import org.eclipse.jkube.kit.build.service.docker.config.handler.ImageConfigResolver;
import org.eclipse.jkube.kit.common.JKubeConfiguration;
import org.eclipse.jkube.kit.common.KitLogger;
Expand Down Expand Up @@ -60,7 +59,6 @@ public abstract class AbstractJKubeTask extends DefaultTask implements Kubernete

protected final KubernetesExtension kubernetesExtension;
protected KitLogger kitLogger;
protected LogOutputSpecFactory logOutputSpecFactory;
protected ClusterAccess clusterAccess;
protected JKubeServiceHub jKubeServiceHub;
protected static final String DOCKER_BUILD_TIMESTAMP = "docker/build.timestamp";
Expand All @@ -84,8 +82,6 @@ public final void runTask() {
private void init() {
kubernetesExtension.javaProject = GradleUtil.convertGradleProject(getProject());
kitLogger = createLogger(null);
logOutputSpecFactory = new LogOutputSpecFactory(isAnsiEnabled(), kubernetesExtension.getLogStdoutOrDefault(),
kubernetesExtension.getLogDateOrNull());
clusterAccess = new ClusterAccess(initClusterConfiguration());
jKubeServiceHub = initJKubeServiceHubBuilder().build();
kubernetesExtension.resources = updateResourceConfigNamespace(kubernetesExtension.getNamespaceOrNull(), kubernetesExtension.resources);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public KubernetesBuildTask(Class<? extends KubernetesExtension> extensionClass)
@Override
protected JKubeServiceHub.JKubeServiceHubBuilder initJKubeServiceHubBuilder() {
return super.initJKubeServiceHubBuilder()
.dockerServiceHub(DockerServiceHub.newInstance(kitLogger, TaskUtil.initDockerAccess(kubernetesExtension, kitLogger),
logOutputSpecFactory))
.dockerServiceHub(DockerServiceHub.newInstance(kitLogger, TaskUtil.initDockerAccess(kubernetesExtension, kitLogger)))
.buildServiceConfig(buildServiceConfigBuilder().build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public KubernetesPushTask(Class<? extends KubernetesExtension> extensionClass) {
@Override
protected JKubeServiceHub.JKubeServiceHubBuilder initJKubeServiceHubBuilder() {
return super.initJKubeServiceHubBuilder()
.dockerServiceHub(DockerServiceHub.newInstance(kitLogger, TaskUtil.initDockerAccess(kubernetesExtension, kitLogger),
logOutputSpecFactory))
.dockerServiceHub(DockerServiceHub.newInstance(kitLogger, TaskUtil.initDockerAccess(kubernetesExtension, kitLogger)))
.buildServiceConfig(buildServiceConfigBuilder().build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.eclipse.jkube.gradle.plugin.KubernetesExtension;
import org.eclipse.jkube.kit.build.core.GavLabel;
import org.eclipse.jkube.kit.build.service.docker.DockerServiceHub;
import org.eclipse.jkube.kit.build.service.docker.access.log.LogDispatcher;
import org.eclipse.jkube.kit.build.service.docker.watch.WatchContext;
import org.eclipse.jkube.kit.common.util.KubernetesHelper;
import org.eclipse.jkube.kit.common.util.ResourceUtil;
Expand Down Expand Up @@ -48,8 +47,7 @@ public KubernetesWatchTask(Class<? extends KubernetesExtension> extensionClass)
@Override
protected JKubeServiceHub.JKubeServiceHubBuilder initJKubeServiceHubBuilder() {
return super.initJKubeServiceHubBuilder()
.dockerServiceHub(DockerServiceHub.newInstance(kitLogger, TaskUtil.initDockerAccess(kubernetesExtension, kitLogger),
logOutputSpecFactory))
.dockerServiceHub(DockerServiceHub.newInstance(kitLogger, TaskUtil.initDockerAccess(kubernetesExtension, kitLogger)))
.buildServiceConfig(TaskUtil.buildServiceConfigBuilder(kubernetesExtension).build());
}

Expand Down Expand Up @@ -103,19 +101,10 @@ private WatchContext getWatchContext() throws IOException {
.watchInterval(kubernetesExtension.getWatchIntervalOrDefault())
.watchMode(kubernetesExtension.getWatchModeOrDefault())
.watchPostExec(kubernetesExtension.getWatchPostExecOrNull())
.autoCreateCustomNetworks(kubernetesExtension.getWatchAutoCreateCustomNetworksOrDefault())
.keepContainer(kubernetesExtension.getWatchKeepContainerOrDefault())
.keepRunning(kubernetesExtension.getWatchKeepRunningOrDefault())
.removeVolumes(kubernetesExtension.getWatchRemoveVolumesOrDefault())
.containerNamePattern(kubernetesExtension.getWatchContainerNamePatternOrDefault())
.buildTimestamp(getBuildTimestamp(null, null, kubernetesExtension.javaProject.getBuildDirectory().getAbsolutePath(), DOCKER_BUILD_TIMESTAMP))
.gavLabel(new GavLabel(kubernetesExtension.javaProject.getGroupId(), kubernetesExtension.javaProject.getArtifactId(), kubernetesExtension.javaProject.getVersion()))
.buildContext(jKubeServiceHub.getConfiguration())
.follow(kubernetesExtension.getWatchFollowOrDefault())
.showLogs(kubernetesExtension.getWatchShowLogsOrNull())
.logOutputSpecFactory(logOutputSpecFactory)
.hub(hub)
.dispatcher(new LogDispatcher(hub.getDockerAccess()))
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.nio.file.Paths;
import java.util.stream.Stream;

import org.eclipse.jkube.kit.build.service.docker.helper.ContainerNamingUtil;
import org.eclipse.jkube.kit.common.JavaProject;

import org.eclipse.jkube.kit.common.ResourceFileType;
Expand Down Expand Up @@ -117,14 +116,7 @@ static Stream<Arguments> defaultValues() {
arguments("getKubernetesTemplateOrDefault", new File(BASE, "build").toPath().resolve(Paths.get("META-INF", "jkube", "kubernetes")).toFile()),
arguments("getWatchModeOrDefault", WatchMode.both),
arguments("getWatchIntervalOrDefault", 5000),
arguments("getWatchKeepRunningOrDefault", false),
arguments("getWatchPostExecOrNull", null),
arguments("getWatchAutoCreateCustomNetworksOrDefault", false),
arguments("getWatchKeepContainerOrDefault", false),
arguments("getWatchRemoveVolumesOrDefault", false),
arguments("getWatchContainerNamePatternOrDefault", ContainerNamingUtil.DEFAULT_CONTAINER_NAME_PATTERN),
arguments("getWatchFollowOrDefault", false),
arguments("getWatchShowLogsOrNull", null));
arguments("getWatchPostExecOrNull", null));
}

@ParameterizedTest(name = "{index}: {0} with property ''{1}={2}'' returns ''{3}''")
Expand Down Expand Up @@ -213,13 +205,6 @@ static Stream<Arguments> propertiesAndValues() {
Paths.get("META-INF", "jkube", "other").toFile()),
arguments("getWatchModeOrDefault", "jkube.watch.mode", "copy", WatchMode.copy),
arguments("getWatchIntervalOrDefault", "jkube.watch.interval", "10000", 10000),
arguments("getWatchKeepRunningOrDefault", "jkube.watch.keepRunning", "true", true),
arguments("getWatchPostExecOrNull", "jkube.watch.postExec", "ls -lt", "ls -lt"),
arguments("getWatchAutoCreateCustomNetworksOrDefault", "jkube.watch.autoCreateCustomNetworks", "true", true),
arguments("getWatchKeepContainerOrDefault", "jkube.watch.keepContainer", "true", true),
arguments("getWatchRemoveVolumesOrDefault", "jkube.watch.removeVolumes", "true", true),
arguments("getWatchContainerNamePatternOrDefault", "jkube.watch.containerNamePattern", "%n-%g", "%n-%g"),
arguments("getWatchFollowOrDefault", "jkube.watch.follow", "true", true),
arguments("getWatchShowLogsOrNull", "jkube.watch.showLogs", "true", "true"));
arguments("getWatchPostExecOrNull", "jkube.watch.postExec", "ls -lt", "ls -lt"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,6 @@ public Property<Boolean> getSkipResource() {
return property(Boolean.class);
}

@Override
public Property<Boolean> getWatchKeepRunning() {
return property(Boolean.class);
}

@Override
public Property<Boolean> getSkipBuild() {
return property(Boolean.class);
Expand All @@ -358,36 +353,6 @@ public Property<String> getWatchPostExec() {
return property(String.class);
}

@Override
public Property<Boolean> getWatchAutoCreateCustomNetworks() {
return property(Boolean.class);
}

@Override
public Property<Boolean> getWatchKeepContainer() {
return property(Boolean.class);
}

@Override
public Property<Boolean> getWatchRemoveVolumes() {
return property(Boolean.class);
}

@Override
public Property<Boolean> getWatchFollow() {
return property(Boolean.class);
}

@Override
public Property<String> getWatchShowLogs() {
return property(String.class);
}

@Override
public Property<String> getWatchContainerNamePattern() {
return property(String.class);
}

public static <T> Property<T> property(Class<T> type) {
return new DefaultProperty<>(PropertyHost.NO_OP, type);
}
Expand Down
Loading

0 comments on commit 636a94c

Please sign in to comment.