unet-cli: pass service object to set_service()
authorFelix Fietkau <nbd@nbd.name>
Thu, 25 Aug 2022 10:37:24 +0000 (12:37 +0200)
committerFelix Fietkau <nbd@nbd.name>
Thu, 25 Aug 2022 10:41:29 +0000 (12:41 +0200)
Avoids accessing global net_data from within the function

Signed-off-by: Felix Fietkau <nbd@nbd.name>
scripts/unet-cli

index 96894a3b416d6cdeee03bc04b5a9f2c8e09566e2..f00c817021e7618c266a938d81f98dabd1ad30fa 100755 (executable)
@@ -227,9 +227,7 @@ function set_host(name) {
        });
 }
 
-function set_service(name) {
-       let service = net_data.services[name];
-
+function set_service(service) {
        set_fields(service, {
                type: "string",
                members: "array",
@@ -388,12 +386,12 @@ case 'add-service':
                members: [],
        };
        assert(args.type, "Missing service type");
-       set_service(servicename);
+       set_service(net_data.services[servicename]);
        break;
 
 case 'set-service':
        assert(net_data.services[servicename], `Service '${servicename}' does not exist`);
-       set_service(servicename);
+       set_service(net_data.services[servicename]);
        break;
 
 default: