linter: add rule to catch multiple conflicting instructions used in the same stage#4913
Merged
tonistiigi merged 1 commit intoMay 13, 2024
Conversation
fecc7ad to
7dbab0c
Compare
3dd18c6 to
7dbab0c
Compare
tonistiigi
reviewed
May 13, 2024
| // workdirSet is set to true if a workdir has been set | ||
| // within the current dockerfile. | ||
| workdirSet bool | ||
|
|
Member
There was a problem hiding this comment.
possible follow-up: workdirSet to healthcheck seem like fields with similar usage. I think they could be all combined into one struct that is included here.
| IsSet bool | ||
| } | ||
|
|
||
| func (v *parserLocation) Set(loc []parser.Range) { |
Member
There was a problem hiding this comment.
Maybe something like * instructionTracker) MarkUsed(loc []parser.Range) ?
Collaborator
Author
There was a problem hiding this comment.
Seems like a better name to me. Done.
…he same stage This linter rule catches when ENTRYPOINT, CMD, and HEALTHCHECK are used multiple times in the same stage. This is because the last usage of each of these overrides the other usages which makes it so the earlier usage is ignored and unnecessary. Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
7dbab0c to
89ce746
Compare
tonistiigi
approved these changes
May 13, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This linter rule catches when ENTRYPOINT, CMD, and HEALTHCHECK are used
multiple times in the same stage. This is because the last usage of each
of these overrides the other usages which makes it so the earlier usage
is ignored and unnecessary.