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