Skip to content

Commit

Permalink
Add a fmt target for proto defintions
Browse files Browse the repository at this point in the history
This uses clang-format to ensure the proto defintions are more
consistently formatted.
  • Loading branch information
simonswine committed Apr 6, 2022
1 parent b865b81 commit e2eb926
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,22 @@ fmt-jsonnet:
@find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \
xargs -n 1 -- jsonnetfmt -i

fmt-proto:
ifeq ($(BUILD_IN_CONTAINER),true)
# I wish we could make this a multiline variable however you can't pass more than simple arguments to them
@mkdir -p $(shell pwd)/.pkg
@mkdir -p $(shell pwd)/.cache
$(SUDO) docker run $(RM) $(TTY) -i \
-v $(shell pwd)/.cache:/go/cache$(MOUNT_FLAGS) \
-v $(shell pwd)/.pkg:/go/pkg$(MOUNT_FLAGS) \
-v $(shell pwd):/src/loki$(MOUNT_FLAGS) \
$(IMAGE_PREFIX)/loki-build-image:$(BUILD_IMAGE_VERSION) $@;
else
find . -name 'vendor' -prune -o -name '*.proto' -print | \
xargs -n 1 -- clang-format -i
endif


lint-scripts:
# Ignore https://github.com/koalaman/shellcheck/wiki/SC2312
@find . -name '*.sh' -not -path '*/vendor/*' -print0 | \
Expand Down
2 changes: 1 addition & 1 deletion loki-build-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ RUN apt-get update && \
apt-get install -qy \
musl gnupg ragel \
file zip unzip jq gettext\
protobuf-compiler libprotobuf-dev \
protobuf-compiler libprotobuf-dev clang-format \
libsystemd-dev && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

Expand Down

0 comments on commit e2eb926

Please sign in to comment.