Skip to content

Commit

Permalink
Fixing format issues on different vendor folders.
Browse files Browse the repository at this point in the history
  • Loading branch information
andream16 committed Nov 22, 2024
1 parent c0c1f9f commit dcb1140
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ go_protos=$(protos:.proto=.pb.go)
latest_tag=$(shell git tag --list --sort="-version:refname" | head -n 1)
commits_since_latest_tag=$(shell git log --oneline $(latest_tag)..HEAD | wc -l)
GO_TEST_PACKAGES=$(shell go list ./... | grep -v /vendor/)
VENDOR_DIRS=$(shell find . -type d -name "vendor")
NOT_VENDOR_PATHS := $(shell echo $(VENDOR_DIRS) | awk '{for (i=1; i<=NF; i++) print "-not -path \""$$i"/*\""}' | tr '\n' ' ')
EXCLUDE_VENDOR_PATHS := $(shell echo $(VENDOR_DIRS) | awk '{for (i=1; i<=NF; i++) print "--exclude-path \""$$i"\""}' | tr '\n' ' ')

# Deployment vars
# The following variables are used to define the deployment environment
Expand Down Expand Up @@ -98,7 +101,7 @@ publish-component-containers: $(component_containers_publish)
publish-containers: publish-component-containers smithyctl-image-publish

clean-protos:
@find . -not -path './vendor/*' -name '*.pb.go' -delete
@find . $(NOT_VENDOR_PATHS) -name '*.pb.go' -delete

clean-migrations-compose:
cd tests/migrations/ && docker compose rm --force
Expand Down Expand Up @@ -145,9 +148,9 @@ install-go-fmt-tools:
@go install golang.org/x/tools/cmd/goimports@latest

fmt-go:
@echo "Tidying up Go files"
@gofmt -l -w $$(find . -name *.go -not -path "**/vendor/*" | xargs -n 1 dirname | uniq)
@goimports -local $$(cat go.mod | grep -E "^module" | sed 's/module //') -w $$(find . -name *.go -not -path "**/vendor/*" | xargs -n 1 dirname | uniq)
echo "Tidying up Go files"
$(shell find . -type f -name "*.go" -not -name "*.pb.*" $(NOT_VENDOR_PATHS) | xargs gofmt -w | uniq)
@goimports -local $$(cat go.mod | grep -E "^module" | sed 's/module //') -w $$(find . -type f -name *.go -not -name "*.pb.*" $(NOT_VENDOR_PATHS) | xargs -n 1 dirname | uniq)

install-md-fmt-tools:
@npm ci
Expand Down Expand Up @@ -327,11 +330,11 @@ run-buf: build-buf-container

fmt-proto: build-buf-container
@echo "Tidying up Proto files"
$(MAKE) run-buf ARGS="format -w --exclude-path vendor/"
$(MAKE) run-buf ARGS="format -w $(EXCLUDE_VENDOR_PATHS)"

lint-proto: build-buf-container
@echo "Linting Proto files"
$(MAKE) run-buf ARGS="lint --exclude-path vendor/"
$(MAKE) run-buf ARGS="lint $(EXCLUDE_VENDOR_PATHS)"

# Buf doesn't have a way to configure where to put the generated code from remote repositories;
# that's why we make sure to correctly move it around. In this case it's just COM for OCSF types.
Expand Down
3 changes: 2 additions & 1 deletion containers/Dockerfile.buf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN go install google.golang.org/protobuf/cmd/[email protected]

# Install git and its dependencies to enable cloning as we generate protos from remote for OCSF.
FROM alpine AS git
RUN apk --no-cache add git ca-certificates openssl
RUN apk --no-cache add git ca-certificates openssl diffutils
RUN mkdir -p /git-deps/bin /git-deps/lib /git-deps/etc/ssl/certs
RUN cp /usr/bin/git /git-deps/bin
RUN cp /usr/libexec/git-core/git-remote-https /git-deps/bin/
Expand All @@ -25,6 +25,7 @@ COPY --from=git /git-deps/bin/git /usr/bin/
COPY --from=git /git-deps/bin/git-remote-https /usr/bin/
COPY --from=git /git-deps/lib /lib/
COPY --from=git /git-deps/etc/ssl/certs /etc/ssl/certs/
COPY --from=git /usr/bin/diff /usr/bin/diff
ENV GIT_SSL_CAINFO=/etc/ssl/certs/ca-certificates.crt
ENV PATH="/go/bin:/usr/bin:${PATH}"
ENTRYPOINT ["/go/bin/buf"]

0 comments on commit dcb1140

Please sign in to comment.