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 command line flag to limit tasks #59

Closed
sjthespian opened this issue Oct 11, 2021 · 4 comments
Closed

Add command line flag to limit tasks #59

sjthespian opened this issue Oct 11, 2021 · 4 comments

Comments

@sjthespian
Copy link
Contributor

I have a dregsy yaml file that syncs to 5 different docker registries. From time to time, I would like to be able to run a manual sync to just one or two of them w/o having to extract that data to a separate yaml file. It would be very useful to be able to specify which tasks to run from the command line. I'm thinking something along the lines of what anisble-playbook uses:
dregsy --config regsync.yml --limit sync-registry2

@xelalexv
Copy link
Owner

Interesting. I see how that could be handy. We could go for two complementary flags though, --select and --deselect, or alternatively --include/--exclude. Not sure yet which one is better.

In the meantime, you could use yq to filter your config file, e.g.:

# include all test-* tasks
yq eval 'del(.tasks.[] | select(.name != "test-*"))' dregsy.yaml

# exclude all test-* tasks
yq eval 'del(.tasks.[] | select(.name == "test-*"))' dregsy.yaml

There should be an expression with only select, but I couldn't figure out how to do that just now.

@xelalexv xelalexv changed the title Feature request: command line flag to limit tasks add command line flag to limit tasks Oct 11, 2021
@rubin55
Copy link

rubin55 commented Feb 19, 2022

What about --task which if not specified simply does all tasks defined in the configuration file, but can be specified multiple times to select tasks to run, like:

$ dregsy --config my_config_with_many_tasks.yaml --task foo --task bar --task baz

@xelalexv xelalexv changed the title add command line flag to limit tasks Add command line flag to limit tasks Jun 1, 2022
@xelalexv
Copy link
Owner

xelalexv commented Jun 3, 2022

I finally settled on -run {regexp}, similar to go test -run {regexp}. This selects the tasks to be run. Only difference to go test is that here the expression already does a line match, so you don't need to place the expression in ^...$ to get an exact match. For example, -run=task-a will only select task-a, but not task-abc.

@xelalexv xelalexv added the in progress currently being worked on label Jun 3, 2022
@xelalexv xelalexv removed the in progress currently being worked on label Jun 3, 2022
@xelalexv
Copy link
Owner

xelalexv commented Jun 3, 2022

done with PR #76

@xelalexv xelalexv closed this as completed Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants