saleor / cli

Command-line interface allowing interaction with Saleor Cloud environments.
Other
69 stars 23 forks source link

Allow to load multiple backups in single command #708

Open andrzejewsky opened 10 months ago

andrzejewsky commented 10 months ago

Sometimes there is a need to load multiple backups at once for multiple environments. In most cases this reload happens agains backups that are compatible with given environment.

Currently, if we want to do this, we have to call backup command in a loop, passing there all of environments that we want to impact.

Proposal

We can have a command that will load backups for given environments that matches some pattern within its name/domain, where these backups are loaded accordingly to its compatibility. Examples below:

Command that loads backup name snapshot-automation-tests in version 3.15 for envs that match pattern staging.*:

saleor backup restore snapshot-automation-tests:3.15 --environment=staging.*

Command that loads backup name snapshot-automation-tests in latest compatible version for each env that match pattern staging.*:

saleor backup restore snapshot-automation-tests:latest --environment=staging.*

Note: considering this example, when we have env with on version 3.15 it seeks for snapshot-automation-tests in 3.15, if it's not present, it takes 3.14, and so on.

Command that loads backup name snapshot-automation-tests in version 3.15 for specific env:

saleor backup restore snapshot-automation-tests:3.15 --environment=test1

Command that loads backup name snapshot-automation-tests in latest compatible version that fits given env:

saleor backup restore snapshot-automation-tests:latest --environment=test1

Note: Assuming that test1 i on 3.14 it will take snapshot-automation-tests in version 3.14 first.

User prompt / CI We have to also consider two options of executing it.

Default one when the user is calling this command by hand - in this case we have to present the user what envs will be affected and what backups in which version (each) will be used. (eg. table with columns: env - backup - version)

Second one, dedicated for the CI that just skips the prompt with confirmation and table that includes summary (--force kind of)