mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 05:56:16 +00:00
code style fix
add command tests
This commit is contained in:
@ -59,7 +59,7 @@ private function validate($type, Server $server, array $input): void
|
||||
'0 0 * * *',
|
||||
'0 0 * * 0',
|
||||
'0 0 1 * *',
|
||||
'custom'
|
||||
'custom',
|
||||
]),
|
||||
],
|
||||
];
|
||||
|
@ -6,7 +6,6 @@
|
||||
use App\Models\FirewallRule;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class CreateRule
|
||||
|
@ -15,7 +15,7 @@ public function connect(array $input): void
|
||||
$sourceControl = new SourceControl([
|
||||
'provider' => $input['provider'],
|
||||
'profile' => $input['name'],
|
||||
'access_token' => $input['token']
|
||||
'access_token' => $input['token'],
|
||||
]);
|
||||
|
||||
if (! $sourceControl->provider()->connect()) {
|
||||
@ -24,7 +24,7 @@ public function connect(array $input): void
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$sourceControl->save();
|
||||
}
|
||||
|
||||
@ -36,14 +36,14 @@ private function validate(array $input): void
|
||||
$rules = [
|
||||
'provider' => [
|
||||
'required',
|
||||
Rule::in(\App\Enums\SourceControl::getValues())
|
||||
Rule::in(\App\Enums\SourceControl::getValues()),
|
||||
],
|
||||
'name' => [
|
||||
'required',
|
||||
],
|
||||
'token' => [
|
||||
'required'
|
||||
]
|
||||
'required',
|
||||
],
|
||||
];
|
||||
Validator::make($input, $rules)->validate();
|
||||
}
|
||||
|
@ -22,15 +22,15 @@ public function create(User $user, array $input): void
|
||||
'provider' => $input['provider'],
|
||||
'profile' => $input['name'],
|
||||
'credentials' => [
|
||||
'token' => $input['token']
|
||||
]
|
||||
'token' => $input['token'],
|
||||
],
|
||||
]);
|
||||
if (! $storageProvider->provider()->connect()) {
|
||||
throw ValidationException::withMessages([
|
||||
'token' => __("Couldn't connect to the provider")
|
||||
'token' => __("Couldn't connect to the provider"),
|
||||
]);
|
||||
}
|
||||
$storageProvider->save();;
|
||||
$storageProvider->save();
|
||||
}
|
||||
|
||||
private function validate(User $user, array $input): void
|
||||
@ -45,8 +45,8 @@ private function validate(User $user, array $input): void
|
||||
Rule::unique('storage_providers', 'profile')->where('user_id', $user->id),
|
||||
],
|
||||
'token' => [
|
||||
'required'
|
||||
]
|
||||
'required',
|
||||
],
|
||||
])->validate();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user