Skip to content

Commit

Permalink
Merge pull request #1780 from balena-io/remove-si-on-service-env-vars
Browse files Browse the repository at this point in the history
Reduce usage of service_installs on service_env_var hooks
  • Loading branch information
flowzone-app[bot] authored Oct 4, 2024
2 parents 64e6b8e + df9399c commit 3cb8fa4
Showing 1 changed file with 51 additions and 15 deletions.
66 changes: 51 additions & 15 deletions src/features/vars-schema/hooks/vars-update-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,33 @@ addDeviceEnvHooks('device_environment_variable');
addEnvHooks('service_environment_variable', async (args) => {
if (args.req.body.service != null) {
return {
service_install: {
should_be_running__release: {
$any: {
$alias: 'si',
$alias: 'r',
$expr: {
si: {
service: {
r: {
contains__image: {
$any: {
$alias: 's',
$expr: { s: { id: args.req.body.service } },
$alias: 'ci',
$expr: {
ci: {
image: {
$any: {
$alias: 'i',
$expr: {
i: {
is_a_build_of__service: {
$any: {
$alias: 's',
$expr: { s: { id: args.req.body.service } },
},
},
},
},
},
},
},
},
},
},
},
Expand All @@ -212,21 +230,39 @@ addEnvHooks('service_environment_variable', async (args) => {
return [
envVarIds,
(envVarIdsChunk) => ({
service_install: {
should_be_running__release: {
$any: {
$alias: 'si',
$alias: 'r',
$expr: {
si: {
service: {
r: {
contains__image: {
$any: {
$alias: 's',
$alias: 'ci',
$expr: {
s: {
service_environment_variable: {
ci: {
image: {
$any: {
$alias: 'e',
$alias: 'i',
$expr: {
e: { id: { $in: envVarIdsChunk } },
i: {
is_a_build_of__service: {
$any: {
$alias: 's',
$expr: {
s: {
service_environment_variable: {
$any: {
$alias: 'e',
$expr: {
e: { id: { $in: envVarIdsChunk } },
},
},
},
},
},
},
},
},
},
},
},
Expand Down

0 comments on commit 3cb8fa4

Please sign in to comment.