haproxy-lint

command module
v0.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2016 License: MIT Imports: 6 Imported by: 0

README

license GoDoc Build Status codebeat badge

haproxy-lint

Simple linter for HAProxy configuration.

Editor plugins

There is official Atom plugin - linter-haproxy. Any other editor can be simply integrated using linter's JSON output.

Installation

Grab latest release on releases page, or build from source.

To get more warnings you need a local HAProxy executable. Install it with Homebrew on OS X or package manager of your choice on Linux.

Building from source

You need working Go compiler. Tested against Go 1.5+

On Linux/OSX:

# set GOPATH to some valid path
export GOPATH=~/go && mkdir -p ~/go
go get github.com/abulimov/haproxy-lint

Now you have haproxy-lint binary.

Usage

You can specify switch to JSON output with --jsonflag (useful for editor plugins integration).

Also you can manually disable running local HAProxy binary in check mode with --run-haproxy=false flag.

If the config you are checking will be later processed by some template engine, you can tell haproxy-lint to exclude some lines in config file based on regexp pattern with --ignore='some_regexp' flag.

haproxy-lint /etc/haproxy/haproxy.cfg
24:0:warning: ACL h_some declared but not used
18:0:warning: backend unused-servers declared but not used
25:0:critical: backend undefined-servers used but not declared


haproxy-lint --json /etc/haproxy/haproxy.cfg
[
  {
    "col": 0,
    "line": 24,
    "severity": "warning",
    "message": "ACL h_some declared but not used"
  },
  {
    "col": 0,
    "line": 18,
    "severity": "warning",
    "message": "backend unused-servers declared but not used"
  },
  {
    "col": 0,
    "line": 25,
    "severity": "critical",
    "message": "backend undefined-servers used but not declared"
  }
]

HAProxy check mode

In case if you have locally installed HAProxy, it gets run by this linter with -c flag to check specified file, and it's output is parsed and returned as a linter warning.

If locally installed HAProxy is found, some of Native rules does not get executed, as they just duplicate HAProxy's own checks.

Native Rules

# Severity Rule Runs when local HAProxy found
001 critical backend used but not declared yes
002 warning backend declared but not used yes
003 warning acl declared but not used yes
004 critical acl used but not declared no
005 warning rule order masking real evaluation precedence no
006 warning duplicate rules found yes
007 warning deprecated keywords found no
008 warning unreachable rule found yes

Contributing

Please read CONTRIBUTING.md if you wish to contribute.

License

Licensed under the MIT License, see LICENSE.

Documentation

Overview

Simple linter for HAProxy configuration.

This tool can perform static analysis of HAProxy config.

Usage:

$ haproxy-lint [options] FILE

Available options:

-json          output found problems in JSON format

-run-haproxy   run haproxy binary in check mode and parse
               its output to extract alerts and warnigns

-ignore regexp ignore lines in config file matching given regexp

-v             show version and exit

Directories

Path Synopsis
Package checks contains all checks we can run agains HAProxy config
Package checks contains all checks we can run agains HAProxy config
lib
Package lib contains core logic for performing checks on HAProxy config
Package lib contains core logic for performing checks on HAProxy config
acl

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL