-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4878 from jsternberg/maintainer-lint-rule
dockerfile: add lint rule for maintainer instruction
- Loading branch information
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ var lintTests = integration.TestFuncs( | |
testNoEmptyContinuations, | ||
testSelfConsistentCommandCasing, | ||
testFileConsistentCommandCasing, | ||
testMaintainerDeprecated, | ||
) | ||
|
||
func testStageName(t *testing.T, sb integration.Sandbox) { | ||
|
@@ -208,6 +209,29 @@ COPY Dockerfile /bar | |
checkLinterWarnings(t, sb, dockerfile, []expectedLintWarning{}) | ||
} | ||
|
||
func testMaintainerDeprecated(t *testing.T, sb integration.Sandbox) { | ||
dockerfile := []byte(` | ||
FROM scratch | ||
MAINTAINER [email protected] | ||
`) | ||
checkLinterWarnings(t, sb, dockerfile, []expectedLintWarning{ | ||
{ | ||
RuleName: "MaintainerDeprecated", | ||
Description: "The maintainer instruction is deprecated, use a label instead to define an image author", | ||
Detail: "Maintainer instruction is deprecated in favor of using label", | ||
URL: "https://docs.docker.com/reference/dockerfile/#maintainer-deprecated", | ||
Level: 1, | ||
Line: 3, | ||
}, | ||
}) | ||
|
||
dockerfile = []byte(` | ||
FROM scratch | ||
LABEL org.opencontainers.image.authors="[email protected]" | ||
`) | ||
checkLinterWarnings(t, sb, dockerfile, []expectedLintWarning{}) | ||
} | ||
|
||
func checkUnmarshal(t *testing.T, sb integration.Sandbox, c *client.Client, dir *integration.TmpDirWithName, expected []expectedLintWarning) { | ||
destDir, err := os.MkdirTemp("", "buildkit") | ||
require.NoError(t, err) | ||
|
@@ -254,6 +278,8 @@ func checkUnmarshal(t *testing.T, sb integration.Sandbox, c *client.Client, dir | |
} | ||
|
||
func checkProgressStream(t *testing.T, sb integration.Sandbox, c *client.Client, dir *integration.TmpDirWithName, expected []expectedLintWarning) { | ||
t.Helper() | ||
|
||
status := make(chan *client.SolveStatus) | ||
statusDone := make(chan struct{}) | ||
done := make(chan struct{}) | ||
|
@@ -335,6 +361,7 @@ func checkLinterWarnings(t *testing.T, sb integration.Sandbox, dockerfile []byte | |
} | ||
|
||
func checkVertexWarning(t *testing.T, warning *client.VertexWarning, expected expectedLintWarning) { | ||
t.Helper() | ||
short := linter.LintFormatShort(expected.RuleName, expected.Detail, expected.Line) | ||
require.Equal(t, short, string(warning.Short)) | ||
require.Equal(t, expected.Description, string(warning.Detail[0])) | ||
|
@@ -343,6 +370,7 @@ func checkVertexWarning(t *testing.T, warning *client.VertexWarning, expected ex | |
} | ||
|
||
func checkLintWarning(t *testing.T, warning lint.Warning, expected expectedLintWarning) { | ||
t.Helper() | ||
require.Equal(t, expected.RuleName, warning.RuleName) | ||
require.Equal(t, expected.Description, warning.Description) | ||
require.Equal(t, expected.URL, warning.URL) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters