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

ability to exclude specific folders when use --filter generating configs #248

Open
rjsigma opened this issue Sep 15, 2022 · 6 comments
Open

Comments

@rjsigma
Copy link

rjsigma commented Sep 15, 2022

We can use --filter command line parameters to limit configuration generation within a certain glob pattern. However, there is no easy way to exclude some specific folders within the glob pattern.
For example, if we have following directory structure

- a
    |- b
    |- c
    |- d

there is no easy way to specify following:

  • all subdirectories of a except d should use workflow1
  • while d should use workflow2
@rjsigma rjsigma changed the title ability to exclude specific folders when use --filter when generate configs ability to exclude specific folders when use --filter generating configs Sep 15, 2022
@gmaghera
Copy link
Contributor

You can do this with what's available today:
a/[^d]* would match workflow1 items, all subdirectories of a, except the one which starts with d.

See this example https://go.dev/play/p/iFJsnv6uBAx, which uses the function Match. In our case, Glob() is used, but the docs say it abides by the same pattern as Match().

@gmaghera
Copy link
Contributor

@rjsigma have you tried the globbing pattern I've suggested?

@SerhiiSokolov
Copy link

SerhiiSokolov commented Oct 21, 2022

Hi @gmaghera
Unfortunately go Glob is very limited.
I have a case where need to generate a config for the folders

live-infrastructure/account_123456789012
live-infrastructure/domain/onename/something-01-121234567890
live-infrastructure/anotherdomain/second_name/somethingtwo-01-131234567890

According to the https://www.digitalocean.com/community/tools/glob?comments=true&glob=%2A%2A%2F%2A%2B%28123456789012%7C121234567890%7C131234567890%29&matches=false&tests=%2F%2F%20Imported%20from%20tree%20command&tests=live-infrastructure%2Faccount_123456789012&tests=live-infrastructure%2Fanotherdomain%2Fsecond_name%2Fsomethingtwo-01-131234567890&tests=live-infrastructure%2Fdomain%2Fonename%2Fsomething-01-121234567890
the pattern **/*+(123456789012|121234567890|131234567890) should cover this structure.
But If I use provided example from https://go.dev/play/p/iFJsnv6uBAx and try to set my pattern it does not work and seems it happens because go match is very limited according to the documentation

pattern:
	{ term }
term:
	'*'         matches any sequence of non-Separator characters
	'?'         matches any single non-Separator character
	'[' [ '^' ] { character-range } ']'
	            character class (must be non-empty)
	c           matches character c (c != '*', '?', '\\', '[')
	'\\' c      matches character c

character-range:
	c           matches character c (c != '\\', '-', ']')
	'\\' c      matches character c
	lo '-' hi   matches character c for lo <= c <= hi

I wonder if you would be able to figure out how to solve my problem
Thanks

@azend
Copy link

azend commented Jan 12, 2023

I also need a feature to be able to exclude certain files/directories from a repo that causes errors and no resulting yaml output. Since there's no way to exclude specific paths, filter must be used to include everything but my particular exclusions. However, because the repository is of unknown depth and Go does not support **, this is not possible.

@azend
Copy link

azend commented Jan 13, 2023

I've solved this temporarily by running this tool within a shell script that sets a consistent root path then iterates through all of the non-excluded directories with a --filter for just that directory. Not ideal but it seems to work. When doing this, remember to --preserve-projects and --preserve-workflows as needed or multiple executions will overwrite previous ones.

@rjsigma
Copy link
Author

rjsigma commented Feb 29, 2024

As mentioned by someone above, go glob is not good at excluding pattern.

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

4 participants