Skip to content

Commit

Permalink
lint: add alias to doc rule frontmatter
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Jun 6, 2024
1 parent fb6a825 commit 53e3858
Show file tree
Hide file tree
Showing 20 changed files with 127 additions and 11 deletions.
33 changes: 31 additions & 2 deletions frontend/dockerfile/dockerfile_lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ copy Dockerfile .
{
RuleName: "FromAsCasing",
Description: "The 'as' keyword should match the case of the 'from' keyword",
URL: "https://docs.docker.com/go/dockerfile/rule/from-as-casing/",
Detail: "'as' and 'FROM' keywords' casing do not match",
Line: 2,
Level: 1,
Expand All @@ -93,6 +94,7 @@ copy Dockerfile .
{
RuleName: "FromAsCasing",
Description: "The 'as' keyword should match the case of the 'from' keyword",
URL: "https://docs.docker.com/go/dockerfile/rule/from-as-casing/",
Detail: "'as' and 'FROM' keywords' casing do not match",
Line: 2,
Level: 1,
Expand All @@ -113,6 +115,7 @@ copy Dockerfile .
{
RuleName: "FromAsCasing",
Description: "The 'as' keyword should match the case of the 'from' keyword",
URL: "https://docs.docker.com/go/dockerfile/rule/from-as-casing/",
Detail: "'as' and 'FROM' keywords' casing do not match",
Line: 2,
Level: 1,
Expand Down Expand Up @@ -154,13 +157,15 @@ FROM scratch AS base3
{
RuleName: "StageNameCasing",
Description: "Stage names should be lowercase",
URL: "https://docs.docker.com/go/dockerfile/rule/stage-name-casing/",
Detail: "Stage name 'BadStageName' should be lowercase",
Line: 3,
Level: 1,
},
{
RuleName: "FromAsCasing",
Description: "The 'as' keyword should match the case of the 'from' keyword",
URL: "https://docs.docker.com/go/dockerfile/rule/from-as-casing/",
Detail: "'as' and 'FROM' keywords' casing do not match",
Line: 6,
Level: 1,
Expand All @@ -181,6 +186,7 @@ from scratch as base2
{
RuleName: "FromAsCasing",
Description: "The 'as' keyword should match the case of the 'from' keyword",
URL: "https://docs.docker.com/go/dockerfile/rule/from-as-casing/",
Detail: "'AS' and 'from' keywords' casing do not match",
Line: 3,
Level: 1,
Expand All @@ -206,10 +212,10 @@ COPY Dockerfile \
{
RuleName: "NoEmptyContinuations",
Description: "Empty continuation lines will become errors in a future release",
URL: "https://docs.docker.com/go/dockerfile/rule/no-empty-continuations/",
Detail: "Empty continuation line",
Level: 1,
Line: 6,
URL: "https://github.com/moby/moby/pull/33719",
},
},
})
Expand All @@ -227,6 +233,7 @@ FROM scratch AS base2
{
RuleName: "SelfConsistentCommandCasing",
Description: "Commands should be in consistent casing (all lower or all upper)",
URL: "https://docs.docker.com/go/dockerfile/rule/self-consistent-command-casing/",
Detail: "Command 'From' should be consistently cased",
Level: 1,
Line: 3,
Expand All @@ -245,6 +252,7 @@ from scratch as base2
{
RuleName: "SelfConsistentCommandCasing",
Description: "Commands should be in consistent casing (all lower or all upper)",
URL: "https://docs.docker.com/go/dockerfile/rule/self-consistent-command-casing/",
Detail: "Command 'frOM' should be consistently cased",
Line: 3,
Level: 1,
Expand All @@ -267,6 +275,7 @@ COPY Dockerfile /bar
{
RuleName: "FileConsistentCommandCasing",
Description: "All commands within the Dockerfile should use the same casing (either upper or lower)",
URL: "https://docs.docker.com/go/dockerfile/rule/file-consistent-command-casing/",
Detail: "Command 'copy' should match the case of the command majority (uppercase)",
Line: 4,
Level: 1,
Expand All @@ -286,6 +295,7 @@ copy Dockerfile /bar
{
RuleName: "FileConsistentCommandCasing",
Description: "All commands within the Dockerfile should use the same casing (either upper or lower)",
URL: "https://docs.docker.com/go/dockerfile/rule/file-consistent-command-casing/",
Detail: "Command 'COPY' should match the case of the command majority (lowercase)",
Line: 4,
Level: 1,
Expand All @@ -306,6 +316,7 @@ COPY Dockerfile /baz
{
RuleName: "FileConsistentCommandCasing",
Description: "All commands within the Dockerfile should use the same casing (either upper or lower)",
URL: "https://docs.docker.com/go/dockerfile/rule/file-consistent-command-casing/",
Detail: "Command 'from' should match the case of the command majority (uppercase)",
Line: 3,
Level: 1,
Expand All @@ -326,6 +337,7 @@ copy Dockerfile /baz
{
RuleName: "FileConsistentCommandCasing",
Description: "All commands within the Dockerfile should use the same casing (either upper or lower)",
URL: "https://docs.docker.com/go/dockerfile/rule/file-consistent-command-casing/",
Detail: "Command 'FROM' should match the case of the command majority (lowercase)",
Line: 3,
Level: 1,
Expand Down Expand Up @@ -359,6 +371,7 @@ FROM scratch AS b
{
RuleName: "DuplicateStageName",
Description: "Stage names should be unique",
URL: "https://docs.docker.com/go/dockerfile/rule/duplicate-stage-name/",
Detail: "Duplicate stage name \"b\", stage names should be unique",
Level: 1,
Line: 3,
Expand All @@ -384,13 +397,15 @@ FROM scratch AS context
{
RuleName: "ReservedStageName",
Description: "Reserved stage names should not be used to name a stage",
URL: "https://docs.docker.com/go/dockerfile/rule/reserved-stage-name/",
Detail: "Stage name should not use the same name as reserved stage \"scratch\"",
Level: 1,
Line: 2,
},
{
RuleName: "ReservedStageName",
Description: "Reserved stage names should not be used to name a stage",
URL: "https://docs.docker.com/go/dockerfile/rule/reserved-stage-name/",
Detail: "Stage name should not use the same name as reserved stage \"context\"",
Level: 1,
Line: 3,
Expand Down Expand Up @@ -418,6 +433,7 @@ CMD mycommand
{
RuleName: "JSONArgsRecommended",
Description: "JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals",
URL: "https://docs.docker.com/go/dockerfile/rule/json-args-recommended/",
Detail: "JSON arguments recommended for CMD to prevent unintended behavior related to OS signals",
Level: 1,
Line: 3,
Expand All @@ -434,6 +450,7 @@ ENTRYPOINT mycommand
Warnings: []expectedLintWarning{
{
RuleName: "JSONArgsRecommended",
URL: "https://docs.docker.com/go/dockerfile/rule/json-args-recommended/",
Description: "JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals",
Detail: "JSON arguments recommended for ENTRYPOINT to prevent unintended behavior related to OS signals",
Level: 1,
Expand Down Expand Up @@ -486,8 +503,8 @@ MAINTAINER me@example.org
{
RuleName: "MaintainerDeprecated",
Description: "The maintainer instruction is deprecated, use a label instead to define an image author",
URL: "https://docs.docker.com/go/dockerfile/rule/maintainer-deprecated/",
Detail: "Maintainer instruction is deprecated in favor of using label",
URL: "https://docs.docker.com/reference/dockerfile/#maintainer-deprecated",
Level: 1,
Line: 3,
},
Expand All @@ -513,13 +530,15 @@ FROM ${BAR} AS base
{
RuleName: "StageNameCasing",
Description: "Stage names should be lowercase",
URL: "https://docs.docker.com/go/dockerfile/rule/stage-name-casing/",
Detail: "Stage name 'BadStageName' should be lowercase",
Line: 3,
Level: 1,
},
{
RuleName: "UndeclaredArgInFrom",
Description: "FROM command must use declared ARGs",
URL: "https://docs.docker.com/go/dockerfile/rule/undeclared-arg-in-from/",
Detail: "FROM argument 'BAR' is not declared",
Level: 1,
Line: 4,
Expand Down Expand Up @@ -562,6 +581,7 @@ COPY Dockerfile .
{
RuleName: "UndeclaredArgInFrom",
Description: "FROM command must use declared ARGs",
URL: "https://docs.docker.com/go/dockerfile/rule/undeclared-arg-in-from/",
Detail: "FROM argument 'BULIDPLATFORM' is not declared (did you mean BUILDPLATFORM?)",
Level: 1,
Line: 2,
Expand All @@ -584,6 +604,7 @@ COPY Dockerfile .
{
RuleName: "UndeclaredArgInFrom",
Description: "FROM command must use declared ARGs",
URL: "https://docs.docker.com/go/dockerfile/rule/undeclared-arg-in-from/",
Detail: "FROM argument 'MYARCH' is not declared (did you mean MY_ARCH?)",
Level: 1,
Line: 4,
Expand All @@ -605,6 +626,7 @@ COPY Dockerfile .
{
RuleName: "UndeclaredArgInFrom",
Description: "FROM command must use declared ARGs",
URL: "https://docs.docker.com/go/dockerfile/rule/undeclared-arg-in-from/",
Detail: "FROM argument 'version' is not declared",
Level: 1,
Line: 3,
Expand All @@ -624,6 +646,7 @@ WORKDIR app/
{
RuleName: "WorkdirRelativePath",
Description: "Relative workdir without an absolute workdir declared within the build can have unexpected results if the base image changes",
URL: "https://docs.docker.com/go/dockerfile/rule/workdir-relative-path/",
Detail: "Relative workdir \"app/\" can have unexpected results if the base image changes",
Level: 1,
Line: 3,
Expand Down Expand Up @@ -676,6 +699,7 @@ RUN echo $foo
{
RuleName: "UndefinedVar",
Description: "Variables should be defined before their use",
URL: "https://docs.docker.com/go/dockerfile/rule/undefined-var/",
Detail: "Usage of undefined variable '$foo'",
Level: 1,
Line: 3,
Expand All @@ -696,6 +720,7 @@ COPY $DIR_ASSET .
{
RuleName: "UndefinedVar",
Description: "Variables should be defined before their use",
URL: "https://docs.docker.com/go/dockerfile/rule/undefined-var/",
Detail: "Usage of undefined variable '$DIR_ASSET' (did you mean $DIR_ASSETS?)",
Level: 1,
Line: 6,
Expand All @@ -713,6 +738,7 @@ ENV PATH=$PAHT:/tmp/bin
{
RuleName: "UndefinedVar",
Description: "Variables should be defined before their use",
URL: "https://docs.docker.com/go/dockerfile/rule/undefined-var/",
Detail: "Usage of undefined variable '$PAHT' (did you mean $PATH?)",
Level: 1,
Line: 3,
Expand All @@ -726,6 +752,7 @@ func testMultipleInstructionsDisallowed(t *testing.T, sb integration.Sandbox) {
return expectedLintWarning{
RuleName: "MultipleInstructionsDisallowed",
Description: "Multiple instructions of the same type should not be used in the same stage",
URL: "https://docs.docker.com/go/dockerfile/rule/multiple-instructions-disallowed/",
Detail: fmt.Sprintf("Multiple %s instructions should not be used in the same stage because only the last one will be used", instructionName),
Level: 1,
Line: line,
Expand Down Expand Up @@ -799,13 +826,15 @@ LABEL key value
{
RuleName: "LegacyKeyValueFormat",
Description: "Legacy key/value format with whitespace separator should not be used",
URL: "https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/",
Detail: "\"ENV key=value\" should be used instead of legacy \"ENV key value\" format",
Line: 3,
Level: 1,
},
{
RuleName: "LegacyKeyValueFormat",
Description: "Legacy key/value format with whitespace separator should not be used",
URL: "https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/",
Detail: "\"LABEL key=value\" should be used instead of legacy \"LABEL key value\" format",
Line: 4,
Level: 1,
Expand Down
1 change: 1 addition & 0 deletions frontend/dockerfile/dockerfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7232,6 +7232,7 @@ ENV foo=bar
{
RuleName: "InvalidBaseImagePlatform",
Description: "Base image platform does not match expected target platform",
URL: "https://docs.docker.com/go/dockerfile/rule/invalid-base-image-platform/",
Detail: fmt.Sprintf("Base image %s was pulled with platform %q, expected %q for current build", target, targetPlatform, runtime.GOOS+"/"+runtime.GOARCH),
Level: 1,
Line: 2,
Expand Down
2 changes: 1 addition & 1 deletion frontend/dockerfile/docs/rules/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ $ docker build --check .
<td>Reserved stage names should not be used to name a stage</td>
</tr>
<tr>
<td><a href="./jsonargs-recommended.md">JSONArgsRecommended</a></td>
<td><a href="./json-args-recommended.md">JSONArgsRecommended</a></td>
<td>JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals</td>
</tr>
<tr>
Expand Down
2 changes: 2 additions & 0 deletions frontend/dockerfile/docs/rules/duplicate-stage-name.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: DuplicateStageName
description: Stage names should be unique
aliases:
- /go/dockerfile/rule/duplicate-stage-name/
---

## Output
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: FileConsistentCommandCasing
description: All commands within the Dockerfile should use the same casing (either upper or lower)
aliases:
- /go/dockerfile/rule/file-consistent-command-casing/
---

## Output
Expand Down
2 changes: 2 additions & 0 deletions frontend/dockerfile/docs/rules/from-as-casing.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: FromAsCasing
description: The 'as' keyword should match the case of the 'from' keyword
aliases:
- /go/dockerfile/rule/from-as-casing/
---

## Output
Expand Down
2 changes: 2 additions & 0 deletions frontend/dockerfile/docs/rules/invalid-base-image-platform.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: InvalidBaseImagePlatform
description: Base image platform does not match expected target platform
aliases:
- /go/dockerfile/rule/invalid-base-image-platform/
---

## Output
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: JSONArgsRecommended
description: JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals
aliases:
- /go/dockerfile/rule/json-args-recommended/
---

## Output
Expand Down
2 changes: 2 additions & 0 deletions frontend/dockerfile/docs/rules/legacy-key-value-format.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: LegacyKeyValueFormat
description: Legacy key/value format with whitespace separator should not be used
aliases:
- /go/dockerfile/rule/legacy-key-value-format/
---

## Output
Expand Down
2 changes: 2 additions & 0 deletions frontend/dockerfile/docs/rules/maintainer-deprecated.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: MaintainerDeprecated
description: The maintainer instruction is deprecated, use a label instead to define an image author
aliases:
- /go/dockerfile/rule/maintainer-deprecated/
---

## Output
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: MultipleInstructionsDisallowed
description: Multiple instructions of the same type should not be used in the same stage
aliases:
- /go/dockerfile/rule/multiple-instructions-disallowed/
---

## Output
Expand Down
2 changes: 2 additions & 0 deletions frontend/dockerfile/docs/rules/no-empty-continuations.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: NoEmptyContinuations
description: Empty continuation lines will become errors in a future release
aliases:
- /go/dockerfile/rule/no-empty-continuations/
---

## Output
Expand Down
2 changes: 2 additions & 0 deletions frontend/dockerfile/docs/rules/reserved-stage-name.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: ReservedStageName
description: Reserved stage names should not be used to name a stage
aliases:
- /go/dockerfile/rule/reserved-stage-name/
---

## Output
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: SelfConsistentCommandCasing
description: Commands should be in consistent casing (all lower or all upper)
aliases:
- /go/dockerfile/rule/self-consistent-command-casing/
---

## Output
Expand Down
2 changes: 2 additions & 0 deletions frontend/dockerfile/docs/rules/stage-name-casing.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: StageNameCasing
description: Stage names should be lowercase
aliases:
- /go/dockerfile/rule/stage-name-casing/
---

## Output
Expand Down
2 changes: 2 additions & 0 deletions frontend/dockerfile/docs/rules/undeclared-arg-in-from.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: UndeclaredArgInFrom
description: FROM command must use declared ARGs
aliases:
- /go/dockerfile/rule/undeclared-arg-in-from/
---

## Output
Expand Down
2 changes: 2 additions & 0 deletions frontend/dockerfile/docs/rules/undefined-var.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: UndefinedVar
description: Variables should be defined before their use
aliases:
- /go/dockerfile/rule/undefined-var/
---

## Output
Expand Down
Loading

0 comments on commit 53e3858

Please sign in to comment.