From 7723c623d5ef8d656d1bfa28ede38e65b2f969be Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 4 Jun 2024 11:25:40 +0200 Subject: [PATCH] fix: check env in args for compose based apps --- app/Models/EnvironmentVariable.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/Models/EnvironmentVariable.php b/app/Models/EnvironmentVariable.php index 32bc04285..c30560954 100644 --- a/app/Models/EnvironmentVariable.php +++ b/app/Models/EnvironmentVariable.php @@ -90,6 +90,7 @@ class EnvironmentVariable extends Model return true; } $found_in_compose = false; + $found_in_args = false; $resource = $this->resource(); $compose = data_get($resource, 'docker_compose_raw'); if (!$compose) { @@ -102,21 +103,35 @@ class EnvironmentVariable extends Model } foreach ($services as $service) { $environments = collect(data_get($service, 'environment')); - if ($environments->isEmpty()) { + $args = collect(data_get($service, 'build.args')); + if ($environments->isEmpty() && $args->isEmpty()) { $found_in_compose = false; break; } + $found_in_compose = $environments->contains(function ($item) { if (str($item)->contains('=')) { $item = str($item)->before('='); } return strpos($item, $this->key) !== false; }); + if ($found_in_compose) { break; } + + $found_in_args = $args->contains(function ($item) { + if (str($item)->contains('=')) { + $item = str($item)->before('='); + } + return strpos($item, $this->key) !== false; + }); + + if ($found_in_args) { + break; + } } - return $found_in_compose; + return $found_in_compose || $found_in_args; } ); }