mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(core): report the build version when FLOCI_VERSION is unset (#5768)
/health, /_floci/health and the TLS certificate metadata read FLOCI_VERSION and fell back to "dev". Only the Docker images set it, so a native binary run on the host reported "dev" and the floci-cli version check skipped it. One FlociVersion helper now resolves FLOCI_VERSION first, then the version the Maven build stamps into floci/version.properties (filtered, and included in the native image), and "dev" only when neither is known. It replaces five copies of the lookup. Refs #5767 Signed-off-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
1 parent
21184df828
commit
db8c441ed4
12 files changed
+126
-48
No files matched your search
@@ -0,0 +1,36 @@
|
||||
package io.github.hectorvent.floci.config;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.matchesPattern;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
||||
class FlociVersionTest {
|
||||
|
||||
@Test
|
||||
void overrideWinsOverBuildVersion() {
|
||||
assertThat(FlociVersion.resolve("nightly-10152026", "2.3.0"), equalTo("nightly-10152026"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void blankOverrideFallsBackToBuildVersion() {
|
||||
assertThat(FlociVersion.resolve(" ", "2.3.0"), equalTo("2.3.0"));
|
||||
assertThat(FlociVersion.resolve(null, "2.3.0"), equalTo("2.3.0"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void devOnlyWhenNoVersionIsKnown() {
|
||||
assertThat(FlociVersion.resolve(null, null), equalTo("dev"));
|
||||
assertThat(FlociVersion.resolve("", " "), equalTo("dev"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void buildStampsTheProjectVersion() {
|
||||
// Only meaningful when FLOCI_VERSION is unset, which is how the suite runs.
|
||||
String version = FlociVersion.current();
|
||||
assertThat(version, not(equalTo("dev")));
|
||||
assertThat(version, matchesPattern("\\d+\\.\\d+\\.\\d+.*"));
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -179,8 +179,8 @@ class TlsConfigSourceMetadataPersistenceTest {
|
||||
|
||||
assertNotNull(metadata.getFlociVersion(),
|
||||
"Metadata should contain flociVersion");
|
||||
assertEquals("dev", metadata.getFlociVersion(),
|
||||
"Version should default to 'dev' when FLOCI_VERSION not set");
|
||||
assertEquals(FlociVersion.current(), metadata.getFlociVersion(),
|
||||
"Metadata should record the version this build reports");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-2
@@ -2,6 +2,7 @@ package io.github.hectorvent.floci.lifecycle;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.config.FlociVersion;
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.response.ValidatableResponse;
|
||||
@@ -57,7 +58,7 @@ class EmulatorInfoControllerIntegrationTest {
|
||||
JsonNode tree = MAPPER.readTree(body);
|
||||
assertEquals("community", tree.get("edition").asText());
|
||||
assertEquals("floci-always-free", tree.get("original_edition").asText());
|
||||
assertEquals("dev", tree.get("version").asText());
|
||||
assertEquals(FlociVersion.current(), tree.get("version").asText());
|
||||
|
||||
JsonNode services = tree.get("services");
|
||||
assertNotNull(services, "services field must be present");
|
||||
@@ -94,7 +95,7 @@ class EmulatorInfoControllerIntegrationTest {
|
||||
.statusCode(200)
|
||||
.contentType("application/json")
|
||||
.body("edition", equalTo("community"))
|
||||
.body("version", notNullValue())
|
||||
.body("version", allOf(equalTo(FlociVersion.current()), not(equalTo("dev"))))
|
||||
.body("dynamodb_backend", equalTo("native"));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user