Alon Bar-Lev has uploaded a new change for review.
Change subject: core: config: provide expand string for configuration
......................................................................
core: config: provide expand string for configuration
allow to expand strings such as "${ENGINE_ETC}/config" to proper value.
handy for various of configuration locations.
Change-Id: Ic54791d7ab6faa385a153158f21555a3d8ca49da
Signed-off-by: Alon Bar-Lev <[email protected]>
---
M
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/LocalConfig.java
1 file changed, 25 insertions(+), 13 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/47/14447/1
diff --git
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/LocalConfig.java
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/LocalConfig.java
index b241ca9..4919ac7 100644
---
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/LocalConfig.java
+++
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/LocalConfig.java
@@ -152,6 +152,29 @@
}
/**
+ * Expand string using current variables.
+ *
+ * @return Expanded string.
+ * @param value String.
+ */
+ public String expandString(String value) {
+ for (;;) {
+ Matcher refMatch = REF_EXPR.matcher(value);
+ if (!refMatch.find()) {
+ break;
+ }
+ String refKey = refMatch.group(1);
+ String refValue = values.get(refKey);
+ if (refValue == null) {
+ break;
+ }
+ value = value.substring(0, refMatch.start()) + refValue +
value.substring(refMatch.end());
+ }
+
+ return value;
+ }
+
+ /**
* Load the contents of a line from a properties file, expanding
* references to variables.
*
@@ -183,19 +206,8 @@
value = value.substring(1, value.length() - 1);
}
- // Expand references to other parameters:
- for (;;) {
- Matcher refMatch = REF_EXPR.matcher(value);
- if (!refMatch.find()) {
- break;
- }
- String refKey = refMatch.group(1);
- String refValue = values.get(refKey);
- if (refValue == null) {
- break;
- }
- value = value.substring(0, refMatch.start()) + refValue +
value.substring(refMatch.end());
- }
+ // Expand nested variables
+ value = expandString(value);
// Update the values:
values.put(key, value);
--
To view, visit http://gerrit.ovirt.org/14447
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic54791d7ab6faa385a153158f21555a3d8ca49da
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches