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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix --es-enable-ssl handling #835

Merged
merged 1 commit into from
Mar 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions src/module-elasticsuite-core/Setup/ConfigOptionsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Magento\Framework\Config\File\ConfigFilePool;
use Magento\Framework\Config\Data\ConfigData;
use Magento\Framework\App\DeploymentConfig;
use Magento\Framework\Setup\Option\FlagConfigOption;
use Magento\Framework\Setup\Option\SelectConfigOption;

/**
* Handle ES parameters during setup.
Expand Down Expand Up @@ -76,10 +76,13 @@ public function getOptions()
self::CONFIG_PATH_ES_HOSTS,
'ElasticSearch Servers List.'
),
new FlagConfigOption(
new SelectConfigOption(
self::INPUT_KEY_ES_SSL,
SelectConfigOption::FRONTEND_WIZARD_SELECT,
[0, 1],
self::CONFIG_PATH_ES_SSL,
'Use SSL mode to connect to ElasticSearch.'
'Use SSL mode to connect to ElasticSearch.',
0
),
new TextConfigOption(
self::INPUT_KEY_ES_USER,
Expand Down Expand Up @@ -165,26 +168,32 @@ private function getClientOptions(array $options, DeploymentConfig $deploymentCo
*/
private function readConfiguration(array $options, DeploymentConfig $deploymentConfig, $inputKey)
{
$configPath = $this->getConfigPath($inputKey);
$config = null;
$option = $this->getOption($inputKey);

return $options[$inputKey] ?? ($configPath != null ? $deploymentConfig->get($configPath) : null);
if ($option) {
$configPath = $option->getConfigPath($inputKey);
$config = $options[$inputKey] ?? ($configPath != null ? $deploymentConfig->get($configPath) : $option->getDefault());
}

return $config;
}

/**
* Convert an inout key to a config path.
* Retrieve option by input key.
*
* @param string $inputKey Input key.
*
* @return NULL|string
* @return \Magento\Framework\Setup\Option\AbstractConfigOption|null
*/
private function getConfigPath($inputKey)
private function getOption($inputKey)
{
$configPath = null;
$option = null;

foreach ($this->getOptions() as $option) {
$configPath = $option->getName() == $inputKey ? $option->getConfigPath() : $configPath;
foreach ($this->getOptions() as $currentOption) {
$option = $currentOption->getName() == $inputKey ? $currentOption : $option;
}

return $configPath;
return $option;
}
}