Skip to content

Commit

Permalink
Prepare for v1.5.0 release (#85)
Browse files Browse the repository at this point in the history
* README updates and bug fix

* fixing unit tests

* fixing ref

* fixing ref

* reverting ref_head

* don't update badges if on the pull request

* Update README.md

Co-authored-by: Jamie Davidson <[email protected]>

* Update README.md

Co-authored-by: Jamie Davidson <[email protected]>

* Update index.md

Co-authored-by: Jamie Davidson <[email protected]>

* Update index.md

Co-authored-by: Jamie Davidson <[email protected]>

* alphabatized the config file type lists

---------

Co-authored-by: Jamie Davidson <[email protected]>
  • Loading branch information
kehoecj and jd4235 authored Nov 2, 2023
1 parent 62ee751 commit 0dc1878
Show file tree
Hide file tree
Showing 14 changed files with 242 additions and 90 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ jobs:
fi
- name: Commit changes
if: steps.generate-badge.outputs.badge_updates == 'true'
if: steps.generate-badge.outputs.badge_updates == 'true' && github.event_name != 'pull_request'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add README.md index.md
git commit -m "chore: Updated coverage badge."
- name: Push changes
if: steps.generate-badge.outputs.badge_updates == 'true'
if: steps.generate-badge.outputs.badge_updates == 'true' && github.event_name != 'pull_request'
uses: ad-m/github-push-action@master
with:
github_token: ${{ github.token }}
Expand Down
140 changes: 103 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div align="center">
<img src="./img/logo.png" width="200" height="200"/>
<h1>Config File Validator</h1>
<img src="./img/logo.png" width="200" height="200"/>
<h1>Config File Validator</h1>
<p>Single cross-platform CLI tool to validate different configuration file types</p>
</div>

<p align="center">
Expand All @@ -23,60 +24,89 @@
</a>
</p>

## About
How many deployments have you done that needed to be rolled back due to a missing character in a configuration file in your repo? If you're like most teams that number is greater than zero. The config file validator was created to solve this problem by searching through your project and validating the syntax of all configuration files.

> [!NOTE]
> The config-file-validator only performs syntax validation. We are working toward adding support for schema validation in future releases
### Where can you use this tool?
* In a CI/CD pipeline as a quality gate
* On your desktop to validate configuration files as you write them
* As a library within your existing go code

### What types of files are supported?
* XML
* JSON
* YAML
* TOML
## Supported config files formats:
* Apple PList XML
* CSV
* HCL
* INI
* JSON
* Properties
* HCL
* TOML
* XML
* YAML

## Demo

## Installing
<img src="./img/demo.gif" alt="demo" />

## Installation
There are several ways to install the config file validator tool

### Using `go install`
If you have a go environment on your desktop you can use [go install](https://go.dev/doc/go-get-install-deprecation) to install the validator executable. The validator executable will be installed to the directory named by the GOBIN environment variable, which defaults to $GOPATH/bin or $HOME/go/bin if the GOPATH environment variable is not set.
### Docker

We offer alpine, ubuntu, and scratch containers

#### Apline

```
docker pull config-file-validator:1.5.0
```

#### Ubuntu

```
go install github.com/Boeing/config-file-validator/cmd/validator
docker pull config-file-validator-ubuntu:1.5.0
```

### Using aqua
#### Scratch

```
docker pull config-file-validator-scratch:1.5.0
```

### Binary Releases
Download and unpack from https://github.com/Boeing/config-file-validator/releases

### Aqua
You can install the validator using [aqua](https://aquaproj.github.io/).

```
aqua g -i Boeing/config-file-validator
```

### Executables
The config-file-validator is built as a statically linked binary which can be downloaded and executed on your target system. Binaries are available for Linux, Windows, and MacOS. Navigate to the [releases](https://github.com/Boeing/config-file-validator/releases) page to download the latest version. Once the binary has been downloaded it needs to be installed by moving the downloaded file to a location on your operating system's PATH.
### Arch Linux
We release a [PKGBUILD](https://github.com/Boeing/config-file-validator/blob/main/PKGBUILD) file for Arch Linux

## Using
```
Usage: validator [OPTIONS] [search_path]
cd config-file-validator
makepkg -si
```

### `go install`
If you have a go environment on your desktop you can use [go install](https://go.dev/doc/go-get-install-deprecation) to install the validator executable. The validator executable will be installed to the directory named by the GOBIN environment variable, which defaults to $GOPATH/bin or $HOME/go/bin if the GOPATH environment variable is not set.

```
go install github.com/Boeing/config-file-validator/cmd/[email protected]
```

## Usage
```
Usage: validator [OPTIONS] [<search_path>...]
positional arguments:
search_path: The search path on the filesystem for configuration files. Defaults to the current working directory if no search_path provided
search_path: The search path on the filesystem for configuration files. Defaults to the current working directory if no search_path provided. Multiple search paths can be declared separated by a space.
optional flags:
-depth int
Depth of recursion for the provided search paths. Set depth to 0 to disable recursive path traversal
-exclude-dirs string
Subdirectories to exclude when searching for configuration files
-exclude-file-types string
A comma separated list of file types to ignore
-reporter string
Format of the printed report. Options are standard and json (default "standard")
-version
Version prints the release version of validator
```

### Examples
Expand All @@ -88,7 +118,15 @@ validator /path/to/search

![Standard Run](./img/standard_run.png)

#### Exclude dirs
#### Multiple search paths
Multiple search paths are supported and the results will be merged into a single report
```
validator /path/to/search /another/path/to/search
```

![Multiple Search Paths Run](./img/multiple_paths.png)

#### Exclude directories
Exclude subdirectories in the search path

```
Expand All @@ -98,14 +136,23 @@ validator --exclude-dirs=/path/to/search/tests /path/to/search
![Exclude Dirs Run](./img/exclude_dirs.png)

#### Exclude file types
Exclude file types in the search path. Available file types are `ini`, `json`, `yaml`, `yml`, `toml`, and `xml`
Exclude file types in the search path. Available file types are `csv`, `hcl`, `ini`, `json`, `plist`, `properties`, `toml`, `xml`, `yaml`, and `yml`

```
validator --exclude-file-types=json /path/to/search
```

![Exclude File Types Run](./img/exclude_file_types.png)

#### Customize recursion depth
By default there is no recursion limit. If desired, the recursion depth can be set to an integer value. If depth is set to `0` recursion will be disabled and only the files in the search path will be validated.

```
validator --depth=0 /path/to/search
```

![Custom Recursion Run](./img/custom_recursion.png)

#### Customize report output
Customize the report output. Available options are `standard` and `json`

Expand All @@ -118,13 +165,32 @@ validator --reporter=json /path/to/search

#### Container Run
```
docker run -it --rm -v /path/to/config/files:/test config-file-validator:1.4.0 /test
docker run -it --rm -v /path/to/config/files:/test config-file-validator:1.5.0 /test
```

![Docker Standard Run](./img/docker_run.png)

## Building from source
The project can be downloaded and built from source using an environment with golang 1.17+ installed. After successful build, the statically-linked binary can be moved to a location on your operating system PATH.
## Build
The project can be downloaded and built from source using an environment with golang 1.21 installed. After a successful build, the binary can be moved to a location on your operating system PATH.

### MacOS
#### Build
```
CGO_ENABLED=0 \
GOOS=darwin \
GOARCH=amd64 \ # for Apple Silicon use arm64
go build \
-ldflags='-w -s -extldflags "-static"' \
-tags netgo \
-o validator \
cmd/validator/validator.go
```

#### Install
```
cp ./validator /usr/local/bin/
chmod +x /usr/local/bin/validator
```

### Linux
#### Build
Expand Down Expand Up @@ -166,14 +232,14 @@ cp .\validator.exe 'C:\Program Files\validator'
```

### Docker
You can also use the provided Dockerfile to build the config file validator tool in a container
You can also use the provided Dockerfile to build the config file validator tool as a container

```
docker build . -t config-file-validator
docker build . -t config-file-validator:v1.5.0
```

## Contributing
We welcome contributions! Please refer to our [contributing guide](/CONTRIBUTING.md)

## License
The Config File Validator is released under the [Apache 2.0](/LICENSE) License
The Config File Validator is released under the [Apache 2.0](/LICENSE) License
33 changes: 19 additions & 14 deletions cmd/validator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@
Validator recusively scans a directory to search for configuration files and
validates them using the go package for each configuration type.
Currently json, yaml, toml, xml, ini, properties, hcl, csv and plist configuration file
types are supported.
Usage:
validator [OPTIONS] [search_path]
The flags are:
-exclude-dirs string
Subdirectories to exclude when searching for configuration files.
-reporter string
Format of printed report. Currently supports standard, JSON.
-exclude-file-types string
A comma separated list of file types to ignore.
Currently Apple PList XML, CSV, HCL, INI, JSON, Properties, TOML, XML, and YAML
configuration file types are supported.
Usage: validator [OPTIONS] [<search_path>...]
positional arguments:
search_path: The search path on the filesystem for configuration files. Defaults to the current working directory if no search_path provided. Multiple search paths can be declared separated by a space.
optional flags:
-depth int
Depth of recursion for the provided search paths. Set depth to 0 to disable recursive path traversal
-exclude-dirs string
Subdirectories to exclude when searching for configuration files
-exclude-file-types string
A comma separated list of file types to ignore
-reporter string
Format of the printed report. Options are standard and json (default "standard")
-version
Version prints the release version of validator
*/

package main
Expand Down
Binary file added img/custom_recursion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/custom_reporter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/docker_run.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/exclude_dirs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/exclude_file_types.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/multiple_paths.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/standard_run.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0dc1878

Please sign in to comment.