Skip to content

Commit

Permalink
php: Streamline vendor file location with local dev-env (#961)
Browse files Browse the repository at this point in the history
  • Loading branch information
nilmerg authored Mar 14, 2024
2 parents 274b903 + b928705 commit b18db1c
Show file tree
Hide file tree
Showing 78 changed files with 1,042 additions and 568 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ jobs:

- name: Setup dependencies
run: |
composer require -n --no-progress overtrue/phplint
git clone --depth 1 https://github.com/Icinga/icingaweb2.git vendor/icingaweb2
git clone --depth 1 https://github.com/Icinga/icingaweb2-module-reporting.git vendor/reporting
git clone --depth 1 https://github.com/Icinga/icingaweb2-module-x509.git vendor/x509
git clone --depth 1 https://github.com/Icinga/icingaweb2-module-pdfexport.git vendor/pdfexport
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-library.git vendor/icinga-php-library
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git vendor/icinga-php-thirdparty
composer require -n --no-progress overtrue/phplint phpstan/phpstan
sudo git clone --depth 1 https://github.com/Icinga/icingaweb2.git /icingaweb2
sudo git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-library.git /usr/share/icinga-php/ipl
sudo git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git /usr/share/icinga-php/vendor
sudo git clone --depth 1 https://github.com/Icinga/icingaweb2-module-reporting.git /usr/share/icingaweb2-modules/reporting
sudo git clone --depth 1 https://github.com/Icinga/icingaweb2-module-pdfexport.git /usr/share/icingaweb2-modules/pdfexport
sudo git clone --depth 1 https://github.com/Icinga/icingaweb2-module-x509.git /usr/share/icingaweb2-modules/x509
- name: PHP Lint
if: ${{ ! cancelled() }}
Expand All @@ -50,7 +50,7 @@ jobs:

- name: PHPStan
if: ${{ ! cancelled() }}
uses: php-actions/phpstan@v3
run: ./vendor/bin/phpstan analyse

test:
name: Unit tests with php ${{ matrix.php }} on ${{ matrix.os }}
Expand Down
9 changes: 3 additions & 6 deletions application/clicommands/MigrateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,8 @@ public function dashboardAction(): void
);

$changed = false;
/** @var ConfigObject $dashboardConfig */
/** @var ConfigObject<string> $dashboardConfig */
foreach ($dashboardsConfig->getConfigObject() as $name => $dashboardConfig) {
/** @var ?string $dashboardUrlString */
$dashboardUrlString = $dashboardConfig->get('url');
if ($dashboardUrlString !== null) {
$dashBoardUrl = Url::fromPath($dashboardUrlString, [], new Request());
Expand Down Expand Up @@ -595,9 +594,8 @@ public function filterAction(): void
private function transformNavigationItems(Config $config, string $owner, int &$rc): bool
{
$updated = false;
/** @var ConfigObject $newConfigObject */
/** @var ConfigObject<string> $newConfigObject */
foreach ($config->getConfigObject() as $section => $newConfigObject) {
/** @var string $configOwner */
$configOwner = $newConfigObject->get('owner') ?? '';
if ($configOwner && $configOwner !== $owner) {
continue;
Expand Down Expand Up @@ -686,9 +684,8 @@ private function migrateNavigationItems(Config $config, string $owner, string $p
$newConfig = $config->getConfigFile() === $path ? $config : $this->readFromIni($path, $rc);

$updated = false;
/** @var ConfigObject $configObject */
/** @var ConfigObject<string> $configObject */
foreach ($config->getConfigObject() as $configObject) {
/** @var string $configOwner */
$configOwner = $configObject->get('owner') ?? '';
if ($configOwner && $configOwner !== $owner) {
continue;
Expand Down
4 changes: 2 additions & 2 deletions library/Icingadb/Command/Transport/CommandTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static function getConfig(): Config
/**
* Create a transport from config
*
* @param ConfigObject $config
* @param ConfigObject<string> $config
*
* @return ApiCommandTransport
*
Expand All @@ -59,7 +59,7 @@ public static function getConfig(): Config
public static function createTransport(ConfigObject $config): ApiCommandTransport
{
$config = clone $config;
switch (strtolower($config->transport)) {
switch (strtolower($config->transport ?? '')) {
case ApiCommandTransport::TRANSPORT:
$transport = new ApiCommandTransport();
break;
Expand Down
15 changes: 8 additions & 7 deletions library/Icingadb/Compat/CompatObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,14 @@ protected function getDataView()
*/
private function getBoolType($value)
{
switch ($value) {
case false:
return 0;
case true:
return 1;
case 'sticky':
return 2;
if ($value === 'sticky') {
return 2;
}

if (is_string($value)) {
return null;
}

return (int) $value;
}
}
16 changes: 16 additions & 0 deletions library/Icingadb/Model/AcknowledgementHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Icinga\Module\Icingadb\Model;

use DateTime;
use Icinga\Module\Icingadb\Model\Behavior\BoolCast;
use ipl\Orm\Behavior\Binary;
use ipl\Orm\Behavior\MillisecondTimestamp;
Expand All @@ -16,6 +17,21 @@
*
* Please note that using this model will fetch history entries for decommissioned services. To avoid this, the query
* needs a `acknowledgement_history.service_id IS NULL OR acknowledgement_history_service.id IS NOT NULL` where.
*
* @property string $id
* @property string $environment_id
* @property ?string $endpoint_id
* @property string $object_type
* @property string $host_id
* @property ?string $service_id
* @property DateTime $set_time
* @property ?DateTime $clear_time
* @property ?string $author
* @property ?string $cleared_by
* @property ?string $comment
* @property ?DateTime $expire_time
* @property ?bool $is_sticky
* @property ?bool $is_persistent
*/
class AcknowledgementHistory extends Model
{
Expand Down
5 changes: 5 additions & 0 deletions library/Icingadb/Model/ActionUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
use ipl\Orm\Model;
use ipl\Orm\Relations;

/**
* @property string $id
* @property string[] $action_url
* @property string $environment_id
*/
class ActionUrl extends Model
{
public function getTableName()
Expand Down
11 changes: 11 additions & 0 deletions library/Icingadb/Model/Checkcommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@
use ipl\Orm\Model;
use ipl\Orm\Relations;

/**
* @property string $id
* @property ?string $zone_id
* @property string $environment_id
* @property string $name_checksum
* @property string $properties_checksum
* @property string $name
* @property string $name_ci
* @property string $command
* @property int $timeout
*/
class Checkcommand extends Model
{
public function getTableName()
Expand Down
17 changes: 17 additions & 0 deletions library/Icingadb/Model/CheckcommandArgument.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@
use ipl\Orm\Model;
use ipl\Orm\Relations;

/**
* @property string $id
* @property string $checkcommand_id
* @property string $argument_key
* @property string $environment_id
* @property string $properties_checksum
* @property ?string $argument_value
* @property ?int $argument_order
* @property ?string $description
* @property ?string $argument_key_override
* @property string $repeat_key
* @property string $required
* @property ?string $set_if
* @property ?string $separator
* @property string $skip_key
*/
class CheckcommandArgument extends Model
{
public function getTableName()
Expand All @@ -35,6 +51,7 @@ public function getColumns()
'repeat_key',
'required',
'set_if',
'separator',
'skip_key'
];
}
Expand Down
6 changes: 6 additions & 0 deletions library/Icingadb/Model/CheckcommandCustomvar.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
use ipl\Orm\Model;
use ipl\Orm\Relations;

/**
* @property string $id
* @property string $checkcommand_id
* @property string $customvar_id
* @property string $environment_id
*/
class CheckcommandCustomvar extends Model
{
public function getTableName()
Expand Down
8 changes: 8 additions & 0 deletions library/Icingadb/Model/CheckcommandEnvvar.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
use ipl\Orm\Model;
use ipl\Orm\Relations;

/**
* @property string $id
* @property string $checkcommand_id
* @property string $envvar_key
* @property string $environment_id
* @property string $properties_checksum
* @property string $envvar_value
*/
class CheckcommandEnvvar extends Model
{
public function getTableName()
Expand Down
19 changes: 19 additions & 0 deletions library/Icingadb/Model/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Icinga\Module\Icingadb\Model;

use DateTime;
use Icinga\Module\Icingadb\Model\Behavior\BoolCast;
use Icinga\Module\Icingadb\Model\Behavior\ReRoute;
use ipl\Orm\Behavior\Binary;
Expand All @@ -12,6 +13,24 @@
use ipl\Orm\Model;
use ipl\Orm\Relations;

/**
* @property string $id
* @property string $environment_id
* @property string $object_type
* @property string $host_id
* @property ?string $service_id
* @property string $name_checksum
* @property string $properties_checksum
* @property string $name
* @property string $author
* @property string $text
* @property string $entry_type
* @property DateTime $entry_time
* @property bool $is_persistent
* @property bool $is_sticky
* @property ?DateTime $expire_time
* @property ?string $zone_id
*/
class Comment extends Model
{
public function getTableName()
Expand Down
18 changes: 18 additions & 0 deletions library/Icingadb/Model/CommentHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Icinga\Module\Icingadb\Model;

use DateTime;
use Icinga\Module\Icingadb\Model\Behavior\BoolCast;
use ipl\Orm\Behavior\Binary;
use ipl\Orm\Behavior\MillisecondTimestamp;
Expand All @@ -16,6 +17,23 @@
*
* Please note that using this model will fetch history entries for decommissioned services. To avoid this,
* the query needs a `comment_history.service_id IS NULL OR comment_history_service.id IS NOT NULL` where.
*
* @property string $comment_id
* @property string $environment_id
* @property ?string $endpoint_id
* @property string $object_type
* @property string $host_id
* @property ?string $service_id
* @property DateTime $entry_time
* @property string $author
* @property ?string $removed_by
* @property string $comment
* @property string $entry_type
* @property bool $is_persistent
* @property bool $is_sticky
* @property ?DateTime $expire_time
* @property ?DateTime $remove_time
* @property bool $has_been_removed
*/
class CommentHistory extends Model
{
Expand Down
7 changes: 7 additions & 0 deletions library/Icingadb/Model/Customvar.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
use ipl\Orm\Model;
use ipl\Orm\Relations;

/**
* @property string $id
* @property string $environment_id
* @property string $name_checksum
* @property string $name
* @property string $value
*/
class Customvar extends Model
{
public function getTableName()
Expand Down
8 changes: 8 additions & 0 deletions library/Icingadb/Model/CustomvarFlat.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
use ipl\Orm\Relations;
use Traversable;

/**
* @property string $id
* @property string $environment_id
* @property string $customvar_id
* @property string $flatname_checksum
* @property string $flatname
* @property ?string $flatvalue
*/
class CustomvarFlat extends Model
{
public function getTableName()
Expand Down
27 changes: 27 additions & 0 deletions library/Icingadb/Model/Downtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Icinga\Module\Icingadb\Model;

use DateTime;
use Icinga\Module\Icingadb\Model\Behavior\BoolCast;
use Icinga\Module\Icingadb\Model\Behavior\ReRoute;
use ipl\Orm\Behavior\Binary;
Expand All @@ -12,6 +13,32 @@
use ipl\Orm\Model;
use ipl\Orm\Relations;

/**
* @property string $id
* @property string $environment_id
* @property ?string $triggered_by_id
* @property ?string $parent_id
* @property string $object_type
* @property string $host_id
* @property ?string $service_id
* @property string $name_checksum
* @property string $properties_checksum
* @property string $name
* @property string $author
* @property string $comment
* @property DateTime $entry_time
* @property DateTime $scheduled_start_time
* @property DateTime $scheduled_end_time
* @property int $scheduled_duration
* @property bool $is_flexible
* @property int $flexible_duration
* @property bool $is_in_effect
* @property ?DateTime $start_time
* @property ?DateTime $end_time
* @property int $duration
* @property ?string $scheduled_by
* @property ?string $zone_id
*/
class Downtime extends Model
{
public function getTableName()
Expand Down
Loading

0 comments on commit b18db1c

Please sign in to comment.