Implement Keystone environment deployments
This commit is contained in:
29
database/factories/ApplicationFactory.php
Normal file
29
database/factories/ApplicationFactory.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\RepositoryType;
|
||||
use App\Models\Organisation;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Application>
|
||||
*/
|
||||
class ApplicationFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'organisation_id' => Organisation::factory(),
|
||||
'name' => $this->faker->words(2, true),
|
||||
'repository_url' => 'git@example.com:org/'.$this->faker->slug().'.git',
|
||||
'repository_type' => RepositoryType::GIT,
|
||||
'default_branch' => 'main',
|
||||
];
|
||||
}
|
||||
}
|
||||
31
database/factories/EnvironmentFactory.php
Normal file
31
database/factories/EnvironmentFactory.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\SchedulerMode;
|
||||
use App\Models\Application;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Environment>
|
||||
*/
|
||||
class EnvironmentFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'application_id' => Application::factory(),
|
||||
'name' => 'production',
|
||||
'branch' => 'main',
|
||||
'status' => 'active',
|
||||
'scheduler_enabled' => true,
|
||||
'scheduler_mode' => SchedulerMode::SINGLE,
|
||||
'build_config' => [],
|
||||
];
|
||||
}
|
||||
}
|
||||
29
database/factories/OperationFactory.php
Normal file
29
database/factories/OperationFactory.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\OperationKind;
|
||||
use App\Enums\OperationStatus;
|
||||
use App\Models\Service;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Operation>
|
||||
*/
|
||||
class OperationFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'kind' => OperationKind::SERVICE_DEPLOY,
|
||||
'target_type' => (new Service)->getMorphClass(),
|
||||
'target_id' => Service::factory(),
|
||||
'status' => OperationStatus::PENDING,
|
||||
];
|
||||
}
|
||||
}
|
||||
37
database/factories/ServiceFactory.php
Normal file
37
database/factories/ServiceFactory.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\DeployPolicy;
|
||||
use App\Enums\ServiceCategory;
|
||||
use App\Enums\ServiceStatus;
|
||||
use App\Enums\ServiceType;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Service>
|
||||
*/
|
||||
class ServiceFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->word(),
|
||||
'status' => ServiceStatus::NOT_INSTALLED,
|
||||
'category' => ServiceCategory::DATABASE,
|
||||
'type' => ServiceType::POSTGRES,
|
||||
'version' => '18',
|
||||
'version_track' => '18',
|
||||
'driver_name' => 'postgres.18',
|
||||
'desired_replicas' => 1,
|
||||
'deploy_policy' => DeployPolicy::DEPENDENCY_ONLY,
|
||||
'process_roles' => [],
|
||||
'config' => [],
|
||||
];
|
||||
}
|
||||
}
|
||||
33
database/factories/ServiceReplicaFactory.php
Normal file
33
database/factories/ServiceReplicaFactory.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\Service;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\ServiceReplica>
|
||||
*/
|
||||
class ServiceReplicaFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'service_id' => Service::factory(),
|
||||
'server_id' => Server::factory(),
|
||||
'container_name' => $this->faker->slug(),
|
||||
'image_digest' => 'sha256:'.$this->faker->sha256(),
|
||||
'internal_host' => $this->faker->domainWord(),
|
||||
'internal_port' => 8080,
|
||||
'status' => 'running',
|
||||
'health_status' => 'healthy',
|
||||
'config' => [],
|
||||
];
|
||||
}
|
||||
}
|
||||
33
database/factories/ServiceSliceFactory.php
Normal file
33
database/factories/ServiceSliceFactory.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Service;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\ServiceSlice>
|
||||
*/
|
||||
class ServiceSliceFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'service_id' => Service::factory(),
|
||||
'name' => $this->faker->slug(),
|
||||
'type' => 'database_user',
|
||||
'status' => 'active',
|
||||
'config' => [],
|
||||
'credentials' => [
|
||||
'username' => $this->faker->userName(),
|
||||
'password' => $this->faker->password(16),
|
||||
'database' => $this->faker->slug(),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user