我有一个像这样声明的 helm 值文件
role: agent
customConfig:
data_dir: /vector-data-dir
api:
enabled: false
sources:
graph-node-logs:
type: kubernetes_logs
extra_label_selector: "graph-node-indexer=true"
transforms:
parse_graph_node_logs:
inputs:
- graph-node-logs
type: remap
source: >
# Extract timestamp, severity and message
# we ignore the timestamp as explained below
regexed = parse_regex!(.message, r'^(?P<timestamp>\w\w\w \d\d \d\d:\d\d:\d\d\.\d\d\d) (?P<severity>[A-Z]+) (?P<message>.*)$')
# From the message, extract the subgraph id (the ipfs hash)
message_parts = split(regexed.message, ", ", 2)
structured = parse_key_value(message_parts[1], key_value_delimiter: ":", field_delimiter: ",") ?? {}
# construct the final fields we care about which are the subgraph id, the
severity, the message and the unix timestamp
final_fields = {}
final_fields.subgraph_id = structured.subgraph_id
final_fields.message = regexed.message
final_fields.severity = regexed.severity
# graph node does not emit time zone information and thus we can't use the timestamp we extract
# because we can't coerce the extracted timestamp into an umabiguous timestamp. Therefore,
# we use the timestamp of the log event instead as seen by the source plugin (docker-logs)
final_fields.unix_timestamp = to_unix_timestamp!(.timestamp || now(), unit: "milliseconds")
# Add the final fields to the root object. The clickhouse integration below will discard fields unknown to the schema.
. |= final_fields
sinks:
stdout:
type: console
encoding:
codec: json
target: stdout
inputs:
- parse_graph_node_logs
service:
enabled: false
我在 typescript cdktf 构造中使用这个值文件,就像这样
const valuesAsset = new TerraformAsset(this, "vector-values", {
path: `./${EnvConfig.name}-values.yaml`,
type: AssetType.FILE,
});
new helm.Release(this, "vector", {
repository: "https://helm.vector.dev",
chart: "vector",
name: "vector",
version: "0.21.1",
values: [Fn.file(valuesAsset.path)],
});
但是,当这个值文件通过管道传输到 helm chart 中,然后创建一个 configmap 时,我看到
transforms.parse_graph_node_logs.source
的多行值没有得到尊重:
❯❯❯ k get configmap -o yaml vector
apiVersion: v1
data:
vector.yaml: |
api:
enabled: false
data_dir: /vector-data-dir
sinks:
stdout:
encoding:
codec: json
inputs:
- parse_graph_node_logs
target: stdout
type: console
sources:
graph-node-logs:
extra_label_selector: graph-node-indexer=true
type: kubernetes_logs
transforms:
parse_graph_node_logs:
inputs:
- graph-node-logs
source: |
# Extract timestamp, severity and message # we ignore the timestamp as explained below regexed = parse_regex!(.message, r'^(?P<timestamp>\w\w\w \d\d \d\d:\d\d:\d\d\.\d\d\d) (?P<severity>[A-Z]+) (?P<message>.*)$')
# From the message, extract the subgraph id (the ipfs hash) message_parts = split(regexed.message, ", ", 2) structured = parse_key_value(message_parts[1], key_value_delimiter: ":", field_delimiter: ",") ?? {}
# construct the final fields we care about which are the subgraph id, the severity, the message and the unix timestamp final_fields = {} final_fields.subgraph_id = structured.subgraph_id final_fields.message = regexed.message final_fields.severity = regexed.severity
# graph node does not emit time zone information and thus we can't use the timestamp we extract # because we can't coerce the extracted timestamp into an umabiguous timestamp. Therefore, # we use the timestamp of the log event instead as seen by the source plugin (docker-logs) final_fields.unix_timestamp = to_unix_timestamp!(.timestamp || now(), unit: "milliseconds")
# Add the final fields to the root object. The clickhouse integration below will discard fields unknown to the schema. . |= final_fields
type: remap
kind: ConfigMap
metadata:
annotations:
meta.helm.sh/release-name: vector
meta.helm.sh/release-namespace: default
creationTimestamp: "2023-05-18T14:10:45Z"
labels:
app.kubernetes.io/component: Agent
app.kubernetes.io/instance: vector
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: vector
app.kubernetes.io/version: 0.29.1-distroless-libc
helm.sh/chart: vector-0.21.1
name: vector
namespace: default
resourceVersion: "307030904"
uid: d9fabff2-426d-47aa-8298-4935ddef1d42
如何让 cdktf 尊重这个多行值文件?