mirror of https://github.com/dense-analysis/ale
Add 'dockerfile_hadolint_options' config setting (#4353)
- Add this option so command line arguments can be supplied to hadolint - This will be respected when running in docker and via the executable - Preserve the --no-color and - flags, and add these to the list - Add to docs and tests
This commit is contained in:
parent
483d056528
commit
121fbefeae
|
@ -3,6 +3,7 @@
|
|||
" always, yes, never
|
||||
call ale#Set('dockerfile_hadolint_use_docker', 'never')
|
||||
call ale#Set('dockerfile_hadolint_docker_image', 'hadolint/hadolint')
|
||||
call ale#Set('dockerfile_hadolint_options', '')
|
||||
|
||||
function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort
|
||||
" Matches patterns line the following:
|
||||
|
@ -102,7 +103,7 @@ endfunction
|
|||
|
||||
function! ale_linters#dockerfile#hadolint#GetCommand(buffer) abort
|
||||
let l:command = ale_linters#dockerfile#hadolint#GetExecutable(a:buffer)
|
||||
let l:opts = '--no-color -'
|
||||
let l:opts = ale#Var(a:buffer, 'dockerfile_hadolint_options') . ' --no-color -'
|
||||
|
||||
if l:command is# 'docker'
|
||||
return printf('docker run --rm -i %s hadolint %s',
|
||||
|
|
|
@ -37,6 +37,16 @@ hadolint *ale-dockerfile-hadolint*
|
|||
hadolint can be found at: https://github.com/hadolint/hadolint
|
||||
|
||||
|
||||
g:ale_dockerfile_hadolint_options *g:ale_dockerfile_hadolint_options*
|
||||
*b:ale_dockerfile_hadolint_options*
|
||||
Type: |String|
|
||||
Default: `''`
|
||||
|
||||
This variable can be changed to add command-line arguments to the hadolint
|
||||
invocation. These arguments will be used whether docker is being used or not
|
||||
(see below).
|
||||
|
||||
|
||||
g:ale_dockerfile_hadolint_use_docker *g:ale_dockerfile_hadolint_use_docker*
|
||||
*b:ale_dockerfile_hadolint_use_docker*
|
||||
Type: |String|
|
||||
|
|
|
@ -19,6 +19,7 @@ After:
|
|||
Restore
|
||||
silent! unlet b:ale_dockerfile_hadolint_use_docker
|
||||
silent! unlet b:ale_dockerfile_hadolint_docker_image
|
||||
silent! unlet b:ale_dockerfile_hadolint_options
|
||||
|
||||
|
||||
Execute(linter honors ..._use_docker correctly):
|
||||
|
@ -55,15 +56,30 @@ Execute(command is correct when using docker):
|
|||
let b:ale_dockerfile_hadolint_use_docker = 'always'
|
||||
|
||||
AssertEqual
|
||||
\ "docker run --rm -i hadolint/hadolint hadolint --no-color -",
|
||||
\ "docker run --rm -i hadolint/hadolint hadolint --no-color -",
|
||||
\ ale_linters#dockerfile#hadolint#GetCommand(bufnr(''))
|
||||
|
||||
Execute(command is correct when using docker and supplying options):
|
||||
let b:ale_dockerfile_hadolint_use_docker = 'always'
|
||||
let b:ale_dockerfile_hadolint_options = '--ignore DL3006'
|
||||
|
||||
AssertEqual
|
||||
\ "docker run --rm -i hadolint/hadolint hadolint --ignore DL3006 --no-color -",
|
||||
\ ale_linters#dockerfile#hadolint#GetCommand(bufnr(''))
|
||||
|
||||
Execute(command is correct when not docker):
|
||||
let b:ale_dockerfile_hadolint_use_docker = 'never'
|
||||
|
||||
AssertEqual
|
||||
\ "hadolint --no-color -",
|
||||
\ "hadolint --no-color -",
|
||||
\ ale_linters#dockerfile#hadolint#GetCommand(bufnr(''))
|
||||
|
||||
Execute(command is correct when not docker and supplying options):
|
||||
let b:ale_dockerfile_hadolint_use_docker = 'never'
|
||||
let b:ale_dockerfile_hadolint_options = '--ignore DL3006'
|
||||
|
||||
AssertEqual
|
||||
\ "hadolint --ignore DL3006 --no-color -",
|
||||
\ ale_linters#dockerfile#hadolint#GetCommand(bufnr(''))
|
||||
|
||||
Execute(test warnings from hadolint):
|
||||
|
|
Loading…
Reference in New Issue