-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Improve skaffold init file traversal #3062
Improve skaffold init file traversal #3062
Conversation
Codecov Report
|
@tejal29 I broke the long function down, LMK if it's an improvement. |
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.
The overall logic part looks sound to me. Some minor naming suggestions.
@tejal29 @nkubala Would you mind giving another review? @chanseokoh's approval isn't enough since this is outside of Jib files. |
Fixes #3060.
Description
Currently,
skaffold init
ends directory traversal early when a Jib config is detected, so as to not accidentally traverse sub-modules, detect more Jib configurations, and end up with a list of redundant builders. However, the directory traversal had issues that could cause other important files to be missed, such as k8s configs, existing skaffold.yamls, or other build files in the Jib config directory (see before/after descriptions below). This PR changesskaffold init
to fully walk the project directory, using a flag to ignore builders in nested directories instead of ignoring the directories altogether. This lets us find k8s manifests/skaffold.yamls regardless of where they are relative to Jib build files, while letting us ignore redundant builder configs.User facing changes
skaffold init
will now detect important files more consistently.Before
Given the example project directory below:
skaffold init
would traverse the directory in alphabetical order, finding the dockerfile first, then finding Jib configured in thebuild.gradle
first, causing it to stop and return to the parent directory. This causes it to miss another potential Jib config in the same directory (pom.xml
), the kubernetes manifests, and the existingskaffold.yaml
.After
Now,
skaffold init
traverses all the files in a directory first before traversing sub-directories (solving the problem of missed builders/skaffold.yaml
). If a Jib config is found, then it will not continue to search for builders in the sub-directories; however it will continue to traverse deeper to find k8s manifests (e.g. inkubernetes-manifests/
).Submitter Checklist
Reviewer Notes
Release Notes
Fix
skaffold init
ending file traversal early when Jib config is detected.