-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* DevService * Auto configure jsch logs * JSchSession annotation: * configurable by properties * named sessions * auto connect/disconnect
- Loading branch information
Showing
27 changed files
with
1,904 additions
and
37 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
18 changes: 18 additions & 0 deletions
18
deployment/src/main/java/io/quarkus/jsch/deployment/JSchBuildTimeConfig.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,18 @@ | ||
package io.quarkus.jsch.deployment; | ||
|
||
import io.quarkus.runtime.annotations.ConfigDocSection; | ||
import io.quarkus.runtime.annotations.ConfigPhase; | ||
import io.quarkus.runtime.annotations.ConfigRoot; | ||
import io.smallrye.config.ConfigMapping; | ||
|
||
@ConfigMapping(prefix = "quarkus.jsch") | ||
@ConfigRoot(phase = ConfigPhase.BUILD_TIME) | ||
public interface JSchBuildTimeConfig { | ||
|
||
/** | ||
* The JSch DevService configuration. | ||
*/ | ||
@ConfigDocSection | ||
JSchDevServiceConfig devservices(); | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
deployment/src/main/java/io/quarkus/jsch/deployment/JSchDevServiceConfig.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,45 @@ | ||
package io.quarkus.jsch.deployment; | ||
|
||
import io.quarkus.runtime.annotations.ConfigGroup; | ||
import io.smallrye.config.WithDefault; | ||
|
||
@ConfigGroup | ||
public interface JSchDevServiceConfig { | ||
|
||
/** | ||
* Enable the JSch DevService. | ||
*/ | ||
@WithDefault("true") | ||
boolean enabled(); | ||
|
||
/** | ||
* The image to use for the JSch DevService. | ||
*/ | ||
@WithDefault("linuxserver/openssh-server") | ||
String image(); | ||
|
||
/** | ||
* The port to use for the JSch DevService. | ||
*/ | ||
@WithDefault("2222") | ||
int port(); | ||
|
||
/** | ||
* The username to use for the JSch DevService. | ||
*/ | ||
@WithDefault("quarkus") | ||
String username(); | ||
|
||
/** | ||
* The password to use for the JSch DevService. | ||
*/ | ||
@WithDefault("quarkus") | ||
String password(); | ||
|
||
/** | ||
* Whether to reuse the container for the JSch DevService. | ||
*/ | ||
@WithDefault("false") | ||
boolean reuse(); | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
deployment/src/main/java/io/quarkus/jsch/deployment/JSchDevServiceProcessor.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,44 @@ | ||
package io.quarkus.jsch.deployment; | ||
|
||
import java.util.Map; | ||
|
||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.utility.DockerImageName; | ||
|
||
import io.quarkus.deployment.IsNormal; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.annotations.BuildSteps; | ||
import io.quarkus.deployment.builditem.DevServicesResultBuildItem; | ||
import io.quarkus.deployment.dev.devservices.GlobalDevServicesConfig; | ||
|
||
@BuildSteps(onlyIfNot = IsNormal.class, onlyIf = GlobalDevServicesConfig.Enabled.class) | ||
public class JSchDevServiceProcessor { | ||
|
||
@BuildStep | ||
DevServicesResultBuildItem startDevServices(JSchBuildTimeConfig config) { | ||
if (!config.devservices().enabled()) { | ||
return null; | ||
} | ||
|
||
DockerImageName dockerImageName = DockerImageName.parse(config.devservices().image()); | ||
GenericContainer container = new GenericContainer<>(dockerImageName) | ||
.withEnv("USER_NAME", config.devservices().username()) | ||
.withEnv("USER_PASSWORD", config.devservices().password()) | ||
.withEnv("PASSWORD_ACCESS", "true") | ||
.withExposedPorts(config.devservices().port()) | ||
.withReuse(config.devservices().reuse()); | ||
|
||
container.start(); | ||
|
||
Map<String, String> configOverrides = Map.of( | ||
"quarkus.jsch.session.host", container.getHost(), | ||
"quarkus.jsch.session.port", container.getMappedPort(config.devservices().port()).toString(), | ||
"quarkus.jsch.session.username", config.devservices().username(), | ||
"quarkus.jsch.session.password", config.devservices().password(), | ||
"quarkus.jsch.session.config.StrictHostKeyChecking", "no"); | ||
|
||
return new DevServicesResultBuildItem.RunningDevService(JSchProcessor.FEATURE, container.getContainerId(), | ||
container::close, configOverrides) | ||
.toBuildItem(); | ||
} | ||
} |
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
38 changes: 38 additions & 0 deletions
38
deployment/src/main/java/io/quarkus/jsch/deployment/JSchSessionBuildItem.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,38 @@ | ||
package io.quarkus.jsch.deployment; | ||
|
||
import io.quarkus.builder.item.MultiBuildItem; | ||
|
||
/** | ||
* A build item that registers a JSch session created by annotation. | ||
*/ | ||
public final class JSchSessionBuildItem extends MultiBuildItem { | ||
|
||
private final String name; | ||
|
||
public JSchSessionBuildItem(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String name() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == this) { | ||
return true; | ||
} | ||
|
||
if (!(obj instanceof JSchSessionBuildItem)) { | ||
return false; | ||
} | ||
|
||
JSchSessionBuildItem other = (JSchSessionBuildItem) obj; | ||
return name.equals(other.name); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return name.hashCode(); | ||
} | ||
} |
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
Oops, something went wrong.