Skip to content

Instantly share code, notes, and snippets.

@evgeny-goldin
Created March 7, 2015 16:18
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evgeny-goldin/7162a24713c3ac23bcf7 to your computer and use it in GitHub Desktop.
Save evgeny-goldin/7162a24713c3ac23bcf7 to your computer and use it in GitHub Desktop.
Validate project's JSON and YAMl files
# Validate project's JSON files
function vj()
{
if [ "$1" == "" ]; then
local path="."
else
local path="$1"
fi
for json in $(find "$path" -name "*.json"); do
echo "$json"
python -m json.tool "$json" > /dev/null
if [ "$?" != "0" ]; then
echo "===> [$json] check has failed!"
fi
done
}
# Validate project's YAML files
function vy()
{
if [ "$1" == "" ]; then
local path="."
else
local path="$1"
fi
for yml in $(find "$path" -name "*.yml"); do
echo "$yml"
# pip install --upgrade pyyaml
python -c "import yaml; yaml.load( open('$yml','r'))"
if [ "$?" != "0" ]; then
echo "===> [$yml] check has failed!"
fi
done
}
$ vj
./packer/ansible/packer-template.json
./packer/packer/packer-template.json
./packer/packer-iam.json
$ vy
./playbooks/artifactory-ubuntu.yml
./playbooks/asgard-ubuntu.yml
./playbooks/docker-ubuntu.yml
./playbooks/helios-agent-ubuntu.yml
./playbooks/helios-cli-ubuntu.yml
./playbooks/helios-master-ubuntu.yml
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment