This repository has been archived by the owner on Dec 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enh(update): check platform requirements on updates API call (#11361)
Refs: MON-12296
- Loading branch information
Showing
18 changed files
with
751 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/Core/Platform/Application/Validator/RequirementException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright 2005 - 2022 Centreon (https://www.centreon.com/) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* For more information : contact@centreon.com | ||
* | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Core\Platform\Application\Validator; | ||
|
||
class RequirementException extends \Exception | ||
{ | ||
} |
33 changes: 33 additions & 0 deletions
33
src/Core/Platform/Application/Validator/RequirementValidatorInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright 2005 - 2022 Centreon (https://www.centreon.com/) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* For more information : contact@centreon.com | ||
* | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Core\Platform\Application\Validator; | ||
|
||
interface RequirementValidatorInterface | ||
{ | ||
/** | ||
* Validate requirement or fail | ||
* | ||
* @throws RequirementException | ||
*/ | ||
public function validateRequirementOrFail(): void; | ||
} |
33 changes: 33 additions & 0 deletions
33
src/Core/Platform/Application/Validator/RequirementValidatorsInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright 2005 - 2022 Centreon (https://www.centreon.com/) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* For more information : contact@centreon.com | ||
* | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Core\Platform\Application\Validator; | ||
|
||
interface RequirementValidatorsInterface | ||
{ | ||
/** | ||
* Validate platform requirements or fail | ||
* | ||
* @throws RequirementException | ||
*/ | ||
public function validateRequirementsOrFail(): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/Core/Platform/Infrastructure/Validator/RequirementValidators.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright 2005 - 2022 Centreon (https://www.centreon.com/) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* For more information : contact@centreon.com | ||
* | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Core\Platform\Infrastructure\Validator; | ||
|
||
use Centreon\Domain\Log\LoggerTrait; | ||
use Core\Platform\Application\Validator\RequirementValidatorsInterface; | ||
use Core\Platform\Application\Validator\RequirementValidatorInterface; | ||
|
||
class RequirementValidators implements RequirementValidatorsInterface | ||
{ | ||
use LoggerTrait; | ||
|
||
/** | ||
* @var RequirementValidatorInterface[] | ||
*/ | ||
private $requirementValidators; | ||
|
||
/** | ||
* @param \Traversable<RequirementValidatorInterface> $requirementValidators | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function __construct( | ||
\Traversable $requirementValidators, | ||
) { | ||
if (iterator_count($requirementValidators) === 0) { | ||
throw new \Exception('Requirement validators not found'); | ||
} | ||
$this->requirementValidators = iterator_to_array($requirementValidators); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function validateRequirementsOrFail(): void | ||
{ | ||
foreach ($this->requirementValidators as $requirementValidator) { | ||
$this->info('Validating platform requirement with ' . $requirementValidator::class); | ||
$requirementValidator->validateRequirementOrFail(); | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
.../Platform/Infrastructure/Validator/RequirementValidators/DatabaseRequirementException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright 2005 - 2022 Centreon (https://www.centreon.com/) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* For more information : contact@centreon.com | ||
* | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Core\Platform\Infrastructure\Validator\RequirementValidators; | ||
|
||
use Core\Platform\Application\Validator\RequirementException; | ||
|
||
class DatabaseRequirementException extends RequirementException | ||
{ | ||
/** | ||
* @param \Throwable $e | ||
* @return self | ||
*/ | ||
public static function errorWhenGettingDatabaseVersion(\Throwable $e): self | ||
{ | ||
return new self( | ||
_('Error when getting database version'), | ||
0, | ||
$e, | ||
); | ||
} | ||
|
||
/** | ||
* @return self | ||
*/ | ||
public static function cannotRetrieveVersionInformation(): self | ||
{ | ||
return new self(_('Cannot retrieve database version information')); | ||
} | ||
} |
Oops, something went wrong.