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

Add subcommand for bulk actions #2327

Open
jsoriano opened this issue Jan 9, 2025 · 0 comments
Open

Add subcommand for bulk actions #2327

jsoriano opened this issue Jan 9, 2025 · 0 comments

Comments

@jsoriano
Copy link
Member

jsoriano commented Jan 9, 2025

In repositories with multiple packages, and in elastic-package development itself, it is usual to run actions on multiple packages. For this, the developer usually needs to craft some kind of shell pipeline.

It could be useful to introduce in elastic-package a subcommand that can discover packages under certain rules and run some other subcommand for the discovered packages. For example the following command would add a changelog to all the modified packages under the packages directory.

elastic-package foreach --modified --packages ./packages/* changelog add ...

Or to test elastic-package while development with a set of packages:

elastic-package foreach --packages ./test/packages/parallel/* test

In general, its usage would be like this:

elastic-package foreach [discovery flags] [other flags] [subcommand] [subcommand flags]

Discovery flags

The subcommand would contain a set of flags used to discover packages, that can be combined, for example:

  • --modified to select only packages with modified files.
  • --packages [glob] to select packages matching with a glob pattern.
  • --auto to walk the repository looking for compatible manifest files.
  • --constraint [constraint] to filter packages based on their constraints (like --constraint kibana.version=8.17.0).

Not all these flags would be needed in a first MVP, they could be added later, as well as other flags.

Technically, the foreach subcommand would call the specified subcommand for each one of the discovered packages, setting for the called subcommands the -C flag.

Other flags

There could be support for other flags that control execution of subcommands, for example --parallel 4 would allow the execution of four subcommands in parallel.

Available subcommands

In principle all subcommands would be supported, we would need to investigate what is the best implementation so the --help makes sense and avoid loops between subcommands.

Additionally, we could add some kind of query subcommand that could help in shell pipelines or just listing info from packages. For example the following to list the name of modified packages:

elastic-package foreach --modified query --path manifest.package.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant