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
Add a --config parameter to import config after install. #1875
Conversation
| if ($config = drush_get_option('config')) { | ||
| // Set the destination site UUID to match the source UUID, to bypass a core fail-safe. | ||
| $source_storage = new FileStorage($config); | ||
| drush_op('drush_config_set', 'system.site', 'uuid', $source_storage->read('system.site')['uuid']); |
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.
Doesn't this modify the UUID from the source config (i.e. what's on disk)? That is not a desirable behavior if the config is in version control - that config on disk should never change IMO. Since this option is only available when installing a fresh site, I think it's safe enough to change what's in the site instead of in the config directory.
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.
No, it modifies the UUID in the active config of the newly installed site. I've been using @markdorison's variation on this and it has never modified the source yml file on disk.
|
I think this should also change the default profile choice to Minimal if --config is passed. Minimal doesn't create any config entities by default, whereas Standard does (shortcut links is what bit us in the past). Minimal provides the most likely path to success when installing from config, so it makes sense to me to switch that default. |
|
That seems like a sound idea. It also makes the whole process faster. |
|
Commit added to default to 'minimal' per @cweagans suggestion. |
|
Hmm. Regardless of what you default the installation to, the imported configuration (assuming it includes |
|
@simesy I think it's okay to default to Minimal. If they're using some other profile, they can change it by adding the profile argument. |
| @@ -55,7 +56,8 @@ function site_install_drush_command() { | |||
| 'example-value' => 'directory_name', | |||
| ), | |||
| 'writable' => 'Make CMI and other dirs writable by both web and CLI users. Suitable for non Prod environments.', | |||
| 'keep-config' => 'Keep CMI directories untouched. This preserves existing configuration.' | |||
| 'keep-config' => 'Keep CMI directories untouched. This preserves existing configuration.', | |||
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.
options that are version specific should get altered in so they aren't valid or shown for other versions. see user_drush_help_alter() for example.
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.
Commit just pushed removes --config for versions less than 8.
|
Left some minor comments. Would be good to hear that this actually works for folks. |
|
To recap: All comments addressed. The call needs to be made about removing the 'minimal' profile part, I would suggest removing it unless we can replicate the problem it's mitigating. |
| @@ -55,7 +56,8 @@ function site_install_drush_command() { | |||
| 'example-value' => 'directory_name', | |||
| ), | |||
| 'writable' => 'Make CMI and other dirs writable by both web and CLI users. Suitable for non Prod environments.', | |||
| 'keep-config' => 'Keep CMI directories untouched. This preserves existing configuration.' | |||
| 'keep-config' => 'Keep CMI directories untouched. This preserves existing configuration.', | |||
| 'config' => 'After installation, override all configuration and UUIDs that were generated during installation with config from this file path.' | |||
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.
"Update site UUID and then import configuration from this path."
|
Resolved comments in last commit. |
|
Squashed and merged. Thanks much. |
|
This looks like it will be a good and useful feature, but we are not done yet; the new site-install option --config conflicts with the existing Drush global --config option, so folks like me who set --config cannot run site-install. This local option needs to be renamed to something else. |
Suggested fix for #1875: rename --config to --config-dir
|
Thanks greg! |
|
There are quite a few gotcha with this approach. If the install profiles on the source config and the drush install don't match then there are issues. Also the install language is interesting - I think it should match the site default language from system.site. To be honest I really wish we all got behind https://www.drupal.org/project/config_installer since this is doing exactly what people want, does it without installing incorrect config first, and has tests. |
|
I believe that the config installer works with drush site-install. It sounds like the implementation of config_installer is currently more robust than what we have here, but some folks prefer the DX of the --config. Maybe some work could be done here to ensure consistency between installation variables and their corresponding configuration values. I don't know that it's a problem to install minimal profile first. I think that the ideal solution, for the future would be to take the operation of the config_installer and make it part of the core installation code rather than having it be a separate installation profile. Until then, what we have is just a choice between different workarounds. |
|
@alexpott To be honest I really wish we all got behind config_installer |
|
Some help for those just catching up here. So I've got a site profile which installs fine with however when I run This error does not really mean anything to me, where am I going wrong? |
|
@simesy have you seen https://www.drupal.org/node/2642398 ? |
|
@dgtlmoon The practical solution is to use https://www.drupal.org/project/config_installer For a projects:
config_installer:
type: "profile"
version: "1.3"Installation: drush site-install config_installer --config-dir=PATH/TO/config/base --yes |
|
I need to enable my own profile and import config from the repo to build a fresh site from code.
How can I use config_installer to import the config? It is not possible to have two profiles enabled at the same time. |
|
I think I figured out why it wasn't working and how config_installer knows that I want my_profile enabled. Basically core.extension.yml is what defines which profile will be enabled. I had an entry for standard: 0 which I changed to my_profile: 0 Now it works. I can only make it work using the UI. When using drush, I get an error saying that the folder config/base is empty. |
…h existing Drush global --config option. Rename the new site-install option to --config-dir.
Passing a --config parameter (eg.
drush site-install --config=path/to/config) triggers the equivalent of adrush config-import --source=path/to/configafter the installation is complete.This is all-or-nothing, any UUIDs generated during the site installation will be overwritten, any config created during the installation that is not represented in the --config directory will be deleted.
A use case for feature is CI/testing where the source directory contains a known set of configuration to be tested.
For history of this feature see #1635