Automattic / vip-cli

The VIP CLI
https://docs.wpvip.com/vip-cli/
MIT License
59 stars 16 forks source link

`dev-env import sql` requires user input #1561

Closed ethitter closed 9 months ago

ethitter commented 10 months ago

Expected/Desired Behavior

Run vip dev-env import sql without user input.

Actual Behavior

Command prompts if ES should be reindexed after import, even when environment was created with --elasticsearch=false flag.

Steps to Reproduce the Problem

  1. Run vip dev-env create (with or without --elasticsearch=false flag
  2. Run vip dev-env import sql [FILE]
  3. Observe that you're prompted to reindex ES.

Additional notes

I'm working on an automation that uses vip dev-env to set up an environment, import a database backup that VIP shipped to our S3 bucket, and run various WP-CLI commands against the environment. The ES-indexing prompt breaks the automation by requiring user input.

sjinks commented 10 months ago

What version of VIP CLI are you using?

This is what I see with the latest one:

$ vip dev-env info
Running validation steps...
✓ Check for Docker installation 
✓ Check for docker-compose installation 
✓ Check Docker connectivity 
✓ Check DNS resolution 
 SLUG              vip-local                                                                                               
 LOCATION          /home/volodymyr/.local/share/vip/dev-environment/vip-local                                              
 SERVICES          devtools, nginx, php, database, memcached, wordpress, vip-mu-plugins, demo-app-code                     
 NGINX URLS        http://vip-local.vipdev.lndo.site:8000/                                                                 
                   https://vip-local.vipdev.lndo.site:444/                                                                 
 DATABASE          127.0.0.1:32818                                                                                         
 STATUS            UP                                                                                                      
 LOGIN URL         http://vip-local.vipdev.lndo.site:8000/wp-admin/?vip-dev-autologin=8ec227b0-fc46-4486-b3ce-af6a09ce7bd8 
 DEFAULT USERNAME  vipgo                                                                                                   
 DEFAULT PASSWORD  password                                                                                                
 DOCUMENTATION     https://docs.wpvip.com/technical-references/vip-local-development-environment/                          

$ vip dev-env import sql data.sql
Running validation steps...
Finished processing 446 lines.

✅ SET @@SESSION.sql_log_bin statement was found 0 times.
✅ TRIGGER statement was found 0 times.
✅ DROP DATABASE statement was found 0 times.
✅ USE <DATABASE_NAME> statement was found 0 times.
✅ ALTER USER statement was found 0 times.
✅ DROP TABLE was found 13 times.
✅ CREATE TABLE was found 13 times.
 - wp_ prefix tables found: 13 
✅ ALTER TABLE statement was found 0 times.
✅ SET UNIQUE_CHECKS = 0 was found 0 times.
siteurl
✅ Siteurl/home options not pointing to lando domain was found 0 times.
✅ ENGINE != InnoDB was found 0 times.

mysql: [Warning] Using a password on the command line interface can be insecure.
Success: Database imported.
Success: The cache was flushed.
User "vipgo" already exits. Skipping creating it.
sjinks commented 10 months ago

The prompt is shown only when Elasticsearch is enabled. This could also happen if you have VIP_ENABLE_VIP_SEARCH and VIP_ENABLE_VIP_SEARCH_QUERY_INTEGRATION constants defined.

sjinks commented 10 months ago

You can run vip dev-env import sql data.sql < /dev/null to suppress prompts. When the stdin is not a TTY, the app won't prompt for reindex confirmation.