meta-config: Fix consecutive same sections

The current coding fails to process local.conf like
the following.  Note: This example is taken from a
real use case. [1]

    [[post-config|$NEUTRON_CONF]]
    [qos]
    notification_drivers = midonet
    [[post-config|$NEUTRON_CONF]]

    [quotas]
    # x10 of default quotas (at the time of writing)
    quota_network=100
    quota_subnet=100
    quota_port=500
    quota_router=100
    quota_floatingip=500
    quota_security_group=100
    quota_security_group_rule=1000

[1] https://review.openstack.org/#/c/400627/

Closes-Bug: #1583214
Change-Id: Ie571b5fa5a33d9ed09f30ba7c7724b958ce17616
This commit is contained in:
YAMAMOTO Takashi 2016-11-26 00:43:07 +09:00
parent a3bb131c13
commit 02f3f9a6bb
2 changed files with 32 additions and 7 deletions

View File

@ -40,12 +40,10 @@ function get_meta_section {
$CONFIG_AWK_CMD -v matchgroup=$matchgroup -v configfile=$configfile '
BEGIN { group = "" }
/^\[\[.+\|.*\]\]/ {
if (group == "") {
gsub("[][]", "", $1);
split($1, a, "|");
if (a[1] == matchgroup && a[2] == configfile) {
group=a[1]
}
gsub("[][]", "", $1);
split($1, a, "|");
if (a[1] == matchgroup && a[2] == configfile) {
group=a[1]
} else {
group=""
}

View File

@ -125,6 +125,14 @@ foo=bar
[[test10|does-not-exist-dir/test.conf]]
foo=bar
[[test11|test-same.conf]]
[DEFAULT]
foo=bar
[[test11|test-same.conf]]
[some]
random=config
[[test-multi-sections|test-multi-sections.conf]]
[sec-1]
cfg_item1 = abcd
@ -147,6 +155,9 @@ cfg_item1 = abcd
cfg_item2 = efgh
cfg_item2 = \${FOO_BAR_BAZ}
[[test11|test-same.conf]]
[another]
non = sense
EOF
echo -n "get_meta_section_files: test0 doesn't exist: "
@ -385,8 +396,24 @@ EXPECT_VAL=255
check_result "$VAL" "$EXPECT_VAL"
set -e
echo -n "merge_config_file test11 same section: "
rm -f test-same.conf
merge_config_group test.conf test11
VAL=$(cat test-same.conf)
EXPECT_VAL='
[DEFAULT]
foo = bar
[some]
random = config
[another]
non = sense'
check_result "$VAL" "$EXPECT_VAL"
rm -f test.conf test1c.conf test2a.conf \
test-space.conf test-equals.conf test-strip.conf \
test-colon.conf test-env.conf test-multiline.conf \
test-multi-sections.conf
test-multi-sections.conf test-same.conf
rm -rf test-etc