Skip to content

Commit 0bfc02b

Browse files
committed
#2072: enhance Helm configuration with pre-defined extraFields
1 parent 86081de commit 0bfc02b

File tree

5 files changed

+69
-5
lines changed

5 files changed

+69
-5
lines changed

deployment/helm/ditto/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ description: |
1616
A digital twin is a virtual, cloud based, representation of his real world counterpart
1717
(real world “Things”, e.g. devices like sensors, smart heating, connected cars, smart grids, EV charging stations etc).
1818
type: application
19-
version: 3.6.9 # chart version is effectively set by release-job
19+
version: 3.6.10 # chart version is effectively set by release-job
2020
appVersion: 3.6.9
2121
keywords:
2222
- iot-chart

deployment/helm/ditto/service-config/things-extension.conf.tpl

+40
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,46 @@ ditto {
4444
"{{$header}}"
4545
{{- end }}
4646
]
47+
pre-defined-extra-fields = [
48+
{{- range $index, $extraFieldConfig := .Values.things.config.event.preDefinedExtraFields }}
49+
{
50+
namespaces = [
51+
{{- range $index, $namespace := $extraFieldConfig.namespaces }}
52+
"{{$namespace}}"
53+
{{- end }}
54+
]
55+
{{- if $extraFieldConfig.condition }}
56+
condition = "{{$extraFieldConfig.condition}}"
57+
{{- end }}
58+
extra-fields = [
59+
{{- range $index, $extraField := $extraFieldConfig.extraFields }}
60+
"{{$extraField}}"
61+
{{- end }}
62+
]
63+
}
64+
{{- end }}
65+
]
66+
}
67+
message {
68+
pre-defined-extra-fields = [
69+
{{- range $index, $extraFieldConfig := .Values.things.config.message.preDefinedExtraFields }}
70+
{
71+
namespaces = [
72+
{{- range $index, $namespace := $extraFieldConfig.namespaces }}
73+
"{{$namespace}}"
74+
{{- end }}
75+
]
76+
{{- if $extraFieldConfig.condition }}
77+
condition = "{{$extraFieldConfig.condition}}"
78+
{{- end }}
79+
extra-fields = [
80+
{{- range $index, $extraField := $extraFieldConfig.extraFields }}
81+
"{{$extraField}}"
82+
{{- end }}
83+
]
84+
}
85+
{{- end }}
86+
]
4787
}
4888
}
4989

deployment/helm/ditto/values.yaml

+21
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,27 @@ things:
10591059
interval: 15m
10601060
# the threshold after how many changes to a Thing to do a snapshot
10611061
threshold: 50
1062+
# event contains configuration related to e.g. publishing of thing events
1063+
event:
1064+
# preDefinedExtraFields contains pre-defined (configured) extraFields to send along all thing (change) events
1065+
preDefinedExtraFields: []
1066+
# - namespaces:
1067+
# - "org.eclipse.ditto*"
1068+
# condition: "eq(attributes/foo,'RQL condition')"
1069+
# extraFields:
1070+
# - "definition"
1071+
# - "attributes/serial"
1072+
# message contains configuration related to distributing thing messages
1073+
message:
1074+
# preDefinedExtraFields contains pre-defined (configured) extraFields to send along all thing messages
1075+
preDefinedExtraFields: []
1076+
# - namespaces:
1077+
# - "namespace1"
1078+
# - "namespace2"
1079+
# condition: "eq(attributes/foo,'RQL condition')"
1080+
# extra-fields:
1081+
# - "definition"
1082+
# - "attributes/serial"
10621083
# entityCreation by default, Ditto allows anyone to create a new entity (thing in this case) in any namespace.
10631084
# However, this behavior can be customized, and the ability to create new entities can be restricted:
10641085
entityCreation:

things/service/src/main/java/org/eclipse/ditto/things/service/common/config/ThingMessageConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
public interface ThingMessageConfig {
2323

2424
/**
25-
* Contains pre-defined (configured) {@code extraFields} to send along all thing (change) messages.
25+
* Contains pre-defined (configured) {@code extraFields} to send along all thing messages.
2626
*
2727
* @return the pre-defined {@code extraFields} to send along.
2828
*/

things/service/src/main/java/org/eclipse/ditto/things/service/persistence/actors/enrichment/PreDefinedExtraFieldsEnricher.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,12 @@ public <T extends DittoHeadersSettable<? extends T>> CompletionStage<T> enrichWi
108108
if (null != thing && !preDefinedExtraFieldsConfigs.isEmpty()) {
109109
final List<PreDefinedExtraFieldsConfig> matchingPreDefinedFieldsConfigs =
110110
preDefinedExtraFieldsConfigs.stream()
111-
.filter(conf -> conf
112-
.getNamespace().stream()
113-
.anyMatch(pattern -> pattern.matcher(thingId.getNamespace()).matches())
111+
.filter(conf -> conf.getNamespace().isEmpty() ||
112+
conf.getNamespace()
113+
.stream()
114+
.anyMatch(pattern ->
115+
pattern.matcher(thingId.getNamespace()).matches()
116+
)
114117
)
115118
.filter(applyPredefinedExtraFieldsCondition(thing, withDittoHeaders))
116119
.toList();

0 commit comments

Comments
 (0)