Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

Fix variable assignment in Import.php and ApplicationDeploymentJob.php

Andras Bacsaie71032a8fc5f
diff --git a/app/Actions/Database/StartClickhouse.php b/app/Actions/Database/StartClickhouse.php
index d530bc6c31..10fe6e0d5a 100644
--- a/app/Actions/Database/StartClickhouse.php
+++ b/app/Actions/Database/StartClickhouse.php
@@ -116,8 +116,12 @@ class StartClickhouse
{
$local_persistent_volumes = [];
foreach ($this->database->persistentStorages as $persistentStorage) {
- $volume_name = $persistentStorage->host_path ?? $persistentStorage->name;
- $local_persistent_volumes[] = $volume_name . ':' . $persistentStorage->mount_path;
+ if ($persistentStorage->host_path !== '' && $persistentStorage->host_path !== null) {
+ $local_persistent_volumes[] = $persistentStorage->host_path . ':' . $persistentStorage->mount_path;
+ } else {
+ $volume_name = $persistentStorage->name;
+ $local_persistent_volumes[] = $volume_name . ':' . $persistentStorage->mount_path;
+ }
}
return $local_persistent_volumes;
}
diff --git a/app/Actions/Database/StartDragonfly.php b/app/Actions/Database/StartDragonfly.php
index e5daf933b3..a750f4412d 100644
--- a/app/Actions/Database/StartDragonfly.php
+++ b/app/Actions/Database/StartDragonfly.php
@@ -124,8 +124,12 @@ class StartDragonfly
{
$local_persistent_volumes = [];
foreach ($this->database->persistentStorages as $persistentStorage) {
- $volume_name = $persistentStorage->host_path ?? $persistentStorage->name;
- $local_persistent_volumes[] = $volume_name . ':' . $persistentStorage->mount_path;
+ if ($persistentStorage->host_path !== '' && $persistentStorage->host_path !== null) {
+ $local_persistent_volumes[] = $persistentStorage->host_path . ':' . $persistentStorage->mount_path;
+ } else {
+ $volume_name = $persistentStorage->name;
+ $local_persistent_volumes[] = $volume_name . ':' . $persistentStorage->mount_path;
+ }
}
return $local_persistent_volumes;
}
diff --git a/app/Actions/Database/StartKeydb.php b/app/Actions/Database/StartKeydb.php
index 11f8b00225..7b4bbe1243 100644
--- a/app/Actions/Database/StartKeydb.php
+++ b/app/Actions/Database/StartKeydb.php
@@ -121,8 +121,12 @@ class StartKeydb
{
$local_persistent_volumes = [];
foreach ($this->database->persistentStorages as $persistentStorage) {
- $volume_name = $persistentStorage->host_path ?? $persistentStorage->name;
- $local_persistent_volumes[] = $volume_name . ':' . $persistentStorage->mount_path;
+ if ($persistentStorage->host_path !== '' && $persistentStorage->host_path !== null) {
+ $local_persistent_volumes[] = $persistentStorage->host_path . ':' . $persistentStorage->mount_path;
+ } else {
+ $volume_name = $persistentStorage->name;
+ $local_persistent_volumes[] = $volume_name . ':' . $persistentStorage->mount_path;
+ }
}
return $local_persistent_volumes;
}
diff --git a/app/Actions/Database/StartMariadb.php b/app/Actions/Database/StartMariadb.php
index 8dca584f23..755c478672 100644
--- a/app/Actions/Database/StartMariadb.php
+++ b/app/Actions/Database/StartMariadb.php
@@ -114,8 +114,12 @@ class StartMariadb
{
$local_persistent_volumes = [];
foreach ($this->database->persistentStorages as $persistentStorage) {
- $volume_name = $persistentStorage->host_path ?? $persistentStorage->name;
- $local_persistent_volumes[] = $volume_name . ':' . $persistentStorage->mount_path;
+ if ($persistentStorage->host_path !== '' && $persistentStorage->host_path !== null) {
+ $local_persistent_volumes[] = $persistentStorage->host_path . ':' . $persistentStorage->mount_path;
+ } else {
+ $volume_name = $persistentStorage->name;
+ $local_persistent_volumes[] = $volume_name . ':' . $persistentStorage->mount_path;
+ }
}
return $local_persistent_volumes;
}
diff --git a/app/Actions/Database/StartMongodb.php b/app/Actions/Database/StartMongodb.php
index ef04a9be83..180ae988ae 100644
--- a/app/Actions/Database/StartMongodb.php
+++ b/app/Actions/Database/StartMongodb.php
@@ -130,8 +130,12 @@ class StartMongodb
{
$local_persistent_volumes = [];
foreach ($this->database->persistentStorages as $persistentStorage) {
- $volume_name = $persistentStorage->host_path ?? $persistentStorage->name;
- $local_persistent_volumes[] = $volume_name . ':' . $persistentStorage->mount_path;
+ if ($persistentStorage->host_path !== '' && $persistentStorage->host_path !== null) {
+ $local_persistent_volumes[] = $persistentStorage->host_path . ':' . $persistentStorage->mount_path;
+ } else {
+ $volume_name = $persistentStorage->name;
+ $local_persistent_volumes[] = $volume_name . ':' . $persistentStorage->mount_path;
+ }
}
return $local_persistent_volumes;
}
diff --git a/app/Actions/Database/StartMysql.php b/app/Actions/Database/StartMysql.php
index 3b47483a3d..0e2e757192 100644
--- a/app/Actions/Database/StartMysql.php
+++ b/app/Actions/Database/StartMysql.php
@@ -114,8 +114,12 @@ class StartMysql
{
$local_persistent_volumes = [];
foreach ($this->database->persistentStorages as $persistentStorage) {
- $volume_name = $persistentStorage->host_path ?? $persistentStorage->name;
- $local_persistent_volumes[] = $volume_name . ':' . $persistentStorage->mount_path;
+ if ($persistentStorage->host_path !== '' && $persistentStorage->host_path !== null) {
+ $local_persistent_volumes[] = $persistentStorage->host_path . ':' . $persistentStorage->mount_path;
+ } else {
+ $volume_name = $persistentStorage->name;
+ $local_persistent_volumes[] = $volume_name . ':' . $persistentStorage->mount_path;
+ }
}
return $local_persistent_volumes;
}
diff --git a/app/Actions/Database/StartPostgresql.php b/app/Actions/Database/StartPostgresql.php
index 844f81c311..03b460edc7 100644
--- a/app/Actions/Database/StartPostgresql.php
+++ b/app/Actions/Database/StartPostgresql.php
@@ -136,8 +136,12 @@ class StartPostgresql
{
$local_persistent_volumes = [];
foreach ($this->database->persistentStorages as $persistentStorage) {
- $volume_name = $persistentStorage->host_path ?? $persistentStorage->name;
- $local_persistent_volumes[] = $volume_name . ':' . $persistentStorage->mount_path;
+ if ($persistentStorage->host_path !== '' && $persistentStorage->host_path !== null) {
+ $local_persistent_volumes[] = $persistentStorage->host_path . ':' . $persistentStorage->mount_path;
+ } else {
+ $volume_name = $persistentStorage->name;
+ $local_persistent_volumes[] = $volume_name . ':' . $persistentStorage->mount_path;
+ }
}
return $local_persistent_volumes;
}
diff --git a/app/Actions/Database/StartRedis.php b/app/Actions/Database/StartRedis.php
index e1a8eef41b..ff8c63aab7 100644
--- a/app/Actions/Database/StartRedis.php
+++ b/app/Actions/Database/StartRedis.php
@@ -125,8 +125,12 @@ class StartRedis
{
$local_persistent_volumes = [];
foreach ($this->database->persistentStorages as $persistentStorage) {
- $volume_name = $persistentStorage->host_path ?? $persistentStorage->name;
- $local_persistent_volumes[] = $volume_name . ':' . $persistentStorage->mount_path;
+ if ($persistentStorage->host_path !== '' && $persistentStorage->host_path !== null) {
+ $local_persistent_volumes[] = $persistentStorage->host_path . ':' . $persistentStorage->mount_path;
+ } else {
+ $volume_name = $persistentStorage->name;
+ $local_persistent_volumes[] = $volume_name . ':' . $persistentStorage->mount_path;
+ }
}
return $local_persistent_volumes;
}
diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php
index 6ad87e07fd..729b2e049e 100644
--- a/app/Jobs/ApplicationDeploymentJob.php
+++ b/app/Jobs/ApplicationDeploymentJob.php
@@ -1340,7 +1340,11 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
{
$local_persistent_volumes = [];
foreach ($this->application->persistentStorages as $persistentStorage) {
- $volume_name = $persistentStorage->host_path ?? $persistentStorage->name;
+ if ($persistentStorage->host_path !== '' && $persistentStorage->host_path !== null) {
+ $volume_name = $persistentStorage->host_path;
+ } else {
+ $volume_name = $persistentStorage->name;
+ }
if ($this->pull_request_id !== 0) {
$volume_name = $volume_name . '-pr-' . $this->pull_request_id;
}
diff --git a/app/Livewire/Project/Database/Import.php b/app/Livewire/Project/Database/Import.php
index 4a2a9fff21..74e41056a9 100644
--- a/app/Livewire/Project/Database/Import.php
+++ b/app/Livewire/Project/Database/Import.php
@@ -8,7 +8,7 @@ use Illuminate\Support\Facades\Storage;
class Import extends Component
{
-
+ public bool $unsupported = false;
public $resource;
public $parameters;
public $containers;
@@ -65,7 +65,7 @@ class Import extends Component
$this->resource->getMorphClass() == 'App\Models\StandaloneClickhouse' ||
$this->resource->getMorphClass() == 'App\Models\StandaloneMongodb'
) {
- $this->dispatch('error', 'Import is not supported for this resource.');
+ $this->unsupported = true;
}
}
diff --git a/resources/views/livewire/project/database/import.blade.php b/resources/views/livewire/project/database/import.blade.php
index ad01995630..b35beb47af 100644
--- a/resources/views/livewire/project/database/import.blade.php
+++ b/resources/views/livewire/project/database/import.blade.php
@@ -37,41 +37,46 @@
</script>
@endscript
<h2>Import Backup</h2>
- <div class="mt-2 mb-4 rounded alert-error">
- <svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 stroke-current shrink-0" fill="none" viewBox="0 0 24 24">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
- d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
- </svg>
- <span>This is a destructive action, existing data will be replaced!</span>
- </div>
+ @if ($unsupported)
+ <div>Database restore is not supported.</div>
+ @else
+ <div class="mt-2 mb-4 rounded alert-error">
+ <svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 stroke-current shrink-0" fill="none"
+ viewBox="0 0 24 24">
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
+ d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
+ </svg>
+ <span>This is a destructive action, existing data will be replaced!</span>
+ </div>
+ @if (str(data_get($resource, 'status'))->startsWith('running'))
- @if (str(data_get($resource, 'status'))->startsWith('running'))
- @if ($resource->type() === 'standalone-postgresql')
- <x-forms.input class="mb-2" label="Custom Import Command"
- wire:model='postgresqlRestoreCommand'></x-forms.input>
- @elseif ($resource->type() === 'standalone-mysql')
- <x-forms.input class="mb-2" label="Custom Import Command"
- wire:model='mysqlRestoreCommand'></x-forms.input>
- @elseif ($resource->type() === 'standalone-mariadb')
- <x-forms.input class="mb-2" label="Custom Import Command"
- wire:model='mariadbRestoreCommand'></x-forms.input>
- @endif
+ @if ($resource->type() === 'standalone-postgresql')
+ <x-forms.input class="mb-2" label="Custom Import Command"
+ wire:model='postgresqlRestoreCommand'></x-forms.input>
+ @elseif ($resource->type() === 'standalone-mysql')
+ <x-forms.input class="mb-2" label="Custom Import Command"
+ wire:model='mysqlRestoreCommand'></x-forms.input>
+ @elseif ($resource->type() === 'standalone-mariadb')
+ <x-forms.input class="mb-2" label="Custom Import Command"
+ wire:model='mariadbRestoreCommand'></x-forms.input>
+ @endif
- <div x-show="isUploading">
- <progress max="100" x-bind:value="progress" class="progress progress-warning"></progress>
- </div>
- <div x-show="filename && !error">
- <div>File: <span x-text="filename ?? 'N/A'"></span> <span x-text="filesize">/ </span></div>
- <x-forms.button class="w-full my-4" wire:click='runImport'>Restore Backup</x-forms.button>
- </div>
- <form action="/upload/backup/{{ $resource->uuid }}" class="dropzone" id="my-dropzone">
- @csrf
- </form>
+ <div x-show="isUploading">
+ <progress max="100" x-bind:value="progress" class="progress progress-warning"></progress>
+ </div>
+ <div x-show="filename && !error">
+ <div>File: <span x-text="filename ?? 'N/A'"></span> <span x-text="filesize">/ </span></div>
+ <x-forms.button class="w-full my-4" wire:click='runImport'>Restore Backup</x-forms.button>
+ </div>
+ <form action="/upload/backup/{{ $resource->uuid }}" class="dropzone" id="my-dropzone">
+ @csrf
+ </form>
- <div class="container w-full mx-auto">
- <livewire:activity-monitor header="Database restore output" />
- </div>
- @else
- <div>Database must be running to restore a backup.</div>
+ <div class="container w-full mx-auto">
+ <livewire:activity-monitor header="Database Restore Output" />
+ </div>
+ @else
+ <div>Database must be running to restore a backup.</div>
+ @endif
@endif
</div>