Code Monkey home page Code Monkey logo

Comments (7)

wata727 avatar wata727 commented on July 3, 2024

I'm not familiar with GitLab CI, but this error seems to occur when running tflint sh.
It's probably better to check the entrypoint.

from tflint-bundle.

tkreuder avatar tkreuder commented on July 3, 2024

I just face the issue with this image and as the 'Dockerfile' contains 'tflint' as entrypoint and my gitlab runner is configured to allow for entrypoint overrides, I am quiet puzzled, where this issue comes from. So the combination of gitlab runner and this image seems to result in this issue for me.

from tflint-bundle.

runningman avatar runningman commented on July 3, 2024

I also came across this issue which then led me to this issue. You can solve it by changing the entrypoint in your job:

tflint:
  image: 
    name: ghcr.io/terraform-linters/tflint-bundle:v0.45.0.0
    entrypoint: [ '/bin/sh', '-c' ]
  script:
    - tflint

from tflint-bundle.

csmatt4 avatar csmatt4 commented on July 3, 2024

I am encountering this issue as well. @runningman suggestion to alter the entrypoint appears to have been deprecated as a valid option in Gitlab. If you try to use it gitlab-ci.yml file to fail validation. I noticed the tflint image also fails when simply launching it with >docker run -it ghcr.io/terraform-linters/tflint-bundle:v0.45.0.0 sh or bash.

from tflint-bundle.

runningman avatar runningman commented on July 3, 2024

I don't think its deprecated, it is still documented https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#override-the-entrypoint-of-an-image

from tflint-bundle.

csmatt4 avatar csmatt4 commented on July 3, 2024

That's odd. Here is my gitlab-ci.yml file.

`stages:

  • lint

variables:
TFLINT_VERSION: "v0.45.0.2"
TFLINT_CONFIG: ".tflint.hcl"

lint:
stage: lint
image: ghcr.io/terraform-linters/tflint-bundle:${TFLINT_VERSION}
script:
- tflint --version
- tflint --init
- tflint modules/aws
- tflint --config=${TFLINT_CONFIG} --format=json > gl-tf-lint.json
- find . -type f -name "*.tf" -exec dirname {} ; | sort -u | while read line; do (cd "$line" && tflint --config=${TFLINT_CONFIG}); done
artifacts:
paths:
- gl-tf-lint.json`

When I validate the file against the gitlab API it returns as valid.

http POST "https://gitlab.com/api/v4/ci/lint" "Content-Type:application/json" "PRIVATE-TOKEN:xxxxx" content="$(cat .gitlab-ci.yml)" ref=main options:='{"gitlab_version":"15.0"}'

{
"errors": [],
"includes": [],
"status": "valid",
"valid": true,
"warnings": []
}`

Then when I add the entrypoint entrypoint: [ '/bin/sh', '-c' ]

It returns ...

{
"errors": [
"jobs:lint config contains unknown keys: entrypoint"
],
"includes": [],
"status": "invalid",
"valid": false,
"warnings": []
}`

from tflint-bundle.

csmatt4 avatar csmatt4 commented on July 3, 2024

I finally got it to work. I restructured my gitlab-ci.yml like this.

`stages:

  • lint

variables:
TFLINT_VERSION: "v0.45.0.2"
TFLINT_CONFIG: ".tflint.hcl"

lint:
image:
name: ghcr.io/terraform-linters/tflint-bundle:${TFLINT_VERSION}
entrypoint: [""]
stage: lint
script:
- tflint --version
- tflint --init
- tflint --config=${TFLINT_CONFIG} --format=json > gl-tf-lint.json
- find . -type f -name "*.tf" -exec dirname {} ; | sort -u | while read line; do (cd "$line" && tflint --config=${TFLINT_CONFIG}); done
artifacts:
paths:
- gl-tf-lint.json`

Apparently the trick was to add the "name" key as a separate indented line under the "image" key. Then when I added the "entrypoint" line below that it returned as a valid file.

from tflint-bundle.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.