ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject ambari git commit: AMBARI-13256 configs.sh cannot add name-value pair to an empty config (dsen)
Date Tue, 29 Sep 2015 13:23:21 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 8a5b6388b -> d588d4fc3


AMBARI-13256 configs.sh cannot add name-value pair to an empty config (dsen)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d588d4fc
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d588d4fc
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d588d4fc

Branch: refs/heads/branch-2.1
Commit: d588d4fc342282ec703219e8392f767be9cf1a5b
Parents: 8a5b638
Author: Dmytro Sen <dsen@apache.org>
Authored: Tue Sep 29 16:21:03 2015 +0300
Committer: Dmytro Sen <dsen@apache.org>
Committed: Tue Sep 29 16:23:11 2015 +0300

----------------------------------------------------------------------
 .../src/main/resources/scripts/configs.sh       | 21 ++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d588d4fc/ambari-server/src/main/resources/scripts/configs.sh
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/scripts/configs.sh b/ambari-server/src/main/resources/scripts/configs.sh
index a32ff42..ba02d2d 100755
--- a/ambari-server/src/main/resources/scripts/configs.sh
+++ b/ambari-server/src/main/resources/scripts/configs.sh
@@ -130,14 +130,19 @@ doConfigUpdate () {
       if [ "`echo $line | grep -E "},?$"`" ]; then
         ## Properties ended
         ## Add property
-        # Remove the last ,
         propLen=${#newProperties}
         lastChar=${newProperties:$propLen-1:1}
-        if [ "$lastChar" == "," ]; then
-          newProperties=${newProperties:0:$propLen-1}
-        fi
-        if [ "$MODE" == "set" ]; then
-          newProperties="$newProperties, \"$CONFIGKEY\" : \"$CONFIGVALUE\" "
+        if [ "$MODE" == "delete" ]; then
+          # Remove the last ,
+          if [ "$lastChar" == "," ]; then
+            newProperties=${newProperties:0:$propLen-1}
+          fi
+        elif [ "$MODE" == "set" ]; then
+          # Add comma if required
+          if [ "$lastChar" != ","  -a "$lastChar" != "{" ]; then
+            newProperties="$newProperties,"
+          fi
+          newProperties="$newProperties \"$CONFIGKEY\" : \"$CONFIGVALUE\""
         fi
         newProperties=$newProperties$line
         propertiesStarted=0
@@ -154,6 +159,10 @@ doConfigUpdate () {
     elif [ "`echo $line | grep -E "},?$"`" ]; then
         currentLevel=$((currentLevel-1))
         if [ "$currentLevel" == 1 ]; then
+          # if no properties in current config
+          if [ "$MODE" == "set" -a -z "$newProperties" ]; then
+            newProperties="\"properties\" : { \"$CONFIGKEY\" : \"$CONFIGVALUE\"}"
+          fi
           newTag=`date "+%s%N"`
           newTag="version${newTag}"
           finalJson="{ \"Clusters\": { \"desired_config\": {\"type\": \"$SITE\", \"tag\":\"$newTag\",
$newProperties}}}"


Mime
View raw message