From 942d00e480ff857b9b867cc471bf86a50dedf06e Mon Sep 17 00:00:00 2001 From: Otavio Jacobi Date: Tue, 26 Nov 2024 10:47:22 -0300 Subject: [PATCH] Update device service environment variable hook to navigate via device rather than service install Change-type: patch --- .../vars-schema/hooks/vars-update-trigger.ts | 39 +------------------ 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/src/features/vars-schema/hooks/vars-update-trigger.ts b/src/features/vars-schema/hooks/vars-update-trigger.ts index c5ad5016a..f0363a588 100644 --- a/src/features/vars-schema/hooks/vars-update-trigger.ts +++ b/src/features/vars-schema/hooks/vars-update-trigger.ts @@ -198,6 +198,7 @@ const addDeviceEnvHooks = (resource: keyof BalenaModel) => { addDeviceEnvHooks('device_config_variable'); addDeviceEnvHooks('device_environment_variable'); +addDeviceEnvHooks('device_service_environment_variable'); addEnvHooks('service_environment_variable', async (args) => { if (args.req.body.service != null) { @@ -293,44 +294,6 @@ addEnvHooks('service_environment_variable', async (args) => { ]; }); -addEnvHooks('device_service_environment_variable', async (args) => { - if (args.req.body.service_install != null) { - return { - service_install: { - $any: { - $alias: 's', - $expr: { s: { id: args.req.body.service_install } }, - }, - }, - }; - } - - const envVarIds = await sbvrUtils.getAffectedIds(args); - if (envVarIds.length === 0) { - return; - } - return [ - envVarIds, - (envVarIdsChunk) => ({ - service_install: { - $any: { - $alias: 's', - $expr: { - s: { - device_service_environment_variable: { - $any: { - $alias: 'e', - $expr: { e: { id: { $in: envVarIdsChunk } } }, - }, - }, - }, - }, - }, - }, - }), - ]; -}); - addEnvHooks('image_environment_variable', async (args) => { if (args.req.body.release_image != null) { return {