Add servers and privatekeys to database

This commit is contained in:
Andras Bacsai
2023-03-24 15:47:58 +01:00
parent 26cfcd31f8
commit f7c615c958
7 changed files with 146 additions and 0 deletions

View File

@@ -12,6 +12,8 @@ class DatabaseSeeder extends Seeder
$this->call([
UserSeeder::class,
TeamSeeder::class,
ServerSeeder::class,
PrivateKeySeeder::class,
]);
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Database\Seeders;
use App\Models\PrivateKey;
use App\Models\Server;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class PrivateKeySeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$server = Server::find(1);
PrivateKey::create([
"name" => "Testing-host",
"description" => "This is a test docker container",
"private_key" => "-----BEGIN OPENSSH PRIVATE KEY-----\
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW\
QyNTUxOQAAACBbhpqHhqv6aI67Mj9abM3DVbmcfYhZAhC7ca4d9UCevAAAAJi/QySHv0Mk\
hwAAAAtzc2gtZWQyNTUxOQAAACBbhpqHhqv6aI67Mj9abM3DVbmcfYhZAhC7ca4d9UCevA\
AAAECBQw4jg1WRT2IGHMncCiZhURCts2s24HoDS0thHnnRKVuGmoeGq/pojrsyP1pszcNV\
uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==\
-----END OPENSSH PRIVATE KEY-----",
])->private_key_morph()->associate($server)->save();
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace Database\Seeders;
use App\Models\Server;
use App\Models\Team;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class ServerSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$root_team = Team::find(1);
Server::create([
'id' => 1,
'name' => "testing-host",
'description' => "This is a test docker container",
'ip' => "coolify-testing-host",
'team_id' => $root_team->id,
]);
}
}