Skip to content

Commit

Permalink
feat(composer): generate pb.go using generate step
Browse files Browse the repository at this point in the history
  • Loading branch information
qlonik committed Feb 26, 2024
1 parent 18a9efa commit 33c97b3
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 13 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/ensure-committed-go-generate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Ensure all `go generate` files are committed

on:
pull_request:

jobs:
generated-committed:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'privacy-profile-composer/go.mod'
- uses: arduino/setup-protoc@v3
with:
version: "25.x"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- run: |
go mod download
go install google.golang.org/protobuf/cmd/protoc-gen-go
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc
go generate ./...
working-directory: ./privacy-profile-composer
- run: |
changes=$(git status --untracked-files=no --porcelain)
if [[ -n "$changes" ]]; then
echo "=== DETECTED CHANGES ==="
echo "$changes"
git diff
exit 1
fi
8 changes: 3 additions & 5 deletions docker/istio-proxyv2.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
FROM golang:1.20 as builder

RUN apt-get update \
&& apt-get install -y protobuf-compiler \
&& go install google.golang.org/protobuf/cmd/[email protected] \
&& go install google.golang.org/grpc/cmd/[email protected]

WORKDIR /app

COPY ./privacy-profile-composer/go.mod ./privacy-profile-composer/go.sum ./
RUN go mod download

COPY ./privacy-profile-composer/ ./
RUN make build-envoy-filter

Expand Down
10 changes: 2 additions & 8 deletions privacy-profile-composer/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
build-envoy-filter: proto
build-envoy-filter:
go build -o dist/simple.so -buildmode=c-shared ./cmd/envoy-filter

run-server: proto
run-server:
go run ./cmd/opa-composer-server --policy_file ./pkg/opa/policy-and-logic/policy.rego

proto:
protoc \
--go_out=. --go_opt=module=privacy-profile-composer \
--go-grpc_out=. --go-grpc_opt=module=privacy-profile-composer \
./pkg/proto/privacy_profiles.proto
6 changes: 6 additions & 0 deletions privacy-profile-composer/pkg/proto/generator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//go:build generate
// +build generate

package proto

//go:generate protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative ./privacy_profiles.proto

0 comments on commit 33c97b3

Please sign in to comment.