Skip to content

Commit d5edf81

Browse files
committed
Update/create readme for generating protobuf files for logcache and loggregator
1 parent 805210e commit d5edf81

File tree

2 files changed

+36
-53
lines changed

2 files changed

+36
-53
lines changed

lib/logcache/README.md

Lines changed: 19 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,34 @@
1-
This is taken from code.cloudfoundry.org/go-log-cache/rpc/logcache_v1/generate.sh
1+
This is taken from [github.com/cloudfoundry/go-log-cache/rpc/logcache_v1/generate.sh](https://github.com/cloudfoundry/go-log-cache/blob/main/rpc/logcache_v1/generate.sh)
22

3-
To generate the two logcache egress*pb.rb files:
4-
5-
`grpc_tools_ruby_protoc` comes from doing `gem install grpc-tools`
3+
To generate the logcache protobuf files:
64

75
```
86
#!/bin/bash
97
10-
11-
go get github.com/golang/protobuf/{proto,protoc-gen-go}
12-
go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
13-
go get code.cloudfoundry.org/log-cache
8+
gem install grpc-tools
149
1510
tmp_dir=$(mktemp -d)
16-
mkdir -p $tmp_dir/log-cache
17-
18-
trash_dir=$(mktemp -d)
19-
20-
cp $GOPATH/src/code.cloudfoundry.org/log-cache/api/v1/*proto $tmp_dir/log-cache
11+
echo "Temp dir: $tmp_dir"
12+
mkdir -p $tmp_dir/logcache
2113
2214
pushd $tmp_dir
23-
git clone https://github.com/cloudfoundry/loggregator-api
15+
git clone --depth 1 https://github.com/cloudfoundry/loggregator-api.git
16+
git clone --depth 1 https://github.com/googleapis/googleapis.git
17+
mv googleapis/google .
18+
rm -rf googleapis
19+
20+
git clone --depth 1 https://github.com/cloudfoundry/go-log-cache.git
21+
cp go-log-cache/api/v1/*.proto logcache/
22+
rm -rf go-log-cache
2423
popd
2524
26-
RUBY_OUT=$trash_dir/log-cache/ruby-out
27-
GRPC_OUT=$trash_dir/log-cache/grpc-out
28-
mkdir -p $RUBY_OUT $GRPC_OUT
29-
grpc_tools_ruby_protoc \
30-
$tmp_dir/log-cache/*.proto \
31-
--go_out=plugins=grpc,Mv2/envelope.proto=code.cloudfoundry.org/go-loggregator/rpc/loggregator_v2:. \
32-
--ruby_out=$RUBY_OUT \
33-
--grpc_out=$GRPC_OUT \
34-
--proto_path=$tmp_dir/log-cache \
35-
--grpc-gateway_out=logtostderr=true:. \
36-
-I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
37-
-I=/usr/local/include \
38-
-I=$tmp_dir/log-cache \
39-
-I=$tmp_dir/loggregator-api/.
40-
```
41-
42-
You want `$trash_dir/log-cache/ruby-out/egress_pb.rb` and `$trash_dir/log-cache/grpc-out/egress_services_pb.rb`
43-
44-
45-
To generate the two v2/envelope_pb.rb file:
46-
47-
```
48-
mkdir -p $tmp_dir/loggregator-api
49-
cp $GOPATH/src/code.cloudfoundry.org/loggregator-api/v2/*proto $tmp_dir/loggregator-api/
50-
51-
RUBY_OUT=$trash_dir/loggregator-api/ruby-out
52-
GRPC_OUT=$trash_dir/loggregator-api/grpc-out
25+
out_dir=$(mktemp -d)
26+
echo "Out dir: $out_dir"
27+
RUBY_OUT=$out_dir/ruby-out
28+
GRPC_OUT=$out_dir/grpc-out
5329
mkdir -p $RUBY_OUT $GRPC_OUT
54-
grpc_tools_ruby_protoc \
55-
$tmp_dir/loggregator-api/*.proto \
56-
--go_out=plugins=grpc,Mv2/envelope.proto=code.cloudfoundry.org/go-loggregator/rpc/loggregator_v2:. \
57-
--ruby_out=$RUBY_OUT \
58-
--grpc_out=$GRPC_OUT \
59-
--proto_path=$tmp_dir/loggregator-api \
60-
--grpc-gateway_out=logtostderr=true:. \
61-
-I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
62-
-I=/usr/local/include \
63-
-I=$tmp_dir/log-cache \
64-
-I=$GOPATH/src/code.cloudfoundry.org/loggregator-api/.
6530
31+
protoc --plugin=protoc-gen-grpc=`which grpc_tools_ruby_protoc_plugin` --proto_path=$tmp_dir --ruby_out=$RUBY_OUT --grpc_out=$GRPC_OUT $tmp_dir/logcache/*.proto
6632
```
6733

68-
You want `$trash_dir/ruby-out/envelope_pb.rb`
34+
Copy `$tmp_dir/ruby_out/logcache/*` and `$tmp_dir/grpc_out/logcache` into `lib/logcache`.

lib/loggregator-api/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
To generate the envelope_pb.rb file:
2+
3+
1. Install protoc 30.2 from https://github.com/protocolbuffers/protobuf/releases
4+
5+
```
6+
#!/bin/bash
7+
8+
tmp_dir=$(mktemp -d)
9+
10+
pushd $tmp_dir
11+
git clone https://github.com/cloudfoundry/loggregator-api
12+
13+
protoc --ruby_out=. loggregator-api/v2/envelope.proto
14+
popd
15+
```
16+
17+
Copy `$tmp_dir/envelope_pb.rb` to CC's `lib/loggregator-api/v2/`.

0 commit comments

Comments
 (0)