#!/bin/sh usage() { cat < [--fix] Mode: go Run golang lint utilities all Run all lint utilities EOF exit 1 } go() { local fix=$1 [ "$fix" = "true" ] && EXTRA_ARGS="--fix" || EXTRA_ARGS="" [ ! -e .golangci.yaml ] && echo "ERROR: Run the script from the project root." && exit 1 for container in agent:docker agent:native server; do echo "Running Golang linter on $container" case $container in agent:docker) EXTRA_ARGS="$EXTRA_ARGS --build-tags docker" container=$(echo $container | cut -d':' -f 1) ;; agent:native) EXTRA_ARGS="$EXTRA_ARGS --build-tags native" container=$(echo $container | cut -d':' -f 1) ;; esac docker-compose \ -f docker-compose.yml -f docker-compose.dev.yml \ exec $container golangci-lint run ./... $EXTRA_ARGS done echo "Running Golang linter on pkg" docker-compose \ -f docker-compose.yml -f docker-compose.dev.yml \ exec server sh -c "(cd ../pkg; golangci-lint run $EXTRA_ARGS ./... )" } mode=$1 arg=$2 case "$arg" in "--fix") fix="true" ;; esac case "$mode" in "go") go $fix ;; "all") go $fix ;; *) usage ;; esac