[openwrt/openwrt] cli: use model scope for hook calls

LEDE Commits lede-commits at lists.infradead.org
Fri Feb 28 08:36:16 PST 2025


nbd pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/795337640073d0f15f6f60a91048c8b2295b9994

commit 795337640073d0f15f6f60a91048c8b2295b9994
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Wed Feb 26 10:35:02 2025 +0100

    cli: use model scope for hook calls
    
    Make the scope consistent with other callbacks
    
    Signed-off-by: Felix Fietkau <nbd at nbd.name>
---
 package/network/services/unetd/files/unet.uc             | 6 +++---
 package/utils/cli/files/usr/share/ucode/cli/datamodel.uc | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/package/network/services/unetd/files/unet.uc b/package/network/services/unetd/files/unet.uc
index b884e23f60..023ea3e6b8 100644
--- a/package/network/services/unetd/files/unet.uc
+++ b/package/network/services/unetd/files/unet.uc
@@ -151,7 +151,7 @@ function network_sign_data(ctx, name, network, pw_file, upload)
 	return true;
 }
 
-function network_create_uci(name, iface)
+function network_create_uci(model, name, iface)
 {
 	let cur = uci.cursor();
 	cur.set("network", name, "interface");
@@ -344,7 +344,7 @@ function network_create(ctx, argv, named) {
 	if (!network_sign_data(ctx, named.network, network, pw_file))
 		return;
 
-	network_create_uci(named.network, {
+	network_create_uci(ctx.model, named.network, {
 		proto: "unet",
 		metric: named.metric,
 		zone: named.zone,
@@ -580,7 +580,7 @@ function network_join_peer_update(model, ctx, msg)
 	if (joinreq.connect)
 		iface.connect = joinreq.connect;
 
-	network_create_uci(name, iface);
+	network_create_uci(model, name, iface);
 
 	model.status_msg("Configuration added for interface " + name);
 
diff --git a/package/utils/cli/files/usr/share/ucode/cli/datamodel.uc b/package/utils/cli/files/usr/share/ucode/cli/datamodel.uc
index bc78a7b12b..f6d9454dd7 100644
--- a/package/utils/cli/files/usr/share/ucode/cli/datamodel.uc
+++ b/package/utils/cli/files/usr/share/ucode/cli/datamodel.uc
@@ -122,7 +122,7 @@ function run_hook(name, ...args)
 		return;
 
 	for (let hook in hooks)
-		call(hook, this, {}, ...args);
+		call(hook, this, this.scope, ...args);
 }
 
 function init()




More information about the lede-commits mailing list