cefd2dab7a
* add script for tooling * add to make * not to forget * reworked go tools * add tool installation script * adding readme * updating readme * updating readme * cleanup install.sh and makefile * update the readme file * cleanup scripts * switch variables.mk to lazy evaluation * add tools ache to gitignore * get rid of absolute path in hte Variables.mk file * switch to reusable function for path generation * add debug statements * add create cache tool dir * add debuig statements to make file * drop tool cache * fix race condition n ci * fix race condition n ci * cleanup workspace * add lefthook.rc to codeowners * copy .citools folder to docker image * switch back to main branch of grafana-build * Add .citools to the drone builder * fix wording in generate.sh and README.md
34 lines
773 B
Bash
Executable File
34 lines
773 B
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
TOOLS_BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
TOOLS_SRC_DIR="$TOOLS_BASE_DIR/src"
|
|
|
|
IMPORT_PATH_WITH_VERSION="$1"
|
|
|
|
if [[ "$IMPORT_PATH_WITH_VERSION" != *"@"* ]]; then
|
|
echo "Error: tool version must be specified (e.g., github.com/foo/bar@v1.2.3)"
|
|
exit 1
|
|
fi
|
|
|
|
TOOL_PATH="${IMPORT_PATH_WITH_VERSION%@*}"
|
|
TOOL_NAME="${TOOL_PATH##*/}"
|
|
|
|
TOOL_DIR="$TOOLS_SRC_DIR/$TOOL_NAME"
|
|
MOD_FILE="$TOOL_DIR/go.mod"
|
|
|
|
mkdir -p "$TOOL_DIR"
|
|
cd "$TOOL_DIR"
|
|
|
|
# Create a new module if go.mod doesn't exist
|
|
if [ ! -f go.mod ]; then
|
|
go mod init "$TOOL_NAME"
|
|
fi
|
|
|
|
go get -tool --modfile="$MOD_FILE" "$IMPORT_PATH_WITH_VERSION"
|
|
echo "Installed $TOOL_NAME"
|
|
echo " Directory: $TOOL_DIR"
|
|
echo " Modfile: $MOD_FILE"
|
|
|
|
exec "$TOOLS_BASE_DIR/generate.sh"
|