service credentials
This commit is contained in:
@@ -27,8 +27,10 @@ class CreateService
|
||||
'status' => ServiceStatus::NOT_INSTALLED,
|
||||
]);
|
||||
|
||||
$service->credentials = $service->driver()->defaultCredentials();
|
||||
$service->save();
|
||||
if (method_exists($service->driver(), 'defaultCredentials')) {
|
||||
$service->credentials = $service->driver()->defaultCredentials();
|
||||
$service->save();
|
||||
}
|
||||
|
||||
dispatch(new DeployService($service));
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ class Caddy2Driver extends GatewayDriver
|
||||
$script->push('cd services');
|
||||
$script->push("test -d {$this->service->id} || mkdir {$this->service->id}");
|
||||
$script->push("cd {$this->service->id}");
|
||||
return $script->join("\n");
|
||||
}
|
||||
),
|
||||
new Step(
|
||||
@@ -49,7 +50,9 @@ class Caddy2Driver extends GatewayDriver
|
||||
}
|
||||
$runCommand .= ' -p 80:80 -p 443:443 caddy:2';
|
||||
|
||||
return $runCommand;
|
||||
$script->push($runCommand);
|
||||
|
||||
return $script->join("\n");
|
||||
}
|
||||
),
|
||||
]);
|
||||
|
||||
@@ -18,6 +18,6 @@ abstract class Driver
|
||||
abstract public function __construct(
|
||||
?string $containerName = null,
|
||||
?string $containerId = null,
|
||||
?int $service = null,
|
||||
?Service $service = null,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -15,4 +15,4 @@ abstract class GatewayDriver extends Driver
|
||||
?string $containerId = null,
|
||||
?Service $service = null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Drivers\DatabaseDriver;
|
||||
use App\Drivers\Driver;
|
||||
use App\Enums\ServiceCategory;
|
||||
use App\Enums\ServiceStatus;
|
||||
@@ -57,11 +58,16 @@ class Service extends Model
|
||||
throw new \Exception("Driver class {$class} not found");
|
||||
}
|
||||
|
||||
return new $class(
|
||||
$driver = new $class(
|
||||
containerName: $this->container_name,
|
||||
containerId: $this->container_id,
|
||||
serviceId: $this->id,
|
||||
credentials: $this->credentials
|
||||
service: $this,
|
||||
);
|
||||
|
||||
if ($driver instanceof DatabaseDriver) {
|
||||
$driver->credentials = $this->credentials;
|
||||
}
|
||||
|
||||
return $driver;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ const props = defineProps({
|
||||
const form = useForm({
|
||||
name: null,
|
||||
category: null,
|
||||
service: null,
|
||||
type: null,
|
||||
version: null,
|
||||
});
|
||||
|
||||
@@ -45,8 +45,8 @@ function generateServiceName() {
|
||||
str += form.category.toLowerCase() + '-';
|
||||
}
|
||||
|
||||
if (form.service) {
|
||||
str += form.service.toLowerCase() + '-';
|
||||
if (form.type) {
|
||||
str += form.type.toLowerCase() + '-';
|
||||
}
|
||||
|
||||
if (form.version) {
|
||||
@@ -56,7 +56,7 @@ function generateServiceName() {
|
||||
return str;
|
||||
}
|
||||
|
||||
watch([() => form.category, () => form.service, () => form.version], () => {
|
||||
watch([() => form.category, () => form.type, () => form.version], () => {
|
||||
form.name = generateServiceName();
|
||||
});
|
||||
</script>
|
||||
@@ -98,20 +98,14 @@ watch([() => form.category, () => form.service, () => form.version], () => {
|
||||
</div>
|
||||
|
||||
<div v-if="form.category" class="grid gap-2 md:grid-cols-2 lg:grid-cols-3">
|
||||
<RadioButton
|
||||
v-for="service in services[form.category]"
|
||||
v-model="form.service"
|
||||
:value="service.name"
|
||||
name="service"
|
||||
class="py-3"
|
||||
>
|
||||
<RadioButton v-for="service in services[form.category]" v-model="form.type" :value="service.name" name="type" class="py-3">
|
||||
<h4 class="mb-1 text-lg font-semibold leading-none tracking-tighter">{{ service.name }}</h4>
|
||||
</RadioButton>
|
||||
</div>
|
||||
|
||||
<div v-if="form.service" class="grid gap-2 md:grid-cols-2 lg:grid-cols-3">
|
||||
<div v-if="form.type" class="grid gap-2 md:grid-cols-2 lg:grid-cols-3">
|
||||
<RadioButton
|
||||
v-for="(version, versionKey) in services[form.category][form.service].versions"
|
||||
v-for="(version, versionKey) in services[form.category][form.type].versions"
|
||||
v-model="form.version"
|
||||
:value="versionKey"
|
||||
name="version"
|
||||
@@ -128,7 +122,9 @@ watch([() => form.category, () => form.service, () => form.version], () => {
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-end">
|
||||
<Button @click="form.post(route('services.store', { organisation: $page.props.organisation.id, server: $page.props.server.id }))">Submit</Button>
|
||||
<Button @click="form.post(route('services.store', { organisation: $page.props.organisation.id, server: $page.props.server.id }))"
|
||||
>Submit</Button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</AppLayout>
|
||||
|
||||
Reference in New Issue
Block a user