Skip to content

Commit

Permalink
Fix tests (WIP)
Browse files Browse the repository at this point in the history
Signed-off-by: Felipe Santos <[email protected]>
  • Loading branch information
felipecrs committed Oct 31, 2024
1 parent ddbc0f2 commit 6d26769
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 35 deletions.
42 changes: 21 additions & 21 deletions frontend/dockerfile/dockerfile_lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ COPY $bar .
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 '$bar'",
Detail: "Usage of undefined variable $bar",
Level: 1,
Line: 6,
},
Expand All @@ -322,15 +322,15 @@ COPY $bar .
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'",
Detail: "Usage of undefined variable $foo",
Level: 1,
Line: 3,
},
{
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 '$bar'",
Detail: "Usage of undefined variable $bar",
Level: 1,
Line: 6,
},
Expand Down Expand Up @@ -374,7 +374,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",
Detail: "'as' and 'FROM' keywords' casing does not match",
Line: 2,
Level: 1,
},
Expand All @@ -392,7 +392,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",
Detail: "'as' and 'FROM' keywords' casing does not match",
Line: 2,
Level: 1,
},
Expand All @@ -413,7 +413,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",
Detail: "'as' and 'FROM' keywords' casing does not match",
Line: 2,
Level: 1,
},
Expand Down Expand Up @@ -465,7 +465,7 @@ FROM scratch AS base3
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",
Detail: "'as' and 'FROM' keywords' casing does not match",
Line: 8,
Level: 1,
},
Expand All @@ -487,7 +487,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",
Detail: "'AS' and 'from' keywords' casing does not match",
Line: 4,
Level: 1,
},
Expand Down Expand Up @@ -535,7 +535,7 @@ FROM scratch AS base2
RuleName: "ConsistentInstructionCasing",
Description: "All commands within the Dockerfile should use the same casing (either upper or lower)",
URL: "https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/",
Detail: "Command 'From' should match the case of the command majority (uppercase)",
Detail: "Command 'From' should match the case of the majority of commands (uppercase)",
Level: 1,
Line: 4,
},
Expand All @@ -556,7 +556,7 @@ COPY Dockerfile /bar
RuleName: "ConsistentInstructionCasing",
Description: "All commands within the Dockerfile should use the same casing (either upper or lower)",
URL: "https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/",
Detail: "Command 'copy' should match the case of the command majority (uppercase)",
Detail: "Command 'copy' should match the case of the majority of commands (uppercase)",
Line: 4,
Level: 1,
},
Expand All @@ -576,7 +576,7 @@ from scratch as base2
RuleName: "ConsistentInstructionCasing",
Description: "All commands within the Dockerfile should use the same casing (either upper or lower)",
URL: "https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/",
Detail: "Command 'frOM' should match the case of the command majority (lowercase)",
Detail: "Command 'frOM' should match the case of the majority of commands (lowercase)",
Line: 4,
Level: 1,
},
Expand All @@ -596,7 +596,7 @@ copy Dockerfile /bar
RuleName: "ConsistentInstructionCasing",
Description: "All commands within the Dockerfile should use the same casing (either upper or lower)",
URL: "https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/",
Detail: "Command 'COPY' should match the case of the command majority (lowercase)",
Detail: "Command 'COPY' should match the case of the majority of commands (lowercase)",
Line: 4,
Level: 1,
},
Expand All @@ -618,7 +618,7 @@ COPY Dockerfile /baz
RuleName: "ConsistentInstructionCasing",
Description: "All commands within the Dockerfile should use the same casing (either upper or lower)",
URL: "https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/",
Detail: "Command 'from' should match the case of the command majority (uppercase)",
Detail: "Command 'from' should match the case of the majority of commands (uppercase)",
Line: 4,
Level: 1,
},
Expand All @@ -640,7 +640,7 @@ copy Dockerfile /baz
RuleName: "ConsistentInstructionCasing",
Description: "All commands within the Dockerfile should use the same casing (either upper or lower)",
URL: "https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/",
Detail: "Command 'FROM' should match the case of the command majority (lowercase)",
Detail: "Command 'FROM' should match the case of the majority of commands (lowercase)",
Line: 4,
Level: 1,
},
Expand Down Expand Up @@ -1056,7 +1056,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'",
Detail: "Usage of undefined variable $foo",
Level: 1,
Line: 3,
},
Expand All @@ -1079,7 +1079,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?)",
Detail: "Usage of undefined variable $DIR_ASSET (did you mean $DIR_ASSETS?)",
Level: 1,
Line: 6,
},
Expand All @@ -1099,7 +1099,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?)",
Detail: "Usage of undefined variable $PAHT (did you mean $PATH?)",
Level: 1,
Line: 3,
},
Expand Down Expand Up @@ -1187,15 +1187,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",
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",
Detail: "`LABEL key=value` should be used instead of legacy `LABEL key value` format",
Line: 4,
Level: 1,
},
Expand Down Expand Up @@ -1227,15 +1227,15 @@ FROM a AS c
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",
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",
Detail: "`LABEL key=value` should be used instead of legacy `LABEL key value` format",
Line: 4,
Level: 1,
},
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 @@ -37,7 +37,7 @@ To learn more about how to use build checks, see
</tr>
<tr>
<td><a href="./from-as-casing/">FromAsCasing</a></td>
<td>The 'as' keyword should match the case of the 'from' keyword</td>
<td>The AS keyword should match the case of the FROM keyword</td>
</tr>
<tr>
<td><a href="./no-empty-continuation/">NoEmptyContinuation</a></td>
Expand Down
5 changes: 2 additions & 3 deletions frontend/dockerfile/docs/rules/from-as-casing.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
title: FromAsCasing
description: The 'as' keyword should match the case of the 'from' keyword
description: The AS keyword should match the case of the FROM keyword
aliases:
- /go/dockerfile/rule/from-as-casing/
---

## Output

```text
'as' and 'FROM' keywords' casing do not match
'as' and 'FROM' keywords' casing does not match
```

## Description
Expand Down Expand Up @@ -41,4 +41,3 @@ from debian:latest as deb-builder
## Related errors

- [`FileConsistentCommandCasing`](./consistent-instruction-casing.md)

2 changes: 1 addition & 1 deletion frontend/dockerfile/docs/rules/legacy-key-value-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ aliases:
## Output

```text
"ENV key=value" should be used instead of legacy "ENV key value" format
`ENV key=value` should be used instead of legacy `ENV key value` format
```

## Description
Expand Down
4 changes: 2 additions & 2 deletions frontend/dockerfile/docs/rules/undefined-var.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ aliases:
## Output

```text
Usage of undefined variable '$foo'
Usage of undefined variable $foo
```

## Description
Expand All @@ -34,7 +34,7 @@ ENV PATH=$PAHT:/app/bin
The check identifies that `$PAHT` is undefined and likely a typo for `$PATH`:

```text
Usage of undefined variable '$PAHT' (did you mean $PATH?)
Usage of undefined variable $PAHT (did you mean $PATH?)
```

## Examples
Expand Down
2 changes: 1 addition & 1 deletion frontend/dockerfile/linter/docs/FromAsCasing.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Output

```text
'as' and 'FROM' keywords' casing do not match
'as' and 'FROM' keywords' casing does not match
```

## Description
Expand Down
2 changes: 1 addition & 1 deletion frontend/dockerfile/linter/docs/LegacyKeyValueFormat.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Output

```text
"ENV key=value" should be used instead of legacy "ENV key value" format
`ENV key=value` should be used instead of legacy `ENV key value` format
```

## Description
Expand Down
4 changes: 2 additions & 2 deletions frontend/dockerfile/linter/docs/UndefinedVar.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Output

```text
Usage of undefined variable '$foo'
Usage of undefined variable $foo
```

## Description
Expand All @@ -27,7 +27,7 @@ ENV PATH=$PAHT:/app/bin
The check identifies that `$PAHT` is undefined and likely a typo for `$PATH`:

```text
Usage of undefined variable '$PAHT' (did you mean $PATH?)
Usage of undefined variable $PAHT (did you mean $PATH?)
```

## Examples
Expand Down
6 changes: 3 additions & 3 deletions frontend/dockerfile/linter/ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var (
Description: "The AS keyword should match the case of the FROM keyword",
URL: "https://docs.docker.com/go/dockerfile/rule/from-as-casing/",
Format: func(from, as string) string {
return fmt.Sprintf("'%s' and '%s' keywords casing do not match", as, from)
return fmt.Sprintf("'%s' and '%s' keywords' casing does not match", as, from)
},
}
RuleNoEmptyContinuation = LinterRule[func() string]{
Expand Down Expand Up @@ -50,7 +50,7 @@ var (
Description: "Reserved words should not be used as stage names",
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 the reserved stage '%q'", reservedStageName)
return fmt.Sprintf("Stage name should not use the same name as the reserved stage %q", reservedStageName)
},
}
RuleJSONArgsRecommended = LinterRule[func(instructionName string) string]{
Expand Down Expand Up @@ -129,7 +129,7 @@ var (
Description: "Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior",
URL: "https://docs.docker.com/go/dockerfile/rule/redundant-target-platform/",
Format: func(platformVar string) string {
return fmt.Sprintf("Setting platform to predefined $%s in FROM is redundant as this is the default behavior", platformVar)
return fmt.Sprintf("Setting platform to predefined %s in FROM is redundant as this is the default behavior", platformVar)
},
}
RuleSecretsUsedInArgOrEnv = LinterRule[func(string, string) string]{
Expand Down

0 comments on commit 6d26769

Please sign in to comment.