Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add info endpoint contribution with version details #975

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-health-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-info-deployment-spi</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>crd-generator-api-v2</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.lang.annotation.Annotation;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
Expand Down Expand Up @@ -42,6 +43,7 @@
import io.quarkus.gizmo.MethodCreator;
import io.quarkus.gizmo.MethodDescriptor;
import io.quarkus.gizmo.ResultHandle;
import io.quarkus.info.deployment.spi.InfoBuildTimeValuesBuildItem;
import io.quarkus.runtime.QuarkusApplication;
import io.quarkus.runtime.metrics.MetricsFactory;

Expand Down Expand Up @@ -97,6 +99,15 @@ void setup(BuildProducer<IndexDependencyBuildItem> indexDependency,
new AdditionalIndexedClassesBuildItem(QuarkusControllerConfiguration.DefaultRateLimiter.class.getName()));
}

@BuildStep
void addInfo(VersionBuildItem versionBuildItem, BuildProducer<InfoBuildTimeValuesBuildItem> infoContributor) {
final var version = versionBuildItem.getVersion();
infoContributor.produce(new InfoBuildTimeValuesBuildItem("Quarkus Operator SDK", Map.of(
"Java Operator SDK version", version.getSdkCompleteVersion(),
"Quarkus Operator SDK version", version.getExtensionCompleteVersion(),
"Fabric8 effective version", version.getRuntimeFabric8Version())));
}

@BuildStep(onlyIf = IsDevelopment.class)
void addConsoleCommands(VersionBuildItem versionBuildItem, BuildProducer<ConsoleCommandBuildItem> commands) {
// register dev console commands
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ VersionBuildItem checkVersionsAlignment(BuildTimeOperatorConfiguration buildTime
log.info("QOSDK: " + version.getExtensionCompleteVersion());
log.info("JOSDK: " + version.getSdkCompleteVersion());

final var runtimeFabric8Version = io.fabric8.kubernetes.client.Version.clientVersion();
final var runtimeFabric8Version = version.getRuntimeFabric8Version();
log.info("Fabric8 (effective): " + runtimeFabric8Version);

final var runtimeQuarkusVersion = io.quarkus.builder.Version.getVersion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ public class Version extends io.javaoperatorsdk.operator.api.config.Version {
private final String extensionVersion;
private final String extensionBranch;
private final String extensionCommit;
private final String runtimeFabric8Version;
private final Date extensionBuildTime;

@RecordableConstructor // constructor needs to be recordable for the class to be passed around by Quarkus
public Version(String commit, Date builtTime, String extensionVersion, String extensionCommit,
String extensionBranch, Date extensionBuildTime) {
String extensionBranch, String runtimeFabric8Version, Date extensionBuildTime) {
super(commit, builtTime);
this.extensionVersion = extensionVersion;
this.extensionBranch = extensionBranch;
this.extensionCommit = extensionCommit;
this.runtimeFabric8Version = runtimeFabric8Version;
this.extensionBuildTime = extensionBuildTime;
}

Expand Down Expand Up @@ -66,6 +68,10 @@ public String getQuarkusVersion() {
return Versions.QUARKUS;
}

public String getRuntimeFabric8Version() {
return runtimeFabric8Version;
}

public static Version loadFromProperties() {
final var sdkVersion = Utils.VERSION;
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("extension-version.properties");
Expand Down Expand Up @@ -97,6 +103,7 @@ public static Version loadFromProperties() {
properties.getProperty("git.build.version", UNKNOWN),
properties.getProperty("git.commit.id.abbrev", UNKNOWN),
properties.getProperty("git.branch", UNKNOWN),
io.fabric8.kubernetes.client.Version.clientVersion(),
builtTime);
}
}