DL3007: Do not error out when latest tag is used alongside a sha256 #739
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 can
2C69
not 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.
Hello there! 👋
Thank you for creating and maintaining hadolint! I stumbled upon it about a month ago and it really helped me preventing some footguns. I love the fact this linter can save some of my time 👍
What I did
I found an edge case. Docker allows both tags and SHA to be defined in the same base image definition. When this case happens, Docker ignores the tag and just pulls the image associated to its SHA.
Although, Docker ignores the tag, I find the case for having both compelling for humans: it's easier to represent what the image behind a SHA is, if the tag is next to it.
I used this pattern and usually, hadolint is happy with it. Today, one of the tags was explicitly set to
latest
andhadolint
bailed out. Here's a patch that changes the behavior to make it consistent no matter what the tag is.How I did it
TDD 🙂 I first added the unit test, which failed as expected. Then, I added the new check and ran the unit tests. Let me know what you think!
By the way, that's my first patch in haskell. I mainly copy-pasted some the lines around. I would be happy to make any requested change 🙂
How to verify it
stack test