argoproj / applicationset

The ApplicationSet controller manages multiple Argo CD Applications as a single ApplicationSet unit, supporting deployments to large numbers of clusters, deployments of large monorepos, and enabling secure Application self-service.
https://argocd-applicationset.readthedocs.io/
Apache License 2.0
586 stars 279 forks source link

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

Open adamjohnson01 opened 2 years ago

adamjohnson01 commented 2 years ago

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.

crenshaw-dev commented 2 years ago

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

adamjohnson01 commented 2 years ago

@crenshaw-dev yes I am happy to contribute.

templarfelix commented 2 years ago

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

adamjohnson01 commented 2 years ago

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

ErikLundJensen commented 2 years ago

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

adamjohnson01 commented 2 years ago

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
DjoleLepi commented 1 year ago

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

crenshaw-dev commented 1 year ago

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

abelnieva commented 1 year ago

HI that would great to have this feature