Skip to content

Commit

Permalink
Merge pull request grafana#6 from thampiotr/thampiotr/fix-agentfmt.sh
Browse files Browse the repository at this point in the history
Fix & improve agentfmt.sh
  • Loading branch information
mattdurham authored May 12, 2023
2 parents 3885064 + 1c81d1c commit d47e463
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modules/grafana-agent/telemetry-to-lgtm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ The following fields are exported by the module:
```
tracing {
sampling_fraction = 1
write_to = [module.file.agent_telemetry.exports.trace_input]
write_to = [module.git.agent_telemetry.exports.trace_input]
}
module.git "agent_telemetry" {
Expand Down
14 changes: 11 additions & 3 deletions util/agentfmt.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
set -euo pipefail

#
# Recursively search a directory for .river files and format them.
#
Expand All @@ -10,9 +12,15 @@
AGENT_DIR=$1
TARGET_DIR=$2

cd $AGENT_DIR
find "$TARGET_DIR" -name "*.river" -print0 | while read -d $'\0' file
echo "Building agent binary"
pushd "$AGENT_DIR"
make agent
popd


find "$TARGET_DIR" -name "*.river" -print0 | while read -rd $'\0' file
do
# This should probably be more clever than having to run the go project for every file but does the job for now...
go run ./cmd/grafana-agent fmt -w $file
echo "Formatting $file"
AGENT_MODE=flow "$AGENT_DIR/build/grafana-agent" fmt -w "$file"
done

0 comments on commit d47e463

Please sign in to comment.