Skip to content

Commit 37fc95a

Browse files
thompson-shauntonistiigi
authored andcommitted
lint: update descriptions, test and re-generate docs
Signed-off-by: Shaun Thompson <[email protected]>
1 parent 138ee4c commit 37fc95a

13 files changed

+53
-48
lines changed

frontend/dockerfile/dockerfile2llb/convert.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2164,8 +2164,8 @@ func validateCommandCasing(dockerfile *parser.Result, lint *linter.Linter) {
21642164
// as well as ensuring that the casing is consistent throughout the dockerfile by comparing the
21652165
// command to the casing of the majority of commands.
21662166
if !isSelfConsistentCasing(node.Value) {
2167-
msg := linter.RuleSelfConsistentCommandCasing.Format(node.Value)
2168-
lint.Run(&linter.RuleSelfConsistentCommandCasing, node.Location(), msg)
2167+
msg := linter.RuleConsistentInstructionCasing.Format(node.Value)
2168+
lint.Run(&linter.RuleConsistentInstructionCasing, node.Location(), msg)
21692169
} else {
21702170
var msg string
21712171
var needsLintWarn bool
@@ -2284,8 +2284,8 @@ func toPBLocation(sourceIndex int, location []parser.Range) pb.Location {
22842284
func reportUnusedFromArgs(values []string, unmatched map[string]struct{}, location []parser.Range, lint *linter.Linter) {
22852285
for arg := range unmatched {
22862286
suggest, _ := suggest.Search(arg, values, true)
2287-
msg := linter.RuleUndeclaredArgInFrom.Format(arg, suggest)
2288-
lint.Run(&linter.RuleUndeclaredArgInFrom, location, msg)
2287+
msg := linter.RuleUndefinedArgInFrom.Format(arg, suggest)
2288+
lint.Run(&linter.RuleUndefinedArgInFrom, location, msg)
22892289
}
22902290
}
22912291

frontend/dockerfile/dockerfile_lint_test.go

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var lintTests = integration.TestFuncs(
2626
testRuleCheckOption,
2727
testStageName,
2828
testNoEmptyContinuations,
29-
testSelfConsistentCommandCasing,
29+
testConsistentInstructionCasing,
3030
testFileConsistentCommandCasing,
3131
testDuplicateStageName,
3232
testReservedStageName,
@@ -56,6 +56,7 @@ COPY $bar .
5656
{
5757
RuleName: "UndefinedVar",
5858
Description: "Variables should be defined before their use",
59+
URL: "https://docs.docker.com/go/dockerfile/rule/undefined-var/",
5960
Detail: "Usage of undefined variable '$bar'",
6061
Level: 1,
6162
Line: 6,
@@ -65,13 +66,15 @@ COPY $bar .
6566
{
6667
RuleName: "UndefinedVar",
6768
Description: "Variables should be defined before their use",
69+
URL: "https://docs.docker.com/go/dockerfile/rule/undefined-var/",
6870
Detail: "Usage of undefined variable '$foo'",
6971
Level: 1,
7072
Line: 3,
7173
},
7274
{
7375
RuleName: "UndefinedVar",
7476
Description: "Variables should be defined before their use",
77+
URL: "https://docs.docker.com/go/dockerfile/rule/undefined-var/",
7578
Detail: "Usage of undefined variable '$bar'",
7679
Level: 1,
7780
Line: 6,
@@ -260,7 +263,7 @@ COPY Dockerfile \
260263
})
261264
}
262265

263-
func testSelfConsistentCommandCasing(t *testing.T, sb integration.Sandbox) {
266+
func testConsistentInstructionCasing(t *testing.T, sb integration.Sandbox) {
264267
dockerfile := []byte(`
265268
# warning: 'FROM' should be either lowercased or uppercased
266269
From scratch as base
@@ -270,9 +273,9 @@ FROM scratch AS base2
270273
Dockerfile: dockerfile,
271274
Warnings: []expectedLintWarning{
272275
{
273-
RuleName: "SelfConsistentCommandCasing",
274-
Description: "Commands should be in consistent casing (all lower or all upper)",
275-
URL: "https://docs.docker.com/go/dockerfile/rule/self-consistent-command-casing/",
276+
RuleName: "ConsistentInstructionCasing",
277+
Description: "Instructions should be in consistent casing (all lower or all upper)",
278+
URL: "https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/",
276279
Detail: "Command 'From' should be consistently cased",
277280
Level: 1,
278281
Line: 3,
@@ -289,9 +292,9 @@ from scratch as base2
289292
Dockerfile: dockerfile,
290293
Warnings: []expectedLintWarning{
291294
{
292-
RuleName: "SelfConsistentCommandCasing",
293-
Description: "Commands should be in consistent casing (all lower or all upper)",
294-
URL: "https://docs.docker.com/go/dockerfile/rule/self-consistent-command-casing/",
295+
RuleName: "ConsistentInstructionCasing",
296+
Description: "Instructions should be in consistent casing (all lower or all upper)",
297+
URL: "https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/",
295298
Detail: "Command 'frOM' should be consistently cased",
296299
Line: 3,
297300
Level: 1,
@@ -435,15 +438,15 @@ FROM scratch AS context
435438
Warnings: []expectedLintWarning{
436439
{
437440
RuleName: "ReservedStageName",
438-
Description: "Reserved stage names should not be used to name a stage",
441+
Description: "Reserved words should not be used as stage names",
439442
URL: "https://docs.docker.com/go/dockerfile/rule/reserved-stage-name/",
440443
Detail: "Stage name should not use the same name as reserved stage \"scratch\"",
441444
Level: 1,
442445
Line: 2,
443446
},
444447
{
445448
RuleName: "ReservedStageName",
446-
Description: "Reserved stage names should not be used to name a stage",
449+
Description: "Reserved words should not be used as stage names",
447450
URL: "https://docs.docker.com/go/dockerfile/rule/reserved-stage-name/",
448451
Detail: "Stage name should not use the same name as reserved stage \"context\"",
449452
Level: 1,
@@ -541,7 +544,7 @@ MAINTAINER [email protected]
541544
Warnings: []expectedLintWarning{
542545
{
543546
RuleName: "MaintainerDeprecated",
544-
Description: "The maintainer instruction is deprecated, use a label instead to define an image author",
547+
Description: "The MAINTAINER instruction is deprecated, use a label instead to define an image author",
545548
URL: "https://docs.docker.com/go/dockerfile/rule/maintainer-deprecated/",
546549
Detail: "Maintainer instruction is deprecated in favor of using label",
547550
Level: 1,
@@ -575,9 +578,9 @@ FROM ${BAR} AS base
575578
Level: 1,
576579
},
577580
{
578-
RuleName: "UndeclaredArgInFrom",
581+
RuleName: "UndefinedArgInFrom",
579582
Description: "FROM command must use declared ARGs",
580-
URL: "https://docs.docker.com/go/dockerfile/rule/undeclared-arg-in-from/",
583+
URL: "https://docs.docker.com/go/dockerfile/rule/undefined-arg-in-from/",
581584
Detail: "FROM argument 'BAR' is not declared",
582585
Level: 1,
583586
Line: 4,
@@ -618,9 +621,9 @@ COPY Dockerfile .
618621
Dockerfile: dockerfile,
619622
Warnings: []expectedLintWarning{
620623
{
621-
RuleName: "UndeclaredArgInFrom",
624+
RuleName: "UndefinedArgInFrom",
622625
Description: "FROM command must use declared ARGs",
623-
URL: "https://docs.docker.com/go/dockerfile/rule/undeclared-arg-in-from/",
626+
URL: "https://docs.docker.com/go/dockerfile/rule/undefined-arg-in-from/",
624627
Detail: "FROM argument 'BULIDPLATFORM' is not declared (did you mean BUILDPLATFORM?)",
625628
Level: 1,
626629
Line: 2,
@@ -641,9 +644,9 @@ COPY Dockerfile .
641644
Dockerfile: dockerfile,
642645
Warnings: []expectedLintWarning{
643646
{
644-
RuleName: "UndeclaredArgInFrom",
647+
RuleName: "UndefinedArgInFrom",
645648
Description: "FROM command must use declared ARGs",
646-
URL: "https://docs.docker.com/go/dockerfile/rule/undeclared-arg-in-from/",
649+
URL: "https://docs.docker.com/go/dockerfile/rule/undefined-arg-in-from/",
647650
Detail: "FROM argument 'MYARCH' is not declared (did you mean MY_ARCH?)",
648651
Level: 1,
649652
Line: 4,
@@ -663,9 +666,9 @@ COPY Dockerfile .
663666
Dockerfile: dockerfile,
664667
Warnings: []expectedLintWarning{
665668
{
666-
RuleName: "UndeclaredArgInFrom",
669+
RuleName: "UndefinedArgInFrom",
667670
Description: "FROM command must use declared ARGs",
668-
URL: "https://docs.docker.com/go/dockerfile/rule/undeclared-arg-in-from/",
671+
URL: "https://docs.docker.com/go/dockerfile/rule/undefined-arg-in-from/",
669672
Detail: "FROM argument 'version' is not declared",
670673
Level: 1,
671674
Line: 3,
@@ -905,13 +908,15 @@ FROM a AS c
905908
{
906909
RuleName: "LegacyKeyValueFormat",
907910
Description: "Legacy key/value format with whitespace separator should not be used",
911+
URL: "https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/",
908912
Detail: "\"ENV key=value\" should be used instead of legacy \"ENV key value\" format",
909913
Line: 3,
910914
Level: 1,
911915
},
912916
{
913917
RuleName: "LegacyKeyValueFormat",
914918
Description: "Legacy key/value format with whitespace separator should not be used",
919+
URL: "https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/",
915920
Detail: "\"LABEL key=value\" should be used instead of legacy \"LABEL key value\" format",
916921
Line: 4,
917922
Level: 1,

frontend/dockerfile/docs/rules/_index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ $ docker build --check .
4141
<td>Empty continuation lines will become errors in a future release</td>
4242
</tr>
4343
<tr>
44-
<td><a href="./self-consistent-command-casing.md">SelfConsistentCommandCasing</a></td>
45-
<td>Commands should be in consistent casing (all lower or all upper)</td>
44+
<td><a href="./consistent-instruction-casing.md">ConsistentInstructionCasing</a></td>
45+
<td>Instructions should be in consistent casing (all lower or all upper)</td>
4646
</tr>
4747
<tr>
4848
<td><a href="./file-consistent-command-casing.md">FileConsistentCommandCasing</a></td>
@@ -54,18 +54,18 @@ $ docker build --check .
5454
</tr>
5555
<tr>
5656
<td><a href="./reserved-stage-name.md">ReservedStageName</a></td>
57-
<td>Reserved stage names should not be used to name a stage</td>
57+
<td>Reserved words should not be used as stage names</td>
5858
</tr>
5959
<tr>
6060
<td><a href="./json-args-recommended.md">JSONArgsRecommended</a></td>
6161
<td>JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals</td>
6262
</tr>
6363
<tr>
6464
<td><a href="./maintainer-deprecated.md">MaintainerDeprecated</a></td>
65-
<td>The maintainer instruction is deprecated, use a label instead to define an image author</td>
65+
<td>The MAINTAINER instruction is deprecated, use a label instead to define an image author</td>
6666
</tr>
6767
<tr>
68-
<td><a href="./undeclared-arg-in-from.md">UndeclaredArgInFrom</a></td>
68+
<td><a href="./undefined-arg-in-from.md">UndefinedArgInFrom</a></td>
6969
<td>FROM command must use declared ARGs</td>
7070
</tr>
7171
<tr>

frontend/dockerfile/docs/rules/self-consistent-command-casing.md renamed to frontend/dockerfile/docs/rules/consistent-instruction-casing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: SelfConsistentCommandCasing
3-
description: Commands should be in consistent casing (all lower or all upper)
2+
title: ConsistentInstructionCasing
3+
description: Instructions should be in consistent casing (all lower or all upper)
44
aliases:
5-
- /go/dockerfile/rule/self-consistent-command-casing/
5+
- /go/dockerfile/rule/consistent-instruction-casing/
66
---
77

88
## Output

frontend/dockerfile/docs/rules/json-args-recommended.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ aliases:
88
## Output
99

1010
```text
11-
JSON arguments recommended for 'ENTRYPOINT' to prevent unintended behavior related to OS signals
11+
JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals
1212
```
1313

1414
## Description

frontend/dockerfile/docs/rules/maintainer-deprecated.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
title: MaintainerDeprecated
3-
description: The maintainer instruction is deprecated, use a label instead to define an image author
3+
description: The MAINTAINER instruction is deprecated, use a label instead to define an image author
44
aliases:
55
- /go/dockerfile/rule/maintainer-deprecated/
66
---
77

88
## Output
99

1010
```text
11-
Maintainer instruction is deprecated in favor of using label
11+
MAINTAINER instruction is deprecated in favor of using label
1212
```
1313

1414
## Description

frontend/dockerfile/docs/rules/reserved-stage-name.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: ReservedStageName
3-
description: Reserved stage names should not be used to name a stage
3+
description: Reserved words should not be used as stage names
44
aliases:
55
- /go/dockerfile/rule/reserved-stage-name/
66
---

frontend/dockerfile/docs/rules/undeclared-arg-in-from.md renamed to frontend/dockerfile/docs/rules/undefined-arg-in-from.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: UndeclaredArgInFrom
2+
title: UndefinedArgInFrom
33
description: FROM command must use declared ARGs
44
aliases:
5-
- /go/dockerfile/rule/undeclared-arg-in-from/
5+
- /go/dockerfile/rule/undefined-arg-in-from/
66
---
77

88
## Output
File renamed without changes.

frontend/dockerfile/linter/docs/JSONArgsRecommended.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Output
22

33
```text
4-
JSON arguments recommended for 'ENTRYPOINT' to prevent unintended behavior related to OS signals
4+
JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals
55
```
66

77
## Description

0 commit comments

Comments
 (0)