Skip to content

DL3007: Do not error out when latest tag is used alongside a sha256#739

Merged
lorenzo merged 1 commit intohadolint:masterfrom
JohanLorenzo:DL3007-latest-with-sha
Nov 29, 2021
Merged

DL3007: Do not error out when latest tag is used alongside a sha256#739
lorenzo merged 1 commit intohadolint:masterfrom
JohanLorenzo:DL3007-latest-with-sha

Conversation

@JohanLorenzo
Copy link
Copy Markdown
Contributor

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 and hadolint 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

@lorenzo
Copy link
Copy Markdown
Member

lorenzo commented Nov 29, 2021

Thanks, it looks perfect!

@lorenzo lorenzo merged commit 43d2bfe into hadolint:master Nov 29, 2021
@JohanLorenzo JohanLorenzo deleted the DL3007-latest-with-sha branch November 29, 2021 10:01
JohanLorenzo added a commit to jobgraph-dev/jobgraph that referenced this pull request Dec 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants