-
Notifications
You must be signed in to change notification settings - Fork 169
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
tk tool importers
: Handle deleted files
#872
tk tool importers
: Handle deleted files
#872
Conversation
|
8c33773
to
20bac77
Compare
One of the issues we are facing with this command is whenever someone deletes a file and it's still being used somewhere: - We can't pass this file to the `importers` command because it will fail trying to find symlinks - Jsonnet main files which are using this file will not be found - We end up with erroring projects that are only found out the next time they are evaluated This PR adds support for deleted files via a `deleted:` prefix that can be added to files that were deleted. In that case, a simple filepath.Abs logic is used instead of trying to find symlinks and the same import resolution process happens as with existing files Ex: ```console tk tool importers deleted:lib/external-secrets/main.libsonnet ```
20bac77
to
dcf9018
Compare
@@ -154,6 +208,11 @@ func TestFindImportersForFiles(t *testing.T) { | |||
require.NoError(t, err) | |||
require.NotEmpty(t, files) | |||
for _, file := range files { | |||
// This project is known to be invalid (as the name suggests) | |||
if strings.Contains(file, "using-deleted-stuff") { |
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.
Should this be part of findImportersTestCase
? That way you can have next to the test information if you should skip here or rather, expect an error or not.
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.
hmm, I don't think so. It's a sanity check. The command to find importers does not eval jsonnet (because that would be too expensive), and for that that reason, it does not necessarily throw errors on invalid jsonnet (it's not its purpose). So this eval is there to check that the test cases are actually valid
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.
👍
One of the issues we are facing with this command is whenever someone deletes a file and it's still being used somewhere:
importers
command because it will fail trying to find symlinksThis PR adds support for deleted files via a
deleted:
prefix that can be added to files that were deleted. In that case, a simple filepath.Abs logic is used instead of trying to find symlinks and the same import resolution process happens as with existing filesEx:
tk tool importers deleted:lib/external-secrets/main.libsonnet