-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
LegacyKeyValueFormat
linter is noisy with very little practical value
#5130
Comments
The syntax is deprecated and discouraged (since 2020). We should either remove the deprecation or we should warn. I don't see any point of deprecating but then still saying "it is fine, keep using it". If there are many Dockerfiles that use the deprecated syntax 4 years later, that is a sign that nobody follows the deprecation documentation, and if we want to change user's behavior, we need to tell them that they are using a deprecated command. Personally, I tend to agree with the justification for deprecation. In addition to ambiguous cases:
It is only shown until you fix it one time. There is a |
Yes, I agree with your first point -- I argued against the deprecation back in 2020, and still do think we should reverse course on it because I still think it's a net negative. "It's more consistent with The way I see the "multiple ways to do the same thing" argument is no different than shell vs JSON syntax. It's a little hiccup for new users, but experienced users learn quickly. I do think there is value in having a warning for cases like |
But we did add a check for that as well. While non-JSON is allowed from CMD/ENTRYPOINT we now warn against it and ask user to only use JSON. |
And |
I recommend that you change this lint's word order. First specifying the problem and then presenting the solution. I have mentioned it in another issue moby/moby#48327 (comment) |
Copying from the other ticket (which was discussing format of the error-message); Using active voice would probably be good ("use X" instead of "X should be used"). Perhaps more along the lines how we format LegacyKeyValueFormat: The "ENV key value" format is deprecated. Use "ENV key value" format instead. Not sure where to fit in the LegacyKeyValueFormat: The "ENV key value" format is deprecated. Use "ENV key value" format instead. (line 15) I'm used to linters pointing out the issue inline, but not sure if possible, and not sure if that could make the output more noisy / harder to read if it's in more complex parts of a Dockerfile; Dockerfile:15: The "ENV key value" format is deprecated. Use "ENV key value" format instead (LegacyKeyValueFormat).
ENV NODE_ENV production
^ I guess that's the intent of the current output, which may work well for a single error, but with the "lines before / after" becomes quite verbose, and also puts a lot of separation between the error and the line containing the error / issue. |
Yes, that's a bug; it's tracked in #5240, and I saw a patch is being worked on (but not yet complete) |
I don't think this is the appropriate place to discuss rewording the linter notice -- I'm calling for removal or disabling-by-default of it, and don't think rewording it is sufficient. |
Parser ambiguity is never a good thing. The latest The Docker logs and documentation do a terrible job of explaining the reason for the deprecation. The historical parser ambiguity context is essential, but it is hidden in the GitHub issues. |
Would we typically link to this kind of information in the docs @dvdksn? |
Something like https://staticcheck.dev/docs/checks or https://securego.io/docs/rules/g103 could be nice it gives a page with context about each rule (not sure how "SEO friendly" the current Dockerfile rules are to find them through Google). |
https://docs.docker.com/reference/build-checks/ are docs for each rule. |
The check doc is the top result via google atm 🥇 I was mostly curious if the GitHub issue context was worth adding to the check's page for historical purposes. |
I'm not gonna send readers to GitHub issues where people argue about the pros and cons of this syntax. It's deprecated, don't use it. |
I don't care one whit about SEO. I'm asking for the CLI to explain why it bothers to drop support for the old syntax. No reason is given for a seemingly arbitrary warning. A link from stderr to the relevant documentation page would be sufficient to clear up the confusion. |
Links to the warning documentation are added when using Thanks for the feedback @mcandre -- I'll create a separate issue for any changes related to the output changes and link it here so this issue stays focused on its original purpose. |
The so-called "legacy" syntax is only legacy because when |
As a user trying to decide if I should actually go through the churn to update to the new syntax, could a final decision on this issue be made? I am hesitant to update everything if then the decision is that the old syntax is fine and the deprecation is removed. |
The old syntax exhibits parse ambiguity problems. I'd like to docs to emphasize the newer syntax, and note that the former syntax is deprecated. Hopefully the various third party Docker linters include similar reports of the syntax deprecation. Would like the warning transition to an error in a few years, once the community has had time to react to the change. |
At the risk of being a broken record, I still firmly believe it is a mistake to even attempt to deprecate the
ENV key value
syntax in favor of only supportingENV key=value
. Parsing the former is much simpler, and more in line with the way otherDockerfile
instructions are parsed (and have been parsed historically). It is also much easier to generate from other code correctly and safely. As I noted on that other issue, if there are cases where the behavior of the former is ambiguous, that should be the thing we detect and warn about, not just trying to deprecate the entire syntax.For the current linting rule, I would propose that it either be removed or somehow disabled by default, as it is causing unnecessary and noisy churn across the industry with very little practical benefit. 🙇 ❤️
Examples of unnecessary churn/noise:
=
instead of whitespace as the key value separator nginxinc/docker-nginx#906LegacyKeyValueFormat
warnings docker-library/ruby#465ENV key value
format docker/docker-ce-packaging#1047The text was updated successfully, but these errors were encountered: