Skip to content

Commit

Permalink
Update device service environment variable hook to navigate via devic…
Browse files Browse the repository at this point in the history
…e rather than service install

Change-type: patch
  • Loading branch information
otaviojacobi committed Nov 28, 2024
1 parent eaf68d0 commit 942d00e
Showing 1 changed file with 1 addition and 38 deletions.
39 changes: 1 addition & 38 deletions src/features/vars-schema/hooks/vars-update-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 942d00e

Please sign in to comment.