1
0
mirror of https://github.com/prometheus/alertmanager.git synced 2026-02-05 15:45:34 +01:00
Files
alertmanager/scripts/genproto.sh
Solomon Jacobs ec437dd312 Add buf for protobuf generation (#4955)
HRT uses this internally, and have positive experiences with this
project. Thus, this change facilitates them upstreaming their changes,
and makes are project easier to work with.

`buf` also has some nice additional tooling, which we could make use of.

Finally, we want to get rid off `gogoproto`, and having tooling will be
helpful.

Fixes: #4945

Signed-off-by: Solomon Jacobs <solomonjacobs@protonmail.com>
2026-02-05 10:47:40 +00:00

34 lines
790 B
Bash
Executable File

#!/usr/bin/env bash
#
# Generate all protobuf bindings.
# Run from repository root.
set -e
set -u
if ! [[ "$0" =~ "scripts/genproto.sh" ]]; then
echo "must be run from repository root"
exit 255
fi
pushd "internal/tools"
INSTALL_PKGS="github.com/bufbuild/buf/cmd/buf golang.org/x/tools/cmd/goimports github.com/gogo/protobuf/protoc-gen-gogofast"
for pkg in ${INSTALL_PKGS}; do
go install "$pkg"
done
popd
DIRS="nflog/nflogpb silence/silencepb cluster/clusterpb"
echo "generating files"
for dir in ${DIRS}; do
pushd ${dir}
buf dep update
buf generate
sed -i.bak -E 's/import _ \"gogoproto\"//g' *.pb.go
sed -i.bak -E 's/import _ \"google\/protobuf\"//g' *.pb.go
sed -i.bak -E 's/\t_ \"google\/protobuf\"//g' -- *.pb.go
rm -f *.bak
goimports -w *.pb.go
popd
done