Skip to content

Commit

Permalink
fix issue 17 (#18)
Browse files Browse the repository at this point in the history
* release v0.1.3

* go mod tidy

* fix issue 17

* Revert "go mod tidy"

This reverts commit adf2b7b.
  • Loading branch information
zabio3 committed Jul 3, 2022
1 parent 7ee1058 commit 781e50c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (

const name = "godolint"

const version = "0.1.1"
const version = "0.1.3"

const usage = `godolint - Dockerfile Linter written in Golang
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Other Commands:
},
{
command: "godolint --version",
expectedOutStream: "godolint version 0.1.1\n",
expectedOutStream: "godolint version 0.1.3\n",
expectedErrStream: "",
expectedExitCode: ExitCodeOK,
},
Expand Down
6 changes: 5 additions & 1 deletion linter/rules/dl3013.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

var regexVersion3013 = regexp.MustCompile(`.+[=|@].+`)

// validateDL3013 Pin versions in pip. Instead of `pip install <package>` use `pip install <package>==<version>`
// validateDL3013 Pin versions in pip. Instead of `pip install <package>` use `pip install <package>==<version>`.
func validateDL3013(node *parser.Node) (rst []ValidateResult, err error) {
for _, child := range node.Children {
if child.Value == RUN {
Expand All @@ -26,6 +26,10 @@ func validateDL3013(node *parser.Node) (rst []ValidateResult, err error) {
case "&&":
isPip, isInstall = false, false
default:
if strings.HasPrefix(v, "--") || strings.HasPrefix(v, "yamllint") {
continue
}

if isPip && isInstall && !regexVersion3013.MatchString(v) && length == len(rst) {
rst = append(rst, ValidateResult{line: child.StartLine})
}
Expand Down
12 changes: 12 additions & 0 deletions linter/rules/dl3013_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ RUN pip install django && pip install https://github.com/Banno/carbon/tarball/0.
},
expectedErr: nil,
},
{
dockerfileStr: `FROM python:3.4
ARG YAML_LINT_VERSION=v1.26.3
RUN pip install --no-cache-dir yamllint=="${YAML_LINT_VERSION:-v1.26.3}"
RUN pip install django && pip install https://github.com/Banno/carbon/tarball/0.9.x-fix-events-callback
`,
expectedRst: []ValidateResult{
{line: 5},
},
expectedErr: nil,
},
}

for i, tc := range cases {
Expand Down
6 changes: 5 additions & 1 deletion testdata/DL3013_Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
FROM python:3.4
RUN pip install django
RUN pip install https://github.com/Banno/carbon/tarball/0.9.x-fix-events-callback
RUN pip install https://github.com/Banno/carbon/tarball/0.9.x-fix-events-callback

ARG YAML_LINT_VERSION=v1.26.3

RUN pip install --no-cache-dir yamllint=="${YAML_LINT_VERSION:-v1.26.3}"

0 comments on commit 781e50c

Please sign in to comment.