Skip to content

Commit c907aa2

Browse files
iocanelgastaldi
andauthored
Produce build item with gitea service info (#147)
* feat: produce build item with gitea service info * Cleanup GiteaDevServiceInfoBuildItem * Show create user cmd in debug only --------- Co-authored-by: George Gastaldi <[email protected]>
1 parent 0bbc7ef commit c907aa2

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed

deployment/src/main/java/io/quarkus/jgit/deployment/GiteaContainer.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private void createAdminUser() throws IOException, InterruptedException {
6262
"--must-change-password=false",
6363
"--admin"
6464
};
65-
log.info(String.join(" ", cmd));
65+
log.debug(String.join(" ", cmd));
6666
ExecResult execResult = execInContainer(cmd);
6767
log.info(execResult.getStdout());
6868
if (execResult.getExitCode() != 0) {
@@ -71,6 +71,10 @@ private void createAdminUser() throws IOException, InterruptedException {
7171
}
7272

7373
public String getHttpUrl() {
74-
return "http://" + getHost() + ":" + getMappedPort(HTTP_PORT);
74+
return "http://" + getHost() + ":" + getHttpPort();
75+
}
76+
77+
public int getHttpPort() {
78+
return getMappedPort(HTTP_PORT);
7579
}
7680
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package io.quarkus.jgit.deployment;
2+
3+
import io.quarkus.builder.item.SimpleBuildItem;
4+
5+
/**
6+
* A build item that represents the information required to connect to a Gitea dev service.
7+
*/
8+
public final class GiteaDevServiceInfoBuildItem extends SimpleBuildItem {
9+
10+
private final String host;
11+
private final int httpPort;
12+
private final String adminUsername;
13+
private final String adminPassword;
14+
15+
public GiteaDevServiceInfoBuildItem(String host, int httpPort, String adminUsername, String adminPassword) {
16+
this.host = host;
17+
this.httpPort = httpPort;
18+
this.adminUsername = adminUsername;
19+
this.adminPassword = adminPassword;
20+
}
21+
22+
public int httpPort() {
23+
return httpPort;
24+
}
25+
26+
public String host() {
27+
return host;
28+
}
29+
30+
public String adminUsername() {
31+
return adminUsername;
32+
}
33+
34+
public String adminPassword() {
35+
return adminPassword;
36+
}
37+
38+
}

deployment/src/main/java/io/quarkus/jgit/deployment/JGitDevServicesProcessor.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.jboss.logging.Logger;
77

88
import io.quarkus.deployment.IsNormal;
9+
import io.quarkus.deployment.annotations.BuildProducer;
910
import io.quarkus.deployment.annotations.BuildStep;
1011
import io.quarkus.deployment.builditem.CuratedApplicationShutdownBuildItem;
1112
import io.quarkus.deployment.builditem.DevServicesResultBuildItem;
@@ -20,7 +21,8 @@ public class JGitDevServicesProcessor {
2021

2122
@BuildStep(onlyIfNot = IsNormal.class, onlyIf = { GlobalDevServicesConfig.Enabled.class, DevServicesEnabled.class })
2223
DevServicesResultBuildItem createContainer(JGitBuildTimeConfig config,
23-
CuratedApplicationShutdownBuildItem closeBuildItem) {
24+
CuratedApplicationShutdownBuildItem closeBuildItem,
25+
BuildProducer<GiteaDevServiceInfoBuildItem> giteaServiceInfo) {
2426
if (devService != null) {
2527
// only produce DevServicesResultBuildItem when the dev service first starts.
2628
return null;
@@ -34,6 +36,13 @@ DevServicesResultBuildItem createContainer(JGitBuildTimeConfig config,
3436
ContainerShutdownCloseable closeable = new ContainerShutdownCloseable(gitServer, JGitProcessor.FEATURE);
3537
closeBuildItem.addCloseTask(closeable::close, true);
3638
devService = new RunningDevService(JGitProcessor.FEATURE, gitServer.getContainerId(), closeable, configOverrides);
39+
40+
giteaServiceInfo.produce(
41+
new GiteaDevServiceInfoBuildItem(
42+
gitServer.getHost(),
43+
gitServer.getHttpPort(),
44+
config.devservices().adminUsername(),
45+
config.devservices().adminPassword()));
3746
return devService.toBuildItem();
3847
}
3948

0 commit comments

Comments
 (0)