Merge branch 'v4-next' into patricio-deploy-proxy

This commit is contained in:
Andras Bacsai
2023-05-03 20:53:51 +02:00
45 changed files with 431 additions and 248 deletions

View File

@@ -0,0 +1,41 @@
<?php
namespace App\Http\Livewire\PrivateKey;
use App\Models\PrivateKey;
use Livewire\Component;
class Change extends Component
{
public string $private_key_uuid;
public PrivateKey $private_key;
protected $rules = [
'private_key.name' => 'required|string',
'private_key.description' => 'nullable|string',
'private_key.private_key' => 'required|string'
];
public function mount()
{
$this->private_key = PrivateKey::where('uuid', $this->private_key_uuid)->first();
}
public function delete($private_key_uuid)
{
PrivateKey::where('uuid', $private_key_uuid)->delete();
session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get();
redirect()->route('dashboard');
}
public function changePrivateKey()
{
try {
$this->private_key->private_key = trim($this->private_key->private_key);
if (!str_ends_with($this->private_key->private_key, "\n")) {
$this->private_key->private_key .= "\n";
}
$this->private_key->save();
session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get();
} catch (\Exception $e) {
$this->addError('private_key_value', $e->getMessage());
}
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Http\Livewire\PrivateKey;
use App\Models\PrivateKey;
use Livewire\Component;
class Create extends Component
{
public $private_key_value;
public $private_key_name;
public $private_key_description;
public function createPrivateKey()
{
$this->private_key_value = trim($this->private_key_value);
if (!str_ends_with($this->private_key_value, "\n")) {
$this->private_key_value .= "\n";
}
$new_private_key = PrivateKey::create([
'name' => $this->private_key_name,
'description' => $this->private_key_description,
'private_key' => $this->private_key_value,
'team_id' => session('currentTeam')->id
]);
session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get();
redirect()->route('private-key.show', $new_private_key->uuid);
}
}

View File

@@ -45,11 +45,11 @@ class PublicGitRepository extends Component
$this->parameters = Route::current()->parameters();
$this->servers = session('currentTeam')->load(['servers'])->servers;
}
public function chooseServer($server_id)
public function chooseServer($server)
{
$this->chosenServer = $server_id;
$this->standalone_docker = StandaloneDocker::where('server_id', $server_id)->get();
$this->swarm_docker = SwarmDocker::where('server_id', $server_id)->get();
$this->chosenServer = $server;
$this->standalone_docker = StandaloneDocker::where('server_id', $server['id'])->get();
$this->swarm_docker = SwarmDocker::where('server_id', $server['id'])->get();
}
public function setDestination($destination_uuid, $destination_type)
{

View File

@@ -15,7 +15,7 @@ class ByIp extends Component
public $new_private_key_value;
public string $name;
public string $description;
public string|null $description = null;
public string $ip;
public string $user = 'root';
public int $port = 22;
@@ -29,20 +29,6 @@ class ByIp extends Component
{
$this->private_key_id = $private_key_id;
}
public function addPrivateKey()
{
$this->new_private_key_value = trim($this->new_private_key_value);
if (!str_ends_with($this->new_private_key_value, "\n")) {
$this->new_private_key_value .= "\n";
}
PrivateKey::create([
'name' => $this->new_private_key_name,
'description' => $this->new_private_key_description,
'private_key' => $this->new_private_key_value,
'team_id' => session('currentTeam')->id
]);
session('currentTeam')->privateKeys = $this->private_keys = PrivateKey::where('team_id', session('currentTeam')->id)->get();
}
public function submit()
{
if (!$this->private_key_id) {

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Http\Livewire\Server;
use App\Models\PrivateKey as ModelsPrivateKey;
use App\Models\Server;
use Illuminate\Support\Facades\Route;
use Livewire\Component;
class PrivateKey extends Component
{
public $private_keys;
public $parameters;
public function setPrivateKey($private_key_id)
{
Server::where('uuid', $this->parameters['server_uuid'])->update([
'private_key_id' => $private_key_id
]);
return redirect()->route('server.show', $this->parameters['server_uuid']);
}
public function mount()
{
$this->parameters = Route::current()->parameters();
$this->private_keys = ModelsPrivateKey::where('team_id', session('currentTeam')->id)->get();
}
}

View File

@@ -222,10 +222,10 @@ COPY --from={$this->application->uuid}:{$this->git_commit}-build /app/{$this->ap
Storage::disk('deployments')->put(Str::kebab($this->application->name) . '/docker-compose.yml', $this->docker_compose);
} catch (\Exception $e) {
$this->executeNow([
"echo 'Oops something is not okay, are you okay? 😢'",
"echo '\nOops something is not okay, are you okay? 😢'",
"echo '\n\n{$e->getMessage()}'",
]);
throw new \Exception('Deployment finished');
$this->fail($e->getMessage());
} finally {
$this->executeNow(["docker rm -f {$this->deployment_uuid} >/dev/null 2>&1"], hideFromOutput: true);
dispatch(new ContainerStatusJob($this->application_uuid));

View File

@@ -24,4 +24,8 @@ class Team extends BaseModel
{
return $this->hasManyThrough(Application::class, Project::class);
}
public function privateKeys()
{
return $this->hasMany(PrivateKey::class);
}
}

View File

@@ -1,33 +0,0 @@
<?php
namespace App\View\Components;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
class FormInput extends Component
{
/**
* Create a new component instance.
*/
public function __construct(
public string $id,
public bool $required = false,
public bool $readonly = false,
public string|null $label = null,
public string|null $type = 'text',
public bool $instantSave = false,
public bool $disabled = false,
public bool $hidden = false
) {
}
/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.form-input');
}
}

View File

@@ -1,30 +0,0 @@
<?php
namespace App\View\Components;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
class Input extends Component
{
/**
* Create a new component instance.
*/
public function __construct(
public string $id,
public bool $required = false,
public bool $readonly = false,
public string|null $label = null,
public string|null $type = 'text',
) {
}
/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.input');
}
}