Skip to content

Commit

Permalink
fix labels from env (#12604)
Browse files Browse the repository at this point in the history
* 修复环境变量设置标签失效bug

* pmd
 fix
  • Loading branch information
shiyiyue1102 authored Sep 5, 2024
1 parent 38a204c commit feb4c09
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public class DefaultLabelsCollector implements LabelsCollector {

private static final String UNDERSCORE = "_";

private static final String ESCAPE = "\\";

/**
* init labels.
*
Expand Down Expand Up @@ -79,12 +81,12 @@ public Map<String, String> collectLabels(Properties properties) {

//env
LOGGER.info("default nacos collect env raw labels: {}",
System.getenv(Constants.APP_CONN_LABELS_KEY.replaceAll(DOT, UNDERSCORE)));
System.getenv(Constants.APP_CONN_LABELS_KEY.replaceAll(ESCAPE + DOT, UNDERSCORE)));
Map<String, String> envLabels = ConnLabelsUtils.parseRawLabels(
System.getenv(Constants.APP_CONN_LABELS_KEY.replaceAll(DOT, UNDERSCORE)));
if (System.getenv(Constants.CONFIG_GRAY_LABEL.replaceAll(DOT, UNDERSCORE)) != null) {
System.getenv(Constants.APP_CONN_LABELS_KEY.replaceAll(ESCAPE + DOT, UNDERSCORE)));
if (System.getenv(Constants.CONFIG_GRAY_LABEL.replaceAll(ESCAPE + DOT, UNDERSCORE)) != null) {
envLabels.put(Constants.CONFIG_GRAY_LABEL,
System.getenv(Constants.CONFIG_GRAY_LABEL.replaceAll(DOT, UNDERSCORE)));
System.getenv(Constants.CONFIG_GRAY_LABEL.replaceAll(ESCAPE + DOT, UNDERSCORE)));
}
LOGGER.info("default nacos collect env labels: {}", envLabels);

Expand Down

0 comments on commit feb4c09

Please sign in to comment.