-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #1067 by filtering out chart dirs from manifest loading of changed files #1076
Conversation
…changed files.
Hi @ncabatoff , thanks for the PR ⭐ With respect to the approach: the There are a couple of ways this can be achieved, I think.
|
Fair points. I like this approach better too. |
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.
I like how you've done this ✔️
I left a couple of suggestions for you to consider; if you're are happy how it is, respond to those or leave a quick comment indicating so. Thanks!
cluster/kubernetes/resource/load.go
Outdated
|
||
func (c chartTracker) inChart(path string) bool { | ||
p := path | ||
root := fmt.Sprintf("%c", filepath.Separator) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
cluster/kubernetes/resource/load.go
Outdated
for _, root := range roots { | ||
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error { | ||
if err != nil { | ||
return errors.Wrapf(err, "walking %q for yamels", path) | ||
} | ||
|
||
if info.IsDir() && looksLikeChart(path) { | ||
if charts.isChart(path) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Thanks, I'm glad you're happy with the revised version. Re the ambiguous method names: agreed, I had that same thought when I was writing them and then forgot to fix before pushing. Re going up as far as the filesystem root, rather than just the chart root: I think for safety we need to check for when we reach the real filesystem root anyway. Consider what happens if the method is called with a path argument that doesn't match the root the chartTracker was constructed from; that would be a bug, I admit, but it would be a bad bug (infinite loop) if we don't have the loop terminate upon reaching the fs root. So given that we need that test anyway for safety, and we'd only be saving a few extra I/Os by also testing to see if we've reached the root the chartTracker was constructed from, and performance isn't critical here, I prefer the current simpler approach. |
I suppose I am a bit nervous about You are right that individual path arguments aren't necessarily in the root path. They should either be supplied as relative to the root, or it should be an error to supply a path that isn't contained. I was probably a bit confused about the requirements while I wrote this, leading to neither of these being enforced. It can be the subject of a later PR, anyway. |
Thanks @ncabatoff ⭐ |
I haven't written any tests yet because I first wanted to validate with the project maintainers whether this was the right approach. Another way of tackling this might be to filter out everything under the --git-charts-path option. Though in that case maybe we should also change the other manifest loading code path?