Bugfix in ShorthandsExpansionHelper
Change-Id: Ia4447b71b8cf5b176dd4058d138dd2bfa573a884
This commit is contained in:
parent
ecd1be7c6f
commit
82379b5013
@ -116,9 +116,7 @@ public class ClientInstallationProperties implements InitializingBean {
|
|||||||
|
|
||||||
private K8sClientInstallationProperties k8s = new K8sClientInstallationProperties();
|
private K8sClientInstallationProperties k8s = new K8sClientInstallationProperties();
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Data
|
@Data
|
||||||
@Configuration
|
|
||||||
public static class K8sClientInstallationProperties {
|
public static class K8sClientInstallationProperties {
|
||||||
private Map<String,String> extraEnvVars = new LinkedHashMap<>();
|
private Map<String,String> extraEnvVars = new LinkedHashMap<>();
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,8 @@ spec:
|
|||||||
value: 'DEFAULT_IP'
|
value: 'DEFAULT_IP'
|
||||||
- name: BAGUETTE_CLIENT_BASE_DIR
|
- name: BAGUETTE_CLIENT_BASE_DIR
|
||||||
value: '/opt/baguette-client'
|
value: '/opt/baguette-client'
|
||||||
|
# - name: LOGGING_LEVEL_GR_ICCS_IMU_EMS
|
||||||
|
# value: 'DEBUG'
|
||||||
- name: BAGUETTE_CLIENT_ID
|
- name: BAGUETTE_CLIENT_ID
|
||||||
valueFrom:
|
valueFrom:
|
||||||
fieldRef:
|
fieldRef:
|
||||||
|
@ -123,7 +123,6 @@ public class ShorthandsExpansionHelper {
|
|||||||
// ----- Expand Metric sensors -----
|
// ----- Expand Metric sensors -----
|
||||||
List<Object> expandedSensors = asList(ctx
|
List<Object> expandedSensors = asList(ctx
|
||||||
.read("$.spec.*.*.metrics.*[?(@.sensor)]", List.class)).stream()
|
.read("$.spec.*.*.metrics.*[?(@.sensor)]", List.class)).stream()
|
||||||
.filter(item -> JsonPath.read(item, "$.sensor") instanceof String)
|
|
||||||
.peek(this::expandSensor)
|
.peek(this::expandSensor)
|
||||||
.toList();
|
.toList();
|
||||||
log.debug("ShorthandsExpansionHelper: Sensors expanded: {}", expandedSensors);
|
log.debug("ShorthandsExpansionHelper: Sensors expanded: {}", expandedSensors);
|
||||||
@ -236,18 +235,38 @@ public class ShorthandsExpansionHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void expandSensor(Object spec) {
|
private void expandSensor(Object spec) {
|
||||||
log.debug("ShorthandsExpansionHelper.expandSensor: {}", spec);
|
log.debug("ShorthandsExpansionHelper.expandSensor: BEGIN: {}", spec);
|
||||||
String constraintStr = JsonPath.read(spec, "$.sensor").toString().trim();
|
Object sensorSpec = JsonPath.read(spec, "$.sensor");
|
||||||
Matcher matcher = METRIC_SENSOR_PATTERN.matcher(constraintStr);
|
log.trace("ShorthandsExpansionHelper.expandSensor: sensorSpec: {}", sensorSpec);
|
||||||
if (matcher.matches()) {
|
|
||||||
asMap(spec).put("sensor", Map.of(
|
String typeSpecStr = null;
|
||||||
"type", matcher.group(1),
|
if (sensorSpec instanceof String s) {
|
||||||
"config", Map.of(
|
typeSpecStr = s.trim();
|
||||||
EmsConstant.NETDATA_METRIC_KEY, matcher.group(2)
|
sensorSpec = new LinkedHashMap<>();
|
||||||
)
|
asMap(spec).put("sensor", sensorSpec);
|
||||||
));
|
|
||||||
} else
|
} else
|
||||||
throw createException("Invalid metric sensor shorthand expression: "+spec);
|
if (sensorSpec instanceof Map map) {
|
||||||
|
if (map.get("type")==null || !(map.get("type") instanceof String))
|
||||||
|
throw createException("Invalid metric sensor spec. No sensor type: " + spec);
|
||||||
|
typeSpecStr = map.get("type").toString().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(typeSpecStr)) {
|
||||||
|
Matcher matcher = METRIC_SENSOR_PATTERN.matcher(typeSpecStr);
|
||||||
|
if (matcher.matches()) {
|
||||||
|
asMap(sensorSpec).put("type", matcher.group(1));
|
||||||
|
Object sensorConfigSpec = asMap(sensorSpec).get("config");
|
||||||
|
Map<String, Object> sensorConfigMap = sensorConfigSpec == null
|
||||||
|
? new LinkedHashMap<>()
|
||||||
|
: asMap(sensorConfigSpec);
|
||||||
|
asMap(sensorSpec).put("config", sensorConfigMap);
|
||||||
|
sensorConfigMap.put(EmsConstant.NETDATA_METRIC_KEY, matcher.group(2));
|
||||||
|
} else {
|
||||||
|
asMap(sensorSpec).put("type", typeSpecStr);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
throw createException("Invalid metric sensor shorthand expression or sensor specification: " + spec);
|
||||||
|
log.trace("ShorthandsExpansionHelper.expandSensor: END: {}", spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*private void expandConstraint(Object spec) {
|
/*private void expandConstraint(Object spec) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user