Skip to content

Commit 15df4bd

Browse files
authored
Merge pull request #9 from breml/add-mustache
Add mustache
2 parents f48df7a + 2927b7f commit 15df4bd

File tree

24 files changed

+891
-83
lines changed

24 files changed

+891
-83
lines changed

.github/workflows/release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: goreleaser
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]*'
7+
8+
jobs:
9+
goreleaser:
10+
runs-on: ubuntu-latest
11+
steps:
12+
-
13+
name: Checkout
14+
uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
17+
18+
-
19+
name: Set up Go
20+
uses: actions/setup-go@v2
21+
with:
22+
go-version: 1.16
23+
24+
-
25+
name: Run GoReleaser
26+
uses: goreleaser/goreleaser-action@v2
27+
with:
28+
distribution: goreleaser
29+
version: latest
30+
args: release --rm-dist
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,24 @@ jobs:
1313
test:
1414
strategy:
1515
matrix:
16-
go-version: [1.14.x, 1.15.x]
16+
go-version: [1.15.x, 1.16.x]
1717
os: [ubuntu-latest, macos-latest, windows-latest]
1818
runs-on: ${{ matrix.os }}
1919
steps:
20-
- name: Install Go
20+
-
21+
name: Install Go
2122
uses: actions/setup-go@v2
2223
with:
2324
go-version: ${{ matrix.go-version }}
24-
- name: Checkout code
25+
26+
-
27+
name: Checkout code
2528
uses: actions/checkout@v2
26-
- name: Test
29+
30+
-
31+
name: Build
32+
run: go build ./...
33+
34+
-
35+
name: Test
2736
run: go test -v -cover ./...

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@
2020

2121
.idea/
2222
*~
23+
24+
# Goreleaser
25+
dist/

.goreleaser.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This is an example .goreleaser.yml file with some sane defaults.
2+
# Make sure to check the documentation at http://goreleaser.com
3+
before:
4+
hooks:
5+
# You may remove this if you don't use go modules.
6+
- go mod tidy
7+
builds:
8+
- main: ./cmd/mustache
9+
binary: mustache
10+
env:
11+
- CGO_ENABLED=0
12+
goos:
13+
- linux
14+
- windows
15+
- darwin
16+
archives:
17+
- name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
18+
replacements:
19+
darwin: Darwin
20+
linux: Linux
21+
windows: Windows
22+
386: i386
23+
amd64: x86_64
24+
snapshot:
25+
name_template: "{{ .Tag }}-next"
26+
changelog:
27+
skip: true
28+
release:
29+
github:
30+
owner: breml
31+
name: logstash-config

README.md

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# logstash-config : parser and abstract syntax tree for [Logstash](https://github.com/elastic/logstash) config files
1+
# logstash-config : parser and abstract syntax tree for [Logstash](https://www.elastic.co/logstash/) config files
22

33
[![Test Status](https://github.com/breml/logstash-config/workflows/Test/badge.svg)](https://github.com/breml/logstash-config/actions?query=workflow%3ATest)
44
[![Go Report Card](https://goreportcard.com/badge/github.com/breml/logstash-config)](https://goreportcard.com/report/github.com/breml/logstash-config)\
5-
[![GoDoc](https://godoc.org/github.com/breml/logstash-config?status.svg)](https://godoc.org/github.com/breml/logstash-config) [![License](https://img.shields.io/badge/license-Apache_2.0-blue.svg)](LICENSE)
5+
[![GoDoc](https://pkg.go.dev/badge/github.com/breml/logstash-config)](https://pkg.go.dev/github.com/breml/logstash-config) [![License](https://img.shields.io/badge/license-Apache_2.0-blue.svg)](LICENSE)
66

77
## Overview
88

9-
The Go package config provides a ready to use parser for [Logstash](https://github.com/elastic/logstash) configuration files.
9+
The Go package config provides a ready to use parser for Logstash ([github](https://github.com/elastic/logstash)) configuration files.
1010

1111
The basis of the grammar for the parsing of the Logstash configuration format is the original [Logstash Treetop grammar](https://github.com/elastic/logstash/blob/master/logstash-core/lib/logstash/config/grammar.treetop) which could be used with only minor changes.
1212

@@ -22,10 +22,42 @@ go get -t github.com/breml/logstash-config/...
2222

2323
## Usage
2424

25-
### ls-config-check
25+
### mustache
2626

27-
`cmd/ls-config-check` contains the source code for a small sample tool, which uses just allow to parse a given Logstash config file. If the file could be parsed successfully, the tool just exits with exit code `0`. If the parsing fails, the exit code is non zero and a error message, indicating the location, where the parsing failed, is printed.
28-
`ls-config-check <logstash-config-file>` could be used instead if `bin/logstash -f <logstash-config-file> -t`, which is orders of magnitude faster 😃.
27+
`mustache` is a command line tool that allows to syntax check, lint and format Logstash configuration files. The name of
28+
the tool is inspired by the original Logstash Logo ([wooden character with an eye-catching mustache](https://www.elastic.co/de/blog/high-level-logstash-roadmap-is-published)).
29+
30+
The `check` command verifies the syntax of Logstash configuration files:
31+
32+
```shell
33+
mustache check file.conf
34+
```
35+
36+
The `lint` command checks for problems in Logstash configuration files.
37+
38+
The following checks are performed:
39+
40+
* Valid Logstash configuration file syntax
41+
* No comments in exceptional places (these are comments, that are valid by the Logstash configuration file syntax, but
42+
but are located in exceptional or uncommon locations)
43+
* Precence of an `id` attribute for each plugin in the Logstash configuration
44+
45+
If the `--auto-fix-id` flag is passed, each plugin gets automatically an ID. Be aware, that this potentially reformats
46+
the Logstash configuration files.
47+
48+
```shell
49+
mustache lint --auto-fix-id file.conf
50+
```
51+
52+
With the `format` command, mustache returns the provided configuration files in a standardized format (indentation,
53+
location of comments). By default, the reformatted file is print to standard out. If the flag `--write-to-source`
54+
is provided, the Logstash config files are reformatted in place.
55+
56+
```shell
57+
mustache format --write-to-source file.conf
58+
```
59+
60+
Use the `--help` flag to get more information about the usage of the tool.
2961

3062
## Rebuild parser
3163

cmd/ls-config-check/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

cmd/ls-config-check/README.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

cmd/ls-config-check/main.go

Lines changed: 0 additions & 46 deletions
This file was deleted.

cmd/mustache/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mustache

cmd/mustache/main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package main
2+
3+
import (
4+
"os"
5+
6+
"github.com/breml/logstash-config/internal/app"
7+
)
8+
9+
var Version = "(unknown)"
10+
11+
func main() {
12+
exitCode := app.Execute(Version, os.Stdout, os.Stderr)
13+
os.Exit(exitCode)
14+
}

0 commit comments

Comments
 (0)