-
Notifications
You must be signed in to change notification settings - Fork 4
Fixed 'Config key is not set: host' error when executing status command #76
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @christianbader thank you :-) I have the feeling you are not on version 4.2.0 of Elastica bridge. However, if we change this, we should change it to something like this. What do you think?
The output would then look like this:
+------------------- Cluster ----+---------------+
| Key | Value |
+--------------------------------+---------------+
| host | |
| port | |
| path | |
| url | |
| connections.0.host | elasticsearch |
| connections.0.port | 9200 |
| connections.0.transport_config | http_client |
| roundRobin | |
| retryOnConflict | 0 |
| username | |
| password | |
| connectionStrategy | Simple |
+--------------------------------+---------------+
{ | ||
$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'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | |
$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;
}
Other suggestions are welcome 😄