Skip to content

Commit 011906d

Browse files
jeffmendozaistio-testing
authored andcommitted
Add Protolock. (#675)
* Add Protolock. Move the protoc docker files to tools/protoc. Add docker files for protolock image. Update Makefile precommit hook and prow presubmit check to run protolock. * Add combined image to be used on CircleCI * Update proto.lock for policy_check_fail_open in mesh config. * Updade circle config.
1 parent 4a0e55e commit 011906d

File tree

12 files changed

+4489
-4
lines changed

12 files changed

+4489
-4
lines changed

.circleci/config.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: 2
22
defaults: &defaults
33
working_directory: /src/istio.io/api
44
docker:
5-
- image: gcr.io/istio-testing/protoc:2018-06-12
5+
- image: gcr.io/istio-testing/api-build-tools:2018-10-24
66
environment:
77
GOPATH: /go
88
OUT_PATH: /src
@@ -15,10 +15,11 @@ jobs:
1515
- run:
1616
command: |
1717
./scripts/generate-protos.sh || die "could not generate *.pb.go"
18+
make proto-commit || die "could not regenerate proto.lock"
1819
if [[ -n $(git status --porcelain) ]]; then
1920
git status
2021
git --no-pager diff
21-
echo "Repo has unstaged changes. Re-run ./scripts/generate-protos.sh"
22+
echo "Repo has unstaged changes. Re-run ./scripts/generate-protos.sh or make proto-commit"
2223
exit 1
2324
fi
2425

Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ ifdef CIRCLECI
1010
repo_dir = .
1111
docker_gen = /usr/bin/protoc -I/protobuf -I$(repo_dir)
1212
out_path = $(OUT_PATH)
13+
docker_lock = protolock
1314
else
1415
gen_img := gcr.io/istio-testing/protoc:2018-06-12
16+
lock_img := gcr.io/istio-testing/protolock:2018-10-23
1517
pwd := $(shell pwd)
1618
mount_dir := /src
1719
repo_dir := istio.io/api
1820
repo_mount := $(mount_dir)/istio.io/api
1921
docker_gen := docker run --rm -v $(pwd):$(repo_mount) -w $(mount_dir) $(gen_img) -I$(repo_dir)
2022
out_path = .
23+
docker_lock = docker run --rm -v $(pwd):$(repo_mount) -w $(repo_mount) $(lock_img)
2124
endif
2225

2326
########################
@@ -99,12 +102,14 @@ generate-mcp-go: $(config_mcp_pb_gos) $(config_mcp_pb_doc)
99102

100103
$(config_mcp_pb_gos) $(config_mcp_pb_doc): $(config_mcp_protos)
101104
## Generate mcp/v1alpha1/*.pb.go + $(config_mcp_pb_doc)
105+
@$(docker_lock) status
102106
@$(docker_gen) $(gogofast_plugin) $(protoc_gen_docs_plugin)$(config_mcp_path) $^
103107

104108
generate-mcp-python: $(config_mcp_pb_pythons)
105109

106110
$(config_mcp_pb_pythons): $(config_mcp_protos)
107111
## Generate python/istio_api/mcp/v1alpha1/*_pb2.py
112+
@$(docker_lock) status
108113
@$(docker_gen) $(protoc_gen_python_plugin) $^
109114

110115
clean-mcp:
@@ -125,12 +130,14 @@ generate-mesh-go: $(mesh_pb_gos) $(mesh_pb_doc)
125130

126131
$(mesh_pb_gos) $(mesh_pb_doc): $(mesh_protos)
127132
## Generate mesh/v1alpha1/*.pb.go + $(mesh_pb_doc)
133+
@$(docker_lock) status
128134
@$(docker_gen) $(gogofast_plugin) $(protoc_gen_docs_plugin)$(mesh_path) $^
129135

130136
generate-mesh-python: $(mesh_pb_pythons)
131137

132138
$(mesh_pb_pythons): $(mesh_protos)
133139
## Generate python/istio_api/mesh/v1alpha1/*_pb2.py
140+
@$(docker_lock) status
134141
@$(docker_gen) $(protoc_gen_python_plugin) $^
135142

136143
clean-mesh:
@@ -173,18 +180,22 @@ generate-mixer-go: \
173180

174181
$(mixer_v1_pb_gos) $(mixer_v1_pb_doc): $(mixer_v1_protos)
175182
## Generate mixer/v1/*.pb.go + $(mixer_v1_pb_doc)
183+
@$(docker_lock) status
176184
@$(docker_gen) $(gogoslick_plugin) $(protoc_gen_docs_plugin)$(mixer_v1_path) $^
177185

178186
$(mixer_config_client_pb_gos) $(mixer_config_client_pb_doc): $(mixer_config_client_protos)
179187
## Generate mixer/v1/config/client/*.pb.go + $(mixer_config_client_pb_doc)
188+
@$(docker_lock) status
180189
@$(docker_gen) $(gogoslick_plugin) $(protoc_gen_docs_plugin)$(mixer_config_client_path) $^
181190

182191
$(mixer_adapter_model_v1beta1_pb_gos) $(mixer_adapter_model_v1beta1_pb_doc) : $(mixer_adapter_model_v1beta1_protos)
183192
## Generate mixer/adapter/model/v1beta1/*.pb.go + $(mixer_adapter_model_v1beta1_pb_doc)
193+
@$(docker_lock) status
184194
@$(docker_gen) $(gogoslick_plugin) $(protoc_gen_docs_plugin)$(mixer_adapter_model_v1beta1_path) $^
185195

186196
$(policy_v1beta1_pb_gos) $(policy_v1beta1_pb_doc) : $(policy_v1beta1_protos)
187197
## Generate policy/v1beta1/*.pb.go + $(policy_v1beta1_pb_doc)
198+
@$(docker_lock) status
188199
@$(docker_gen) $(gogoslick_plugin) $(protoc_gen_docs_plugin)$(policy_v1beta1_path) $^
189200

190201
generate-mixer-python: \
@@ -195,18 +206,22 @@ generate-mixer-python: \
195206

196207
$(mixer_v1_pb_pythons): $(mixer_v1_protos)
197208
## Generate python/istio_api/mixer/v1/*_pb2.py
209+
@$(docker_lock) status
198210
@$(docker_gen) $(protoc_gen_python_plugin) $^
199211

200212
$(mixer_config_client_pb_pythons): $(mixer_config_client_protos)
201213
## Generate python/istio_api/mixer/v1/config/client/*_pb2.py
214+
@$(docker_lock) status
202215
@$(docker_gen) $(protoc_gen_python_plugin) $^
203216

204217
$(mixer_adapter_model_v1beta1_pb_pythons): $(mixer_adapter_model_v1beta1_protos)
205218
## Generate python/istio_api/mixer/adapter/model/v1beta1/*_pb2.py
219+
@$(docker_lock) status
206220
@$(docker_gen) $(protoc_gen_python_plugin) $^
207221

208222
$(policy_v1beta1_pb_pythons): $(policy_v1beta1_protos)
209223
## Generate python/istio_api/policy/v1beta1/*_pb2.py
224+
@$(docker_lock) status
210225
@$(docker_gen) $(protoc_gen_python_plugin) $^
211226

212227
clean-mixer:
@@ -227,12 +242,14 @@ generate-routing-go: $(routing_v1alpha3_pb_gos) $(routing_v1alpha3_pb_doc)
227242

228243
$(routing_v1alpha3_pb_gos) $(routing_v1alpha3_pb_doc): $(routing_v1alpha3_protos)
229244
## Generate networking/v1alpha3/*.pb.go
245+
@$(docker_lock) status
230246
@$(docker_gen) $(gogofast_plugin) $(protoc_gen_docs_plugin)$(routing_v1alpha3_path) $^
231247

232248
generate-routing-python: $(routing_v1alpha3_pb_pythons)
233249

234250
$(routing_v1alpha3_pb_pythons): $(routing_v1alpha3_protos)
235251
## Generate python/istio_api/networking/v1alpha3/*_pb2.py
252+
@$(docker_lock) status
236253
@$(docker_gen) $(protoc_gen_python_plugin) $^
237254

238255
clean-routing:
@@ -253,12 +270,14 @@ generate-rbac-go: $(rbac_v1alpha1_pb_gos) $(rbac_v1alpha1_pb_doc)
253270

254271
$(rbac_v1alpha1_pb_gos) $(rbac_v1alpha1_pb_doc): $(rbac_v1alpha1_protos)
255272
## Generate rbac/v1alpha1/*.pb.go
273+
@$(docker_lock) status
256274
@$(docker_gen) $(gogofast_plugin) $(protoc_gen_docs_plugin)$(rbac_v1alpha1_path) $^
257275

258276
generate-rbac-python: $(rbac_v1alpha1_protos)
259277

260278
$(rbac_v1alpha1_pb_pythons): $(rbac_v1alpha1_protos)
261279
## Generate python/istio_api/rbac/v1alpha1/*_pb2.py
280+
@$(docker_lock) status
262281
@$(docker_gen) $(protoc_gen_python_plugin) $^
263282

264283
clean-rbac:
@@ -280,12 +299,14 @@ generate-authn-go: $(authn_v1alpha1_pb_gos) $(authn_v1alpha1_pb_doc)
280299

281300
$(authn_v1alpha1_pb_gos) $(authn_v1alpha1_pb_doc): $(authn_v1alpha1_protos)
282301
## Generate authentication/v1alpha1/*.pb.go
302+
@$(docker_lock) status
283303
@$(docker_gen) $(gogofast_plugin) $(protoc_gen_docs_plugin)$(authn_v1alpha1_path) $^
284304

285305
generate-authn-python: $(authn_v1alpha1_pb_pythons)
286306

287307
$(authn_v1alpha1_pb_pythons): $(authn_v1alpha1_protos)
288308
## Generate python/istio_api/authentication/v1alpha1/*_pb2.py
309+
@$(docker_lock) status
289310
@$(docker_gen) $(protoc_gen_python_plugin) $^
290311

291312
clean-authn:
@@ -306,18 +327,26 @@ generate-envoy-go: $(envoy_pb_gos) $(envoy_pb_doc)
306327
# Envoy APIs is internal APIs, documents is not required.
307328
$(envoy_pb_gos): $(envoy_protos)
308329
## Generate envoy/*/*.pb.go
330+
@$(docker_lock) status
309331
@$(docker_gen) $(gogofast_plugin) $^
310332

311333
generate-envoy-python: $(envoy_pb_pythons)
312334

313335
# Envoy APIs is internal APIs, documents is not required.
314336
$(envoy_pb_pythons): $(envoy_protos)
315337
## Generate envoy/*/*_pb2.py
338+
@$(docker_lock) status
316339
@$(docker_gen) $(protoc_gen_python_plugin) $^
317340

318341
clean-envoy:
319342
rm -f $(envoy_pb_gos)
320343

344+
#####################
345+
# Protolock
346+
#####################
347+
proto-commit:
348+
@$(docker_lock) commit
349+
321350
#####################
322351
# Cleanup
323352
#####################

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ When making changes to the protos in this repository, your changes **must** comp
1212

1313
## Updating
1414

15-
After the [protobuf](https://github.com/google/protobuf) definitions are updated, the corresponding `*pb.go` and `_pb2.py` files must be generated by running `scripts/generate-protos.sh` and submitted as part of the same PR as the updated definitions.
15+
After the [protobuf](https://github.com/google/protobuf) definitions
16+
are updated, the corresponding `*pb.go` and `_pb2.py` files must be
17+
generated by running `scripts/generate-protos.sh` and submitted as
18+
part of the same PR as the updated definitions. Also `make
19+
proto-commit` must be run to update the proto.lock file with new
20+
changes.
21+
1622

1723
If releasing a new tagged version, please update python/istio-api/setup.py version to reflect.

0 commit comments

Comments
 (0)