firecow / gitlab-ci-local

Tired of pushing to test your .gitlab-ci.yml?
MIT License
2.06k stars 118 forks source link

fix(#1137): only add image.docker.user if the value exists #1138

Closed e-picas closed 4 months ago

e-picas commented 4 months ago

This fixes #1137

With the original YML in the ticket:

my_job:
  image: node:lts
  script:
    - echo 'test'

The rendering of the --preview option is now safe (no more image.docker.user: null):

$ node ../test-gitlab-ci-local/gitlab-ci-local/src/index.js --preview
---
stages:
  - .pre
  - build
  - test
  - deploy
  - .post
my_job:
  image:
    name: node:lts
  script:
    - echo 'test'

And it passes the ci/lint validation:

$ jq --null-input --arg yaml "$(node ../test-gitlab-ci-local/gitlab-ci-local/src/index.js --preview)" '.content=$yaml' \
| curl "https://gitlab.com/api/v4/projects/${PROJECT_ID}/ci/lint" \
    --header "Authorization: Bearer ${GITLAB_TOKEN}" \
    --header 'Content-Type: application/json' \
    --data @- | jq '.errors'

[]

I also deleted the image.docker.user: null in the test cases.

firecow commented 4 months ago

eslint is failing @e-picas

e-picas commented 4 months ago

@firecow ok fixed