Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed 'Config key is not set: host' error when executing status command #76

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/Command/Status.php
Expand Up @@ -45,10 +45,9 @@
{
$table = new Table($output);
$table
->setHeaders(['Host', 'Port', 'Version'])
->setHeaders(['Hosts', 'Version'])
->setRows([[
$this->esClient->getConfig('host'),
$this->esClient->getConfig('port'),
join(", ", $this->esClient->getConfig('hosts')),

Check failure on line 50 in src/Command/Status.php

View workflow job for this annotation

GitHub Actions / phpstan (PHP 8.1 with Pimcore ^11.0 (prefer-lowest) on ubuntu-latest)

Parameter #2 $pieces of function join expects array, array|bool|string given.

Check failure on line 50 in src/Command/Status.php

View workflow job for this annotation

GitHub Actions / phpstan (PHP 8.1 with Pimcore ^11.0 (prefer-stable) on ubuntu-latest)

Parameter #2 $pieces of function join expects array, array|bool|string given.

Check failure on line 50 in src/Command/Status.php

View workflow job for this annotation

GitHub Actions / phpstan (PHP 8.2 with Pimcore ^11.0 (prefer-lowest) on ubuntu-latest)

Parameter #2 $pieces of function join expects array, array|bool|string given.

Check failure on line 50 in src/Command/Status.php

View workflow job for this annotation

GitHub Actions / phpstan (PHP 8.2 with Pimcore ^11.0 (prefer-stable) on ubuntu-latest)

Parameter #2 $pieces of function join expects array, array|bool|string given.

Check failure on line 50 in src/Command/Status.php

View workflow job for this annotation

GitHub Actions / phpstan (PHP 8.1 with Pimcore ^11.0 (prefer-lowest) on ubuntu-latest)

Parameter #2 $pieces of function join expects array, array|bool|string given.

Check failure on line 50 in src/Command/Status.php

View workflow job for this annotation

GitHub Actions / phpstan (PHP 8.1 with Pimcore ^11.0 (prefer-stable) on ubuntu-latest)

Parameter #2 $pieces of function join expects array, array|bool|string given.

Check failure on line 50 in src/Command/Status.php

View workflow job for this annotation

GitHub Actions / phpstan (PHP 8.2 with Pimcore ^11.0 (prefer-lowest) on ubuntu-latest)

Parameter #2 $pieces of function join expects array, array|bool|string given.

Check failure on line 50 in src/Command/Status.php

View workflow job for this annotation

GitHub Actions / phpstan (PHP 8.2 with Pimcore ^11.0 (prefer-stable) on ubuntu-latest)

Parameter #2 $pieces of function join expects array, array|bool|string given.
$this->esClient->getVersion(),
]])
->setHeaderTitle('Cluster');
Comment on lines 45 to 53
Copy link
Contributor

@rliebi rliebi Apr 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{
$table = new Table($output);
$table
->setHeaders(['Host', 'Port', 'Version'])
->setHeaders(['Hosts', 'Version'])
->setRows([[
$this->esClient->getConfig('host'),
$this->esClient->getConfig('port'),
join(", ", $this->esClient->getConfig('hosts')),
$this->esClient->getVersion(),
]])
->setHeaderTitle('Cluster');
$config = [
...$this->esClient->getConfig(),
'version' => $this->esClient->getVersion(),
];
$table = new Table($this->io);
$table
->setHeaders(['Key', 'Value'])
->setRows(self::flattenConfig($config))
->setHeaderTitle('Cluster');
$table->render();
     private static function flattenConfig($config, $prefix = ''): array {
        $rows = [];
        foreach ($config as $key => $value) {
            if (is_array($value)) {
                foreach (self::flattenConfig($value, $prefix . $key . '.') as $row) {
                    $rows[] = $row;
                }
            } else {
                $rows[] = [$prefix . $key, $value];
            }
        }
        return $rows;
    }

Expand Down