-
Notifications
You must be signed in to change notification settings - Fork 280
feat: add exclude files when using the git file generator (#468) #514
base: master
Are you sure you want to change the base?
Conversation
dcfbe54
to
336f602
Compare
336f602
to
662fff4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! Just one comment for now. Also, could you update the git generator docs page to show how to use the new feature?
662fff4
to
7a0e793
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! My only remaining concern is that a/**/b.json
might be a valid path in path.Match
, and we might be changing the behavior for any users who have that kind of pattern. I don't have time to investigate at the moment.
Are you strongly opposed to just introducing a new glob
field for both files and directories? I feel like that's safer and easier for users to understand.
I think the only potential issues would occur if there were users that had |
2c4fc4a
to
3d484be
Compare
@crenshaw-dev, I misunderstood what you meant about adding a new glob field. I think that would be more confusing. The only time glob will need to be used is when there is a |
3d484be
to
2db748f
Compare
@adamjohnson01 thanks for the explanation! I don't think I'll be able to give this the review it deserves until Monday. Thanks for your patience! |
After thinking some more, I'm still not comfortable inferring pattern type.
|
@crenshaw-dev, those are valid points. How about using the doublestar library instead of glob. It implements support for double star |
I do like doublestar a lot more! Looks better-maintained. But I don't think it resolves the first three points. I've been using these tests to compare behavior: func TestGlobVsMatch(t *testing.T) {
cases := []struct {
name string
testPath string
pattern string
expected bool
}{
{
name: "double-star does not match separator",
testPath: "/a/b/c",
pattern: "/a/**",
expected: true,
},
{
name: "{ is a valid part of a path",
testPath: "/a/{filename}",
pattern: "/a/{filename}",
expected: true,
},
}
for _, testCase := range cases {
testCaseCopy := testCase
t.Run(testCaseCopy.name, func(t *testing.T) {
t.Parallel()
pathMatches, err := path.Match(testCaseCopy.pattern, testCaseCopy.testPath)
assert.NoError(t, err)
assert.Equal(t, testCaseCopy.expected, pathMatches, "path.Match returned %v instead of %v for pattern %v and path %v", pathMatches, testCaseCopy.expected, testCaseCopy.pattern, testCaseCopy.testPath)
doublestarMatches, err := doublestar.Match(testCaseCopy.pattern, testCaseCopy.testPath)
assert.NoError(t, err)
assert.Equal(t, testCaseCopy.expected, doublestarMatches, "doublestar.Match returned %v instead of %v for pattern %v and path %v", doublestarMatches, testCaseCopy.expected, testCaseCopy.pattern, testCaseCopy.testPath)
})
}
} |
I think that 1 is the only point that it does not solve but this is limited to excludes and not the path generation as that is handled by |
Can you clarify what you mean here? I'm sure I'm missing something obvious. But as far as I can tell, file listing is currently performed by cloning the repo and using So the behavior of this generator would change after merging this PR: - git:
repoURL: https://github.com/argoproj/applicationset.git
revision: HEAD
files:
- path: "examples/git-generator-files-discovery/cluster-config/**/config.json" Instead of matching only files one directory away from |
You are not missing anything. I am only half correct.
This would not change as I think that it is probably best if we implement two different filtering functions. One for directories and one for files. That way we can leave the current directory filtering which works the same way as directory generation alone. That way we will not break any existing config. The new exclude config for files should work the same way that the generation for files works so we will need to implement What do you think? |
Ah! Thanks for the clarification. Had to look at the code for a few minutes to understand what's happening. Yep, your idea of two different filter functions makes a lot of sense. |
2db748f
to
81b26e4
Compare
…tor (argoproj#468) Signed-off-by: Adam Johnson <[email protected]>
81b26e4
to
f7212fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for walking me through understanding the implementation. Took me a while to understand fully. 😄
- path: "examples/git-generator-files-discovery/cluster-config/**/config.json" | ||
exclude: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct? Looks like it would exclude everything.
@adamjohnson01 : Can u please move this PR into argocd as applicationset is moved. If u find it laborious, i can do it on your behalf with your consent |
@rishabh625, I will give it a go |
@adamjohnson01 let us know if you'd rather us move over the PR on your behalf. :-) |
any progress on this PR? |
@yebolenko it's already merged and will be available in next release argoproj/argo-cd#9150 |
AFAICS this merge is related to excluding entire repositories using the SCM generator, how would I use this to exclude only a single file using the Git file generator when generating all Applications from a single Git repository? |
I have not had time to work on this but will try and get it moved across. |
Has there been any progress on this? I would like to ignore certain directory patterns but keep the rest, which is impossible using only glob patterns for inclusion as it is now. |
Hi folks, Do we have some update about this? I would like to use exclude files when using git file generator. |
I have not seen this feature attempted on the new repo |
This adds the ability to exclude specific paths when using the git file generator.
Closes #468