Skip to content

USHIFT-1050: Add hadolint : Linter for Dockerfiles and Containerfiles#1642

Merged
openshift-merge-robot merged 4 commits intoopenshift:mainfrom
chiragkyal:docker-lint
Apr 10, 2023
Merged

USHIFT-1050: Add hadolint : Linter for Dockerfiles and Containerfiles#1642
openshift-merge-robot merged 4 commits intoopenshift:mainfrom
chiragkyal:docker-lint

Conversation

@chiragkyal
Copy link
Member

Which issue(s) this PR addresses:

Closes https://issues.redhat.com/browse/USHIFT-1050

This PR adds hadolint as a linter for Dockerfiles and Containerfiles

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 10, 2023
@openshift-ci-robot
Copy link

openshift-ci-robot commented Apr 10, 2023

@chiragkyal: This pull request references USHIFT-1050 which is a valid jira issue.

Details

In response to this:

Which issue(s) this PR addresses:

Closes https://issues.redhat.com/browse/USHIFT-1050

This PR adds hadolint as a linter for Dockerfiles and Containerfiles

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci openshift-ci bot requested review from copejon and pacevedom April 10, 2023 05:37
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 10, 2023
@chiragkyal
Copy link
Member Author

Enabled DL3007 rule to cross-check the linter in CI. Expecting the verify job to fail due to DL3007

@chiragkyal
Copy link
Member Author

As expected, the CI Job failed with error

./docs/config/Containerfile.tinyproxy:1 DL3007 warning: Using latest is prone to errors if the image will ever update. Pin the version explicitly to a release tag
./packaging/images/openshift-ci/Dockerfile.test-runtime:2 DL3007 warning: Using latest is prone to errors if the image will ever update. Pin the version explicitly to a release tag

Disabling the rule back.

@@ -1,3 +1,4 @@
# hadolint global ignore=DL3002,DL4006,SC3037,SC2086
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DL3002 warning: Last USER should not be root
SC3037 warning: In POSIX sh, echo flags are undefined.
SC2086 info: Double quote to prevent globbing and word splitting.
DL4006 warning: Set the SHELL option -o pipefail before RUN with a pipe in it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may want to move the first warning to the global flags and fix the other 3 in the file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's try to avoid having local suppressions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • DL3002 : Moved to common config
  • SC3037 : replaced echo -e with printf with some formatting changes
  • SC2086 : Added Double quote
  • DL4006: Added SHELL ["/bin/bash", "-o", "pipefail", "-c"] Ref here

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 10, 2023

@chiragkyal: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@ggiguash
Copy link
Contributor

This is LGTM for me. Let's have someone else review and merge this PR.

repo_gpgcheck=1\n\
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg\n\
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg' > /etc/yum.repos.d/google-cloud-sdk.repo
RUN printf '%s\n' \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this produce the same output? It seems like we would lose the line breaks between each of the separate values?

Could we put this config file in git as a file and then copy it into the right place in the container at this step?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL

$ printf "%s\n" foo bar
foo
bar

@dhellmann
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 10, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 10, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chiragkyal, dhellmann

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [chiragkyal,dhellmann]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants