Skip to content

Commit

Permalink
Revert "Mark legacy stack templates as deprecated (elastic#101476)" (e…
Browse files Browse the repository at this point in the history
…lastic#101935)

* Revert "Mark legacy stack templates as deprecated (elastic#101476)"

This reverts commit 16cce1f.

* Remove test that was part of revert conflict

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
dakrone and elasticmachine authored Nov 8, 2023
1 parent 57acc1c commit 2ebd084
Show file tree
Hide file tree
Showing 33 changed files with 69 additions and 277 deletions.
5 changes: 0 additions & 5 deletions docs/changelog/101476.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,15 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Map;

public class ResourceUtils {

public static final String APM_TEMPLATE_VERSION_VARIABLE = "xpack.apmdata.template.version";

static byte[] loadVersionedResourceUTF8(String name, int version) {
return loadVersionedResourceUTF8(name, version, Map.of());
}

static byte[] loadVersionedResourceUTF8(String name, int version, Map<String, String> variables) {
try {
String content = loadResource(name);
content = TemplateUtils.replaceVariables(content, String.valueOf(version), APM_TEMPLATE_VERSION_VARIABLE, variables);
content = TemplateUtils.replaceVariable(content, APM_TEMPLATE_VERSION_VARIABLE, String.valueOf(version));
return content.getBytes(StandardCharsets.UTF_8);
} catch (IOException e) {
throw new RuntimeException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public XContentType getXContentType() {

@Override
public BytesReference loadConfig() {
return new BytesArray(loadVersionedResourceUTF8("/ingest-pipelines/" + id + ".yaml", version, variables));
return new BytesArray(loadVersionedResourceUTF8("/ingest-pipelines/" + id + ".yaml", version));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
Expand All @@ -23,7 +22,6 @@ public abstract class IngestPipelineConfig {
protected final String resource;
protected final int version;
protected final String versionProperty;
protected final Map<String, String> variables;

/**
* A list of this pipeline's dependencies, for example - such referred to through a pipeline processor.
Expand All @@ -37,23 +35,11 @@ public IngestPipelineConfig(String id, String resource, int version, String vers
}

public IngestPipelineConfig(String id, String resource, int version, String versionProperty, List<String> dependencies) {
this(id, resource, version, versionProperty, dependencies, Map.of());
}

public IngestPipelineConfig(
String id,
String resource,
int version,
String versionProperty,
List<String> dependencies,
Map<String, String> variables
) {
this.id = Objects.requireNonNull(id);
this.resource = Objects.requireNonNull(resource);
this.version = version;
this.versionProperty = Objects.requireNonNull(versionProperty);
this.dependencies = dependencies;
this.variables = Objects.requireNonNull(variables);
}

public String getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.elasticsearch.xcontent.XContentType;

import java.util.List;
import java.util.Map;

public class JsonIngestPipelineConfig extends IngestPipelineConfig {
public JsonIngestPipelineConfig(String id, String resource, int version, String versionProperty) {
Expand All @@ -23,24 +22,13 @@ public JsonIngestPipelineConfig(String id, String resource, int version, String
super(id, resource, version, versionProperty, dependencies);
}

public JsonIngestPipelineConfig(
String id,
String resource,
int version,
String versionProperty,
List<String> dependencies,
Map<String, String> variables
) {
super(id, resource, version, versionProperty, dependencies, variables);
}

@Override
public XContentType getXContentType() {
return XContentType.JSON;
}

@Override
public BytesReference loadConfig() {
return new BytesArray(TemplateUtils.loadTemplate(resource, String.valueOf(version), versionProperty, variables));
return new BytesArray(TemplateUtils.loadTemplate(resource, String.valueOf(version), versionProperty));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static void validate(String source) {
}
}

public static String replaceVariables(String input, String version, String versionProperty, Map<String, String> variables) {
private static String replaceVariables(String input, String version, String versionProperty, Map<String, String> variables) {
String template = replaceVariable(input, versionProperty, version);
for (Map.Entry<String, String> variable : variables.entrySet()) {
template = replaceVariable(template, variable.getKey(), variable.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,5 @@
"_meta": {
"description": "built-in ILM policy using the hot, warm, and cold phases with a retention of 180 days",
"managed": true
},
"deprecated": ${xpack.stack.template.deprecated}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,5 @@
"_meta": {
"description": "built-in ILM policy using the hot and warm phases with a retention of 30 days",
"managed": true
},
"deprecated": ${xpack.stack.template.deprecated}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,5 @@
"_meta": {
"description": "built-in ILM policy using the hot, warm, and cold phases with a retention of 365 days",
"managed": true
},
"deprecated": ${xpack.stack.template.deprecated}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,5 @@
"_meta": {
"description": "built-in ILM policy using the hot and warm phases with a retention of 7 days",
"managed": true
},
"deprecated": ${xpack.stack.template.deprecated}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,5 @@
"_meta": {
"description": "built-in ILM policy using the hot, warm, and cold phases with a retention of 90 days",
"managed": true
},
"deprecated": ${xpack.stack.template.deprecated}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,5 @@
"description": "general mapping conventions for data streams",
"managed": true
},
"version": ${xpack.stack.template.version},
"deprecated": ${xpack.stack.template.deprecated}
"version": ${xpack.stack.template.version}
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,5 @@
"description": "dynamic mappings based on ECS, installed by x-pack",
"managed": true
},
"version": ${xpack.stack.template.version},
"deprecated": ${xpack.stack.template.deprecated}
"version": ${xpack.stack.template.version}
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,5 @@
"description": "default kibana reporting template installed by elasticsearch",
"managed": true
},
"version": ${xpack.stack.template.version},
"deprecated": ${xpack.stack.template.deprecated}
"version": ${xpack.stack.template.version}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@
"description": "default pipeline for the logs index template installed by x-pack",
"managed": true
},
"version": ${xpack.stack.template.version},
"deprecated": ${xpack.stack.template.deprecated}
"version": ${xpack.stack.template.version}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,5 @@
"description": "automatic parsing of JSON log messages",
"managed": true
},
"version": ${xpack.stack.template.version},
"deprecated": ${xpack.stack.template.deprecated}
"version": ${xpack.stack.template.version}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@
"_meta": {
"description": "default policy for the logs index template installed by x-pack",
"managed": true
},
"deprecated": ${xpack.stack.template.deprecated}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@
"description": "default mappings for the logs index template installed by x-pack",
"managed": true
},
"version": ${xpack.stack.template.version},
"deprecated": ${xpack.stack.template.deprecated}
"version": ${xpack.stack.template.version}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@
"description": "default settings for the logs index template installed by x-pack",
"managed": true
},
"version": ${xpack.stack.template.version},
"deprecated": ${xpack.stack.template.deprecated}
"version": ${xpack.stack.template.version}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@
"description": "default logs template installed by x-pack",
"managed": true
},
"version": ${xpack.stack.template.version},
"deprecated": ${xpack.stack.template.deprecated}
"version": ${xpack.stack.template.version}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@
"_meta": {
"description": "default policy for the metrics index template installed by x-pack",
"managed": true
},
"deprecated": ${xpack.stack.template.deprecated}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,5 @@
"description": "default mappings for the metrics index template installed by x-pack",
"managed": true
},
"version": ${xpack.stack.template.version},
"deprecated": ${xpack.stack.template.deprecated}
"version": ${xpack.stack.template.version}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
"description": "default settings for the metrics index template installed by x-pack",
"managed": true
},
"version": ${xpack.stack.template.version},
"deprecated": ${xpack.stack.template.deprecated}
"version": ${xpack.stack.template.version}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@
"description": "default metrics template installed by x-pack",
"managed": true
},
"version": ${xpack.stack.template.version},
"deprecated": ${xpack.stack.template.deprecated}
"version": ${xpack.stack.template.version}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@
"description": "default settings for the metrics index template installed by x-pack",
"managed": true
},
"version": ${xpack.stack.template.version},
"deprecated": ${xpack.stack.template.deprecated}
"version": ${xpack.stack.template.version}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@
"_meta": {
"description": "default policy for the synthetics index template installed by x-pack",
"managed": true
},
"deprecated": ${xpack.stack.template.deprecated}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@
"description": "default mappings for the synthetics index template installed by x-pack",
"managed": true
},
"version": ${xpack.stack.template.version},
"deprecated": ${xpack.stack.template.deprecated}
"version": ${xpack.stack.template.version}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@
"description": "default settings for the synthetics index template installed by x-pack",
"managed": true
},
"version": ${xpack.stack.template.version},
"deprecated": ${xpack.stack.template.deprecated}
"version": ${xpack.stack.template.version}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@
"description": "default synthetics template installed by x-pack",
"managed": true
},
"version": ${xpack.stack.template.version},
"deprecated": ${xpack.stack.template.deprecated}
"version": ${xpack.stack.template.version}
}
Loading

0 comments on commit 2ebd084

Please sign in to comment.