mirror of
https://github.com/dense-analysis/ale
synced 2024-12-28 00:52:20 +00:00
5a3cfbbdf5
* Add documentation for hadolint (doc/ale-hadolint.txt) * Allow `hadolint` linter to run via docker image These changes enable the `hadolint` linter to run via the author's docker image, if present. Three modes are supported: * never use docker; * always use docker; and * use docker as a failback.
70 lines
1.7 KiB
Plaintext
70 lines
1.7 KiB
Plaintext
" NOTE: We use the 'b:' forms below to ensure that we're properly using
|
|
" ale#Var()
|
|
|
|
Given dockerfile:
|
|
#
|
|
|
|
Before:
|
|
Save g:ale_dockerfile_hadolint_use_docker
|
|
Save g:ale_dockerfile_hadolint_docker_image
|
|
silent! unlet g:ale_dockerfile_hadolint_use_docker
|
|
silent! unlet g:ale_dockerfile_hadolint_docker_image
|
|
|
|
" enable loading inside test container
|
|
silent! cd /testplugin
|
|
source ale_linters/dockerfile/hadolint.vim
|
|
|
|
|
|
After:
|
|
Restore
|
|
silent! unlet b:ale_dockerfile_hadolint_use_docker
|
|
silent! unlet b:ale_dockerfile_hadolint_docker_image
|
|
|
|
|
|
Execute(linter honors ..._use_docker correctly):
|
|
|
|
" default: never
|
|
AssertEqual
|
|
\ 'hadolint',
|
|
\ ale_linters#dockerfile#hadolint#GetExecutable(bufnr(''))
|
|
|
|
" explicit never
|
|
let b:ale_dockerfile_hadolint_use_docker = 'never'
|
|
AssertEqual
|
|
\ 'hadolint',
|
|
\ ale_linters#dockerfile#hadolint#GetExecutable(bufnr(''))
|
|
|
|
let b:ale_dockerfile_hadolint_use_docker = 'always'
|
|
AssertEqual
|
|
\ 'docker',
|
|
\ ale_linters#dockerfile#hadolint#GetExecutable(bufnr(''))
|
|
|
|
" hadolint if present, otherwise docker
|
|
let command = 'docker'
|
|
if executable('hadolint')
|
|
let command = 'hadolint'
|
|
endif
|
|
|
|
let b:ale_dockerfile_hadolint_use_docker = 'yes'
|
|
AssertEqual
|
|
\ command,
|
|
\ ale_linters#dockerfile#hadolint#GetExecutable(bufnr(''))
|
|
|
|
|
|
Execute(command is correct when using docker):
|
|
let b:ale_dockerfile_hadolint_use_docker = 'always'
|
|
|
|
AssertEqual
|
|
\ "docker run --rm -i lukasmartinelli/hadolint",
|
|
\ ale_linters#dockerfile#hadolint#GetCommand(bufnr(''))
|
|
|
|
|
|
Execute(command is correct when not docker):
|
|
let b:ale_dockerfile_hadolint_use_docker = 'never'
|
|
|
|
AssertEqual
|
|
\ "hadolint -",
|
|
\ ale_linters#dockerfile#hadolint#GetCommand(bufnr(''))
|
|
|
|
" fin...
|