Skip to content

Commit

Permalink
Migrate to ConfigMapping using interface because, well idk.
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-simons committed Aug 26, 2024
1 parent eb7482b commit 27dd2d9
Show file tree
Hide file tree
Showing 14 changed files with 303 additions and 293 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,7 @@ target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
release.properties
release.properties

# Genrated docs don't belong in the repo
docs/modules/ROOT/pages/includes/quarkus-neo4j_quarkus.neo4j.adoc

This comment has been minimized.

Copy link
@gastaldi

gastaldi Aug 26, 2024

Member

Actually it should belong in the repository, otherwise, it will not be shown in https://docs.quarkiverse.io/index/explore/index.html, since Antora does not invoke a Maven build

This comment has been minimized.

Copy link
@michael-simons

michael-simons Aug 26, 2024

Author Contributor

🤦 yikes. Not a fan.

This comment has been minimized.

Copy link
@gastaldi

gastaldi Aug 26, 2024

Member

This certainly has room for improvement, we're open for suggestions 😉

This comment has been minimized.

Copy link
@michael-simons

michael-simons Aug 26, 2024

Author Contributor

So, how does it than generated in an updated fashion? Let's say stupid me just pushes a config change without verifying it locally and run away?

This comment has been minimized.

Copy link
@gastaldi

gastaldi Aug 26, 2024

Member

As of now, the release workflow will catch and push it: #280, but it's always a good idea to build locally before pushing a config change :)

This comment has been minimized.

Copy link
@michael-simons

michael-simons Aug 26, 2024

Author Contributor

Sure is, and as I did, I noted the sudden appearance.

And aha, that's what the change is about I approved. Thanks.

Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,47 @@
import java.util.OptionalInt;

import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;
import io.smallrye.config.WithDefault;

@ConfigGroup
public class DevServicesBuildTimeConfig {
public interface DevServicesBuildTimeConfig {

/**
* If DevServices has been explicitly enabled or disabled. DevServices is generally enabled
* by default, unless there is an existing configuration present.
* When DevServices is enabled Quarkus will attempt to automatically configure and start
* a database when running in Dev or Test mode.
*
* @return whether dev services are enabled or not
*/
@ConfigItem
public Optional<Boolean> enabled = Optional.empty();
Optional<Boolean> enabled();

/**
* The container image name to use, for container based DevServices providers.
* {@return the container image name to use, for container based DevServices providers}
*/
@ConfigItem(defaultValue = "neo4j:5")
public String imageName;
@WithDefault("neo4j:5")
String imageName();

/**
* Additional environment entries that can be added to the container before its start.
* {@return additional environment entries that can be added to the container before its start}
*/
@ConfigItem
public Map<String, String> additionalEnv;
Map<String, String> additionalEnv();

/**
* This value can be used to specify the port to which the bolt-port of the container is exposed. It must be a free
* port, otherwise startup will fail. A random, free port will be used by default. Either way, a messsage will be
* logged on which port the Neo4j container is reachable over bolt.
*
* @return a specific port to bind the containers bolt-port to
*/
@ConfigItem
public OptionalInt boltPort = OptionalInt.empty();
OptionalInt boltPort();

/**
* This value can be used to specify the port to which the http-port of the container is exposed. It must be a free
* port, otherwise startup will fail. A random, free port will be used by default. Either way, a messsage will be
* logged on which port the Neo4j Browser is available.
*
* @return a specific port to bind the containers http-port to
*/
@ConfigItem
public OptionalInt httpPort = OptionalInt.empty();
OptionalInt httpPort();
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
package io.quarkus.neo4j.deployment;

import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefault;
import io.smallrye.config.WithName;

@ConfigRoot(name = "neo4j", phase = ConfigPhase.BUILD_TIME)
public class Neo4jBuildTimeConfig {
@ConfigMapping(prefix = "quarkus.neo4j")
@ConfigRoot(phase = ConfigPhase.BUILD_TIME)
public interface Neo4jBuildTimeConfig {

/**
* Whether a health check is published in case the smallrye-health extension is present.
* {@return whether a health check is published in case the smallrye-health extension is present}
*/
@ConfigItem(name = "health.enabled", defaultValue = "true")
public boolean healthEnabled;
@WithName("health.enabled")
@WithDefault("true")
boolean healthEnabled();

/**
* Configuration for DevServices. DevServices allows Quarkus to automatically start a Neo4j instance in dev and test mode.
* DevServices allows Quarkus to automatically start a Neo4j instance in dev and test mode.
* {@return Configuration for DevServices}
*/
@ConfigItem
public DevServicesBuildTimeConfig devservices;
DevServicesBuildTimeConfig devservices();
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public DevServicesResultBuildItem startNeo4jDevService(
LoggingSetupBuildItem loggingSetupBuildItem,
GlobalDevServicesConfig globalDevServicesConfig) {

var configuration = new Neo4jDevServiceConfig(neo4jBuildTimeConfig.devservices);
var configuration = new Neo4jDevServiceConfig(neo4jBuildTimeConfig.devservices());

if (devService != null) {
if (configuration.equals(runningConfiguration)) {
Expand Down Expand Up @@ -213,10 +213,10 @@ private static final class Neo4jDevServiceConfig {

Neo4jDevServiceConfig(DevServicesBuildTimeConfig devServicesConfig) {
this.devServicesEnabled = enabled(devServicesConfig);
this.imageName = devServicesConfig.imageName;
this.additionalEnv = new HashMap<>(devServicesConfig.additionalEnv);
this.fixedBoltPort = devServicesConfig.boltPort;
this.fixedHttpPort = devServicesConfig.httpPort;
this.imageName = devServicesConfig.imageName();
this.additionalEnv = new HashMap<>(devServicesConfig.additionalEnv());
this.fixedBoltPort = devServicesConfig.boltPort();
this.fixedHttpPort = devServicesConfig.httpPort();
}

@Override
Expand Down Expand Up @@ -248,6 +248,6 @@ public int hashCode() {
* @return {@literal true} if Neo4j dev services are enabled or not
*/
static boolean enabled(DevServicesBuildTimeConfig devServicesConfig) {
return Optional.ofNullable(devServicesConfig).flatMap(cfg -> cfg.enabled).orElse(true);
return Optional.ofNullable(devServicesConfig).flatMap(DevServicesBuildTimeConfig::enabled).orElse(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ CardPageBuildItem create(
Neo4jBuildTimeConfig neo4jBuildTimeConfig) {

var cardPageBuildItem = new CardPageBuildItem();
if (Neo4jDevServicesProcessor.enabled(neo4jBuildTimeConfig.devservices)) {
if (Neo4jDevServicesProcessor.enabled(neo4jBuildTimeConfig.devservices())) {

// Find the appropriate config
for (DevServicesResultBuildItem runningDevService : runningDevServices) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Neo4jDriverBuildItem configureDriverProducer(Neo4jDriverRecorder recorder,
@BuildStep
HealthBuildItem addHealthCheck(Neo4jBuildTimeConfig buildTimeConfig) {
return new HealthBuildItem("io.quarkus.neo4j.runtime.health.Neo4jHealthCheck",
buildTimeConfig.healthEnabled);
buildTimeConfig.healthEnabled());
}

@BuildStep
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/includes/attributes.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:quarkus-version: 3.13.2
:quarkus-version: 3.14.0
:quarkus-neo4j-version: 4.2.2
:maven-version: 3.8.1+

Expand Down
Loading

0 comments on commit 27dd2d9

Please sign in to comment.