Commit 0f28ea28 authored by iwakeh's avatar iwakeh
Browse files

Add build revision field to documents.

Implements task-23778.
parent e7cce268
......@@ -4,6 +4,8 @@
- Only set the "running" field in a bridge's details document to
true if the bridge is both contained in the last known bridge
network status and has the "Running" flag assigned there.
- Add build_revision to documents, if available.
- Update to metrics-lib 2.1.1.
* Minor changes
- Remove placeholder page on index.html.
......
......@@ -11,7 +11,7 @@
<property name="onionoo.protocol.version" value="4.1"/>
<property name="release.version"
value="${onionoo.protocol.version}-1.5.0-dev"/>
<property name="metricslibversion" value="2.1.0"/>
<property name="metricslibversion" value="2.1.1"/>
<property name="jetty.version" value="-9.2.21.v20170120" />
<property name="warfile"
value="onionoo-${release.version}.war"/>
......
......@@ -18,16 +18,37 @@ import com.google.gson.GsonBuilder;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
public class ResponseBuilder {
private static final Logger logger =
LoggerFactory.getLogger(ResponseBuilder.class);
private DocumentStore documentStore;
private String buildRevision;
/** Initialize document store and the build revision. */
public ResponseBuilder() {
this.documentStore = DocumentStoreFactory.getDocumentStore();
Properties buildProperties = new Properties();
try (InputStream is = getClass().getClassLoader()
.getResourceAsStream("onionoo.buildrevision.properties")) {
buildProperties.load(is);
buildRevision = buildProperties.getProperty("onionoo.build.revision",
null);
} catch (Exception ex) {
// We create documents anyway: only log a warning.
logger.warn("No build revision available.", ex);
buildRevision = null;
}
}
private String resourceType;
......@@ -112,6 +133,9 @@ public class ResponseBuilder {
this.write(pw, "\"next_major_version_scheduled\":\"%s\",\n",
NEXT_MAJOR_VERSION_SCHEDULED);
}
if (null != buildRevision) {
this.write(pw, "\"build_revision\":\"%s\",\n", buildRevision);
}
this.write(pw, "\"relays_published\":\"%s\",\n",
this.relaysPublishedString);
if (this.relaysSkipped > 0) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment