chore: Update coolify environment variable assignment with double quotes

This commit is contained in:
Andras Bacsai
2024-09-13 08:23:05 +02:00
parent 0b33315991
commit dd8a2dd3c1
2 changed files with 18 additions and 18 deletions

View File

@@ -919,10 +919,10 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
} }
if ($this->application->build_pack !== 'dockercompose' || $this->application->compose_parsing_version === '1' || $this->application->compose_parsing_version === '2') { if ($this->application->build_pack !== 'dockercompose' || $this->application->compose_parsing_version === '1' || $this->application->compose_parsing_version === '2') {
if ($this->application->environment_variables_preview->where('key', 'COOLIFY_BRANCH')->isEmpty()) { if ($this->application->environment_variables_preview->where('key', 'COOLIFY_BRANCH')->isEmpty()) {
$envs->push("COOLIFY_BRANCH={$local_branch}"); $envs->push("COOLIFY_BRANCH=\"{$local_branch}\"");
} }
if ($this->application->environment_variables_preview->where('key', 'COOLIFY_CONTAINER_NAME')->isEmpty()) { if ($this->application->environment_variables_preview->where('key', 'COOLIFY_CONTAINER_NAME')->isEmpty()) {
$envs->push("COOLIFY_CONTAINER_NAME={$this->container_name}"); $envs->push("COOLIFY_CONTAINER_NAME=\"{$this->container_name}\"");
} }
} }
@@ -978,10 +978,10 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
} }
if ($this->application->build_pack !== 'dockercompose' || $this->application->compose_parsing_version === '1' || $this->application->compose_parsing_version === '2') { if ($this->application->build_pack !== 'dockercompose' || $this->application->compose_parsing_version === '1' || $this->application->compose_parsing_version === '2') {
if ($this->application->environment_variables->where('key', 'COOLIFY_BRANCH')->isEmpty()) { if ($this->application->environment_variables->where('key', 'COOLIFY_BRANCH')->isEmpty()) {
$envs->push("COOLIFY_BRANCH={$local_branch}"); $envs->push("COOLIFY_BRANCH=\"{$local_branch}\"");
} }
if ($this->application->environment_variables->where('key', 'COOLIFY_CONTAINER_NAME')->isEmpty()) { if ($this->application->environment_variables->where('key', 'COOLIFY_CONTAINER_NAME')->isEmpty()) {
$envs->push("COOLIFY_CONTAINER_NAME={$this->container_name}"); $envs->push("COOLIFY_CONTAINER_NAME=\"{$this->container_name}\"");
} }
} }

View File

@@ -2100,16 +2100,16 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
// TODO: move this in a shared function // TODO: move this in a shared function
if (! $parsedServiceVariables->has('COOLIFY_APP_NAME')) { if (! $parsedServiceVariables->has('COOLIFY_APP_NAME')) {
$parsedServiceVariables->put('COOLIFY_APP_NAME', $resource->name); $parsedServiceVariables->put('COOLIFY_APP_NAME', "\"{$resource->name}\"");
} }
if (! $parsedServiceVariables->has('COOLIFY_SERVER_IP')) { if (! $parsedServiceVariables->has('COOLIFY_SERVER_IP')) {
$parsedServiceVariables->put('COOLIFY_SERVER_IP', $resource->destination->server->ip); $parsedServiceVariables->put('COOLIFY_SERVER_IP', "\"{$resource->destination->server->ip}\"");
} }
if (! $parsedServiceVariables->has('COOLIFY_ENVIRONMENT_NAME')) { if (! $parsedServiceVariables->has('COOLIFY_ENVIRONMENT_NAME')) {
$parsedServiceVariables->put('COOLIFY_ENVIRONMENT_NAME', $resource->environment->name); $parsedServiceVariables->put('COOLIFY_ENVIRONMENT_NAME', "\"{$resource->environment->name}\"");
} }
if (! $parsedServiceVariables->has('COOLIFY_PROJECT_NAME')) { if (! $parsedServiceVariables->has('COOLIFY_PROJECT_NAME')) {
$parsedServiceVariables->put('COOLIFY_PROJECT_NAME', $resource->project()->name); $parsedServiceVariables->put('COOLIFY_PROJECT_NAME', "\"{$resource->project()->name}\"");
} }
$parsedServiceVariables = $parsedServiceVariables->map(function ($value, $key) use ($envs_from_coolify) { $parsedServiceVariables = $parsedServiceVariables->map(function ($value, $key) use ($envs_from_coolify) {
@@ -3469,13 +3469,13 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
$branch = "pull/{$pullRequestId}/head"; $branch = "pull/{$pullRequestId}/head";
} }
if ($originalResource->environment_variables->where('key', 'COOLIFY_BRANCH')->isEmpty()) { if ($originalResource->environment_variables->where('key', 'COOLIFY_BRANCH')->isEmpty()) {
$coolifyEnvironments->put('COOLIFY_BRANCH', $branch); $coolifyEnvironments->put('COOLIFY_BRANCH', "\"{$branch}\"");
} }
} }
// Add COOLIFY_CONTAINER_NAME to environment // Add COOLIFY_CONTAINER_NAME to environment
if ($resource->environment_variables->where('key', 'COOLIFY_CONTAINER_NAME')->isEmpty()) { if ($resource->environment_variables->where('key', 'COOLIFY_CONTAINER_NAME')->isEmpty()) {
$coolifyEnvironments->put('COOLIFY_CONTAINER_NAME', $containerName); $coolifyEnvironments->put('COOLIFY_CONTAINER_NAME', "\"{$containerName}\"");
} }
if ($isApplication) { if ($isApplication) {
@@ -3723,30 +3723,30 @@ function add_coolify_default_environment_variables(StandaloneRedis|StandalonePos
} }
if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_APP_NAME')->isEmpty()) { if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_APP_NAME')->isEmpty()) {
if ($isAssociativeArray) { if ($isAssociativeArray) {
$where_to_add->put('COOLIFY_APP_NAME', $resource->name); $where_to_add->put('COOLIFY_APP_NAME', "\"{$resource->name}\"");
} else { } else {
$where_to_add->push("COOLIFY_APP_NAME={$resource->name}"); $where_to_add->push("COOLIFY_APP_NAME=\"{$resource->name}\"");
} }
} }
if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) { if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) {
if ($isAssociativeArray) { if ($isAssociativeArray) {
$where_to_add->put('COOLIFY_SERVER_IP', $ip); $where_to_add->put('COOLIFY_SERVER_IP', "\"{$ip}\"");
} else { } else {
$where_to_add->push("COOLIFY_SERVER_IP={$ip}"); $where_to_add->push("COOLIFY_SERVER_IP=\"{$ip}\"");
} }
} }
if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) { if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) {
if ($isAssociativeArray) { if ($isAssociativeArray) {
$where_to_add->put('COOLIFY_ENVIRONMENT_NAME', $resource->environment->name); $where_to_add->put('COOLIFY_ENVIRONMENT_NAME', "\"{$resource->environment->name}\"");
} else { } else {
$where_to_add->push("COOLIFY_ENVIRONMENT_NAME={$resource->environment->name}"); $where_to_add->push("COOLIFY_ENVIRONMENT_NAME=\"{$resource->environment->name}\"");
} }
} }
if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) { if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) {
if ($isAssociativeArray) { if ($isAssociativeArray) {
$where_to_add->put('COOLIFY_PROJECT_NAME', $resource->project()->name); $where_to_add->put('COOLIFY_PROJECT_NAME', "\"{$resource->project()->name}\"");
} else { } else {
$where_to_add->push("COOLIFY_PROJECT_NAME={$resource->project()->name}"); $where_to_add->push("COOLIFY_PROJECT_NAME=\"{$resource->project()->name}\"");
} }
} }
} }