fix: first and last image won't be detected as known image, do not add single quote to the jsonpath (#9448) #9449
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #9448
Related: None
Merge before/after: None
Description
It's not necessary to add single quote to the ojsonpath parameter since Go exec Cmd won't run it in a shell and does not expand any patterns as described in the documentation: https://pkg.go.dev/os/exec#pkg-overview
With the single quote added (the original implementation) JSON path algorithm will add the single quote to string so that the result of the findKnownImages will start and end with a single quote and the list will be something like this (please note the first and last character which is a single quote):
Instead of
If the string of an image tag contains single quote then the
stringslice.Contains(knownImages, normalizedImageRef.String())
won't match it in theloadImages
so we will load it again which is not necessary.User facing changes
This will fix the problem described in #9448 and the startup time will be significantly faster in case of one of the images is the first or the last one in the list.