fix: logdrains validation
This commit is contained in:
parent
34c7aa122c
commit
165d35959e
1 changed files with 39 additions and 1 deletions
|
|
@ -52,7 +52,7 @@ public function mount(string $server_uuid)
|
||||||
public function syncData(bool $toModel = false)
|
public function syncData(bool $toModel = false)
|
||||||
{
|
{
|
||||||
if ($toModel) {
|
if ($toModel) {
|
||||||
$this->validate();
|
$this->customValidation();
|
||||||
$this->server->settings->is_logdrain_newrelic_enabled = $this->isLogDrainNewRelicEnabled;
|
$this->server->settings->is_logdrain_newrelic_enabled = $this->isLogDrainNewRelicEnabled;
|
||||||
$this->server->settings->is_logdrain_axiom_enabled = $this->isLogDrainAxiomEnabled;
|
$this->server->settings->is_logdrain_axiom_enabled = $this->isLogDrainAxiomEnabled;
|
||||||
$this->server->settings->is_logdrain_custom_enabled = $this->isLogDrainCustomEnabled;
|
$this->server->settings->is_logdrain_custom_enabled = $this->isLogDrainCustomEnabled;
|
||||||
|
|
@ -79,6 +79,44 @@ public function syncData(bool $toModel = false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function customValidation()
|
||||||
|
{
|
||||||
|
if ($this->isLogDrainNewRelicEnabled) {
|
||||||
|
try {
|
||||||
|
$this->validate([
|
||||||
|
'logDrainNewRelicLicenseKey' => ['required'],
|
||||||
|
'logDrainNewRelicBaseUri' => ['required', 'url'],
|
||||||
|
]);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->isLogDrainNewRelicEnabled = false;
|
||||||
|
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
} elseif ($this->isLogDrainAxiomEnabled) {
|
||||||
|
try {
|
||||||
|
$this->validate([
|
||||||
|
'logDrainAxiomDatasetName' => ['required'],
|
||||||
|
'logDrainAxiomApiKey' => ['required'],
|
||||||
|
]);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->isLogDrainAxiomEnabled = false;
|
||||||
|
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
} elseif ($this->isLogDrainCustomEnabled) {
|
||||||
|
try {
|
||||||
|
$this->validate([
|
||||||
|
'logDrainCustomConfig' => ['required'],
|
||||||
|
'logDrainCustomConfigParser' => ['string', 'nullable'],
|
||||||
|
]);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->isLogDrainCustomEnabled = false;
|
||||||
|
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function instantSave()
|
public function instantSave()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue