Skip to content

Commit

Permalink
Add note in generated docs indicating experimental rule checks
Browse files Browse the repository at this point in the history
Signed-off-by: Talon Bowler <[email protected]>
  • Loading branch information
daghack committed Aug 12, 2024
1 parent 8a7ba6e commit a62980e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion frontend/dockerfile/docs/rules/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ $ docker build --check .
<td>FROM --platform flag should not use a constant value</td>
</tr>
<tr>
<td><a href="./copy-ignored-file/">CopyIgnoredFile</a></td>
<td><a href="./copy-ignored-file/">CopyIgnoredFile (experimental)</a></td>
<td>Attempting to Copy file that is excluded by .dockerignore</td>
</tr>
</tbody>
Expand Down
5 changes: 5 additions & 0 deletions frontend/dockerfile/docs/rules/copy-ignored-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ aliases:
- /go/dockerfile/rule/copy-ignored-file/
---

> **Note**
>
> This check is experimental and is not enabled by default. To enable it, see
> [Experimental checks](https://docs.docker.com/go/build-checks-experimental/).
## Output

```text
Expand Down
2 changes: 1 addition & 1 deletion frontend/dockerfile/linter/docs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ $ docker build --check .
<tbody>
{{- range .Rules }}
<tr>
<td><a href="./{{ .PageName }}/">{{ .Name }}</a></td>
<td><a href="./{{ .PageName }}/">{{ .Name }}{{- if .Experimental }} (experimental){{- end}}</a></td>
<td>{{ .Description }}</td>
</tr>
{{- end }}
Expand Down
22 changes: 17 additions & 5 deletions frontend/dockerfile/linter/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import (
)

type Rule struct {
Name string
Description string
URL *url.URL
PageName string
URLAlias string
Name string
Description string
URL *url.URL
PageName string
URLAlias string
Experimental bool
}

const tmplStr = `---
Expand All @@ -35,6 +36,13 @@ aliases:
- {{ .Rule.URLAlias }}
{{- end }}
---
{{- if .Rule.Experimental }}
> **Note**
>
> This check is experimental and is not enabled by default. To enable it, see
> [Experimental checks](https://docs.docker.com/go/build-checks-experimental/).
{{- end }}
{{ .Content }}
`
Expand Down Expand Up @@ -160,6 +168,10 @@ func listRules() ([]Rule, error) {
}
rule.URL = u
}
case "Experimental":
if basicLit, ok := kv.Value.(*ast.Ident); ok {
rule.Experimental = basicLit.Name == "true"
}
}
}
}
Expand Down

0 comments on commit a62980e

Please sign in to comment.