Skip to content

Commit

Permalink
Need unqualified version
Browse files Browse the repository at this point in the history
  • Loading branch information
droberts195 committed Sep 27, 2023
1 parent 8acdedf commit c5be055
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 7 deletions.
8 changes: 8 additions & 0 deletions server/src/main/java/org/elasticsearch/Build.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,14 @@ public String qualifiedVersion() {
return version;
}

/**
* Get the build version without any suffices like "-SNAPSHOT" or "-rc1".
* @return the build version with no suffix
*/
public String unqualifiedVersion() {
return version.replaceFirst("-.*", "");
}

public boolean isProductionRelease() {
return isSnapshot() == false && version.matches(".*(-alpha\\d+)|(-beta\\d+)|(-rc\\d+)") == false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static String indexName() {
public static String mapping() {
return TemplateUtils.loadTemplate(
"/ml/config_index_mappings.json",
Build.current().version(), // Only needed for BWC with pre-8.10.0 nodes
Build.current().unqualifiedVersion(), // Only needed for BWC with pre-8.10.0 nodes
MAPPINGS_VERSION_VARIABLE,
Map.of("xpack.ml.managed.index.version", Integer.toString(CONFIG_INDEX_MAPPINGS_VERSION))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static String indexName() {
public static String mapping() {
return TemplateUtils.loadTemplate(
"/ml/meta_index_mappings.json",
Build.current().version(), // Only needed for BWC with pre-8.10.0 nodes
Build.current().unqualifiedVersion(), // Only needed for BWC with pre-8.10.0 nodes
MAPPINGS_VERSION_VARIABLE,
Map.of("xpack.ml.managed.index.version", Integer.toString(META_INDEX_MAPPINGS_VERSION))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static String wrappedMapping() {
public static String mapping() {
return TemplateUtils.loadTemplate(
"/ml/stats_index_mappings.json",
Build.current().version(), // Only needed for BWC with pre-8.10.0 nodes
Build.current().unqualifiedVersion(), // Only needed for BWC with pre-8.10.0 nodes
MAPPINGS_VERSION_VARIABLE,
Map.of("xpack.ml.managed.index.version", Integer.toString(STATS_INDEX_MAPPINGS_VERSION))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public static void createAnnotationsIndexIfNecessary(
public static String annotationsMapping() {
return TemplateUtils.loadTemplate(
"/ml/annotations_index_mappings.json",
Build.current().version(), // Only needed for BWC with pre-8.10.0 nodes
Build.current().unqualifiedVersion(), // Only needed for BWC with pre-8.10.0 nodes
MAPPINGS_VERSION_VARIABLE,
Map.of("xpack.ml.managed.index.version", Integer.toString(ANNOTATION_INDEX_MAPPINGS_VERSION))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public final class InferenceIndexConstants {
public static String mapping() {
return TemplateUtils.loadTemplate(
"/ml/inference_index_mappings.json",
Build.current().version(), // Only needed for BWC with pre-8.10.0 nodes
Build.current().unqualifiedVersion(), // Only needed for BWC with pre-8.10.0 nodes
MAPPINGS_VERSION_VARIABLE,
Map.of("xpack.ml.managed.index.version", Integer.toString(INFERENCE_INDEX_MAPPINGS_VERSION))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public static String wrappedResultsMapping() {
public static String resultsMapping() {
return TemplateUtils.loadTemplate(
RESOURCE_PATH + "results_index_mappings.json",
Build.current().version(), // Only needed for BWC with pre-8.10.0 nodes
Build.current().unqualifiedVersion(), // Only needed for BWC with pre-8.10.0 nodes
RESULTS_MAPPINGS_VERSION_VARIABLE,
Map.of("xpack.ml.managed.index.version", Integer.toString(RESULTS_INDEX_MAPPINGS_VERSION))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private NotificationsIndex() {}
public static String mapping() {
return TemplateUtils.loadTemplate(
RESOURCE_PATH + "notifications_index_mappings.json",
Build.current().version(), // Only needed for BWC with pre-8.10.0 nodes
Build.current().unqualifiedVersion(), // Only needed for BWC with pre-8.10.0 nodes
MAPPINGS_VERSION_VARIABLE,
Map.of("xpack.ml.managed.index.version", Integer.toString(NOTIFICATIONS_INDEX_MAPPINGS_VERSION))
);
Expand Down

0 comments on commit c5be055

Please sign in to comment.