diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 4d2254c..38f3686 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,7 +1,7 @@ # This workflow will build a golang project # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go -name: Go +name: Go Pipeline on: push @@ -45,8 +45,6 @@ jobs: uses: actions/setup-go@v3 with: go-version: 1.19 - + - name: Test run: go test -v ./... - - diff --git a/README.md b/README.md index 26c2424..06e1be5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,28 @@ -# Config File Validator +
+ +

Config File Validator

+
+ +

+ + Apache 2 License + + + + Go Reference + + + + Go Report Card + + + + Pipeline Status + +

## 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 configuation files. +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. ### Where can you use this tool? * In a CI/CD pipeline as a quality gate @@ -14,8 +35,55 @@ How many deployments have you done that needed to be rolled back due to a missin * YAML * TOML -## Getting Started -Binaries and a container on Dockerhub will eventually be available but for now the project must be built on an environment that has golang 1.17+ installed. +## Installing +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. + +``` +go install github.com/Boeing/config-file-validator/cmd/validator +``` + + +### Executables +Executables are available for Linux and Windows (macOS coming soon!). Navigate to the [releases](https://github.com/Boeing/config-file-validator/releases) page to download the latest version. Once the executable has been downloaded it needs to be installed by moving the downloaded file to a location on your OS PATH. + +## Using +``` +Usage of /validator: + -exclude-dirs string + Subdirectories to exclude when searching for configuration files + -search-path string + The search path for configuration files +``` + +### Examples +#### Standard Run +``` +validator -search-path /path/to/search +``` + +![Standard Run](./img/standard_run.png) + +#### Exclude dirs +Exclude subdirectories in the search path + +``` +validator -search-path /path/to/search -exclude-dirs=/path/to/search/tests +``` + +![Exclude Dirs Run](./img/exclude_dirs.png) + +#### Container Run +``` +docker run -it --rm -v /path/to/config/file/location:/test -search-path=/test +``` + +![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. ### Linux #### Build @@ -57,47 +125,14 @@ cp .\validator.exe 'C:\Program Files\validator' ``` ### Docker -The config file validator can be built as a docker container -``` -docker build . -t config-file-validator -``` - -## Using -``` -Usage of /validator: - -exclude-dirs string - Subdirectories to exclude when searching for configuration files - -search-path string - The search path for configuration files -``` +You can also use the provided Dockerfile to build the config file validator tool in a container -### Examples -#### Standard Run -``` -validator -search-path /path/to/search ``` - -![Standard Run](./img/standard_run.png) - -#### Exclude dirs -Exclude subdirectories in the search path - -``` -validator -search-path /path/to/search -exclude-dirs=/path/to/search/tests -``` - -![Exclude Dirs Run](./img/exclude_dirs.png) - -#### Container Run -``` -docker run -it --rm -v /path/to/config/file/location:/test -search-path=/test +docker build . -t config-file-validator ``` -![Standard Run](./img/docker_run.png) - ## 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 diff --git a/cmd/validator/validator.go b/cmd/validator/validator.go index afb622d..920dab7 100644 --- a/cmd/validator/validator.go +++ b/cmd/validator/validator.go @@ -1,3 +1,20 @@ +/* +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, and xml configuration file types are supported. + +Usage: + + validator [flags] + +The flags are: + -search-path string + The search path for configuration files + -exclude-dirs string + Subdirectories to exclude when searching for configuration files +*/ + package main import ( diff --git a/img/logo.png b/img/logo.png new file mode 100755 index 0000000..8e7d070 Binary files /dev/null and b/img/logo.png differ