applicationset icon indicating copy to clipboard operation
applicationset copied to clipboard

Add the ability to exclude files when using the git file generator

Open adamjohnson01 opened this issue 2 years ago • 9 comments

When using the git directory generator it is possible to exclude specific paths like this

  - git:
      repoURL: https://github.com/argoproj-labs/applicationset.git
      revision: HEAD
      directories:
      - path: examples/git-generator-directory/excludes/cluster-addons/*
      - path: examples/git-generator-directory/excludes/cluster-addons/exclude-helm-guestbook
        exclude: true

When using the git file generator I would like to be able to add files using a wildcard and then exclude specific files like this

spec:
  generators:
  - git:
      repoURL: https://github.com/argoproj-labs/applicationset.git
      revision: HEAD
      files:
      - path: "examples/git-generator-files-discovery/cluster-config/**/config.json"
      - path  "examples/git-generator-files-discovery/cluster-config/staging/config.json"
        exclude: true

Of course if there is another way to do this that I am not aware of then I would be happy to use that. If not I am also happy to implement this change if it is agreed.

adamjohnson01 avatar Jan 19 '22 16:01 adamjohnson01

@adamjohnson01 I'm not aware of a workaround. Would you be willing to contribute the feature?

crenshaw-dev avatar Feb 16 '22 19:02 crenshaw-dev

@crenshaw-dev yes I am happy to contribute.

adamjohnson01 avatar Feb 16 '22 21:02 adamjohnson01

i need same feature, @adamjohnson01 you make this chances? if not call for me i write this.

templarfelix avatar Feb 17 '22 18:02 templarfelix

@templarfelix, I have this working. Will create a PR soon.

adamjohnson01 avatar Feb 20 '22 14:02 adamjohnson01

Will this feature also support exclude directories like /foo/** or /foo in the git files generator?

ErikLundJensen avatar Mar 02 '22 15:03 ErikLundJensen

Will this feature also support exclude directories like /foo/** or /foo in the git files generator?

Neither /foo/* or /foo would not work as the file list does not contain a full path. It is the output of git ls-files

foo/** would work but foo would not as the entire path needs to match. There needs to be either a ** or any pattern that is accepted by path.Match

pattern:
	{ term }
term:
	'*'         matches any sequence of non-/ characters
	'?'         matches any single non-/ 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

adamjohnson01 avatar Mar 03 '22 21:03 adamjohnson01

Any updates on this? For me this would simplify the definition of ApplicationSets a lot

DjoleLepi avatar Nov 29 '22 15:11 DjoleLepi

@DjoleLepi I'm not sure if this PR was ever moved over to argoproj/argo-cd after applicationset was integrated with that repo.

crenshaw-dev avatar Nov 29 '22 15:11 crenshaw-dev

HI that would great to have this feature

abelnieva avatar Oct 06 '23 16:10 abelnieva