-
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
dockerfile: generate lint rules documentation #4990
Conversation
if errors.Is(err, os.ErrNotExist) { | ||
log.Printf("WARNING: Markdown file %q not found for %s\n", mdfilename, rule.Name) | ||
return false, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It needs a markdown file that contains examples for the rule. Atm we skip docs generation if the markdown file is not found but I think it should be required and fails if not found (cc @dvdksn)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to make validation fails if markdown files are missing.
fe33f6a
to
bab6f7b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just have a markdown file for this rule atm but we should have one for each of them.
@dvdksn Feel free to push to my branch other ones.
bab6f7b
to
4dc9006
Compare
description: {{.Rule.Description}} | ||
--- | ||
|
||
{{.Content}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here's a far out ask. Is there any way we can generate the sample error using the Format
field? https://github.com/moby/buildkit/blob/master/frontend/dockerfile/linter/linter.go#L79
Just thinking if there's a way to make sure the sample error in the doc and the actual error look the same. If generating the sample error isn't easily doable, maybe we could update the tests to check that generated errors have the same format as what's in the doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could but where to put Format
in the template and what layout would this have?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we could put the templating logic in the Markdown files directly. For example, consider frontend/dockerfile/linter/docs/RuleName.md
---
title: {{ .Name }}
description: {{ .Description }}
---
Example warning:
{{ .Format "foo" "bar" }}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes sounds good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is outdated, I created it a while ago. Would be nice to generate it too (I think we need an index for all of these rules)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added commit to generate _index.md
as well: https://github.com/crazy-max/buildkit/blob/docs-dockerfile-gen/frontend/dockerfile/docs/rules/_index.md
Picked changes from @dvdksn branch to include additional markdown files: crazy-max#18 |
dd2e9f4
to
5b63ac6
Compare
50dd7e9
to
d8bfaf4
Compare
This comment was marked as resolved.
This comment was marked as resolved.
d844815
to
f6c970b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing content
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed it's fine to merge even if content is empty. We can update it later. We just want URL to be set.
f6c970b
to
53e3858
Compare
8f0c7c5
to
989c53e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@colinhemmings PTAL on rule's description related to #4980 (comment)
This comment was marked as resolved.
This comment was marked as resolved.
989c53e
to
3bd7bc4
Compare
cc631ae
to
7c85e86
Compare
URL: "https://docs.docker.com/go/dockerfile/rule/reserved-stage-name/", | ||
Format: func(reservedStageName string) string { | ||
return fmt.Sprintf("Stage name should not use the same name as reserved stage %q", reservedStageName) | ||
}, | ||
} | ||
RuleJSONArgsRecommended = LinterRule[func(instructionName string) string]{ | ||
Name: "JSONArgsRecommended", | ||
Description: "JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals", | ||
Description: "JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals, unless using a custom shell", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "unless using a custom shell" is not needed here. If the user knows what "custom shell" is then they will not see this warning. Otherwise it will just confuse them.
Explaining the "custom shell" behavior in the linked URL is good.
Dockerfile
Outdated
@@ -378,7 +378,7 @@ exec dlv exec /usr/bin/buildkitd \\ | |||
--continue \\ | |||
-- "\$@" | |||
EOF | |||
ENV DELVE_PORT 5000 | |||
ENV DELVE_PORT=5000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: these changes could be in another PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 -- sorry about that, those were driving me nuts
053d42c
to
3b4139b
Compare
@@ -0,0 +1,26 @@ | |||
--- | |||
title: UndefinedArgInFrom |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are for follow-up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to align generated docs: https://github.com/moby/buildkit/actions/runs/9408268148/job/25915879498?pr=4990#step:5:319
#20 [validate 1/1] RUN --mount=target=/context --mount=target=.,type=tmpfs <<EOT (set -e...)
#20 0.814 ERROR: Dockerfile docs result differs. Please update with "make docs-dockerfile"
#20 0.842 M frontend/dockerfile/docs/rules/_index.md
3b4139b
to
25dbfdc
Compare
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
Signed-off-by: Shaun Thompson <shaun.thompson@docker.com>
25dbfdc
to
37fc95a
Compare
relates to #4823 and #4980
Generates lint rules documentation in
./frontend/dockerfile/docs/rules
that can then be used on https://github.com/docker/docs through vendoring with Hugo.Keep in draft as some markdown files are incomplete.