Pre-Commit hooks for validating Docker projects
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

compose-check.sh 581B

1234567891011121314151617181920212223242526272829
  1. #! /bin/bash
  2. # Verifies that files passed in are valid for docker-compose
  3. set -e
  4. check_file() {
  5. local file=$1
  6. docker-compose -f "$file" config -q 2>&1 \
  7. | sed "/variable is not set. Defaulting/d"
  8. return ${PIPESTATUS[0]}
  9. }
  10. check_files() {
  11. local all_files=$@
  12. has_error=0
  13. for file in $all_files ; do
  14. if [[ -f "$file" ]]; then
  15. if ! check_file "$file" ; then
  16. has_error=1
  17. fi
  18. fi
  19. done
  20. return $has_error
  21. }
  22. if ! check_files $@ ; then
  23. echo "To ignore, use --no-verify"
  24. fi
  25. exit $has_error