]> git.ipfire.org Git - people/ms/network.git/commitdiff
header-zone: refactor hook_config_edit
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Wed, 5 Jul 2017 14:19:51 +0000 (16:19 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 5 Jul 2017 15:11:57 +0000 (17:11 +0200)
With the new id function this function gets a zone name and a id,
but hook_config_cmd needs also the name of the hook.

So this function now calls zone_config_get_hook_from_id to get the hook
and calls then hook_config_cmd with the correct argument order.

Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/header-zone

index fdd6e51051bad464f6dce7eb38088573f70bfa15..2e3fa09d31ce08291f100e3e75a5b165c9463206 100644 (file)
@@ -225,7 +225,22 @@ hook_config_destroy() {
 }
 
 hook_config_edit() {
-       hook_config_cmd "edit" "$@"
+       assert [ $# -eq 2 ]
+       local zone=${1}
+       # The id must be the id and not the hid.
+       local id=${2}
+
+       shift 2
+
+       # Check if we get a valid id
+       if ! zone_config_id_is_valid ${zone} ${id}; then
+               log ERROR "ID: ${id} is not a valid id for zone ${zone}"
+       fi
+
+       local hook=$(zone_config_get_hook_from_id ${zone} ${id})
+       assert isset hook
+
+       hook_config_cmd "edit" "${zone}" "${hook}" "${hook}.${id}" "$@"
 }
 
 hook_config_show() {