Skip to content

Commit 15c52a7

Browse files
Upgrade generator and runtime versions (#889)
* Upgrade generator and runtime versions Go 1.12 Node 10.15.2 Protoc 3.7.0 Swagger Codegen 2.4.2 * Fix vet error discovered by Go 1.12 * Regenerate protofiles with protoc 3.7.0 * Update expected error in when specifying incorrect flags Apparently this message changed with Go 1.12 * Use explicit versioning of build environment in docker commands
1 parent cc6fc94 commit 15c52a7

24 files changed

+101
-101
lines changed

.circleci/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.11
1+
FROM golang:1.12
22

33
## Warm apt cache
44
RUN apt-get update
@@ -12,7 +12,7 @@ RUN apt-get install -y openjdk-8-jre wget && \
1212
ENV SWAGGER_CODEGEN="java -jar /usr/local/bin/swagger-codegen-cli.jar"
1313

1414
# Install protoc
15-
ENV PROTOC_VERSION=3.1.0
15+
ENV PROTOC_VERSION=3.7.0
1616
RUN apt-get install -y wget unzip && \
1717
wget https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip \
1818
-O /protoc-${PROTOC_VERSION}-linux-x86_64.zip && \
@@ -21,7 +21,7 @@ RUN apt-get install -y wget unzip && \
2121
apt-get remove -y unzip wget
2222

2323
# Install node
24-
ENV NODE_VERSION=v6.1
24+
ENV NODE_VERSION=v10.15.2
2525
RUN apt-get install -y wget bzip2 && \
2626
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash && \
2727
apt-get remove -y wget

.circleci/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Contained within is the CI test setup for the Gateway. It runs on Circle CI.
77
Great, it should be as simple as thus (run from the root of the directory):
88

99
```bash
10-
$ docker run -v $(pwd):/go/src/github.com/grpc-ecosystem/grpc-gateway --rm jfbrandhorst/grpc-gateway-build-env \
10+
$ docker run -v $(pwd):/go/src/github.com/grpc-ecosystem/grpc-gateway --rm jfbrandhorst/grpc-gateway-build-env:1.12 \
1111
/bin/bash -c 'cd /go/src/github.com/grpc-ecosystem/grpc-gateway && \
1212
make realclean && \
1313
make examples SWAGGER_CODEGEN="${SWAGGER_CODEGEN}"'

.circleci/config.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ version: 2
22
jobs:
33
build:
44
docker:
5-
- image: jfbrandhorst/grpc-gateway-build-env
5+
- image: jfbrandhorst/grpc-gateway-build-env:1.12
66
working_directory: /src/grpc-gateway
77
steps:
88
- checkout
99
- run: go build ./...
1010
test:
1111
docker:
12-
- image: jfbrandhorst/grpc-gateway-build-env
12+
- image: jfbrandhorst/grpc-gateway-build-env:1.12
1313
working_directory: /src/grpc-gateway
1414
environment:
1515
GLOG_logtostderr: '1'
@@ -19,7 +19,7 @@ jobs:
1919
- run: bash <(curl -s https://codecov.io/bash)
2020
node_test:
2121
docker:
22-
- image: jfbrandhorst/grpc-gateway-build-env
22+
- image: jfbrandhorst/grpc-gateway-build-env:1.12
2323
working_directory: /src/grpc-gateway
2424
steps:
2525
- checkout
@@ -32,7 +32,7 @@ jobs:
3232
./node_modules/.bin/gulp
3333
generate:
3434
docker:
35-
- image: jfbrandhorst/grpc-gateway-build-env
35+
- image: jfbrandhorst/grpc-gateway-build-env:1.12
3636
working_directory: /src/grpc-gateway
3737
steps:
3838
- checkout
@@ -42,7 +42,7 @@ jobs:
4242
- run: git diff --exit-code
4343
lint:
4444
docker:
45-
- image: jfbrandhorst/grpc-gateway-build-env
45+
- image: jfbrandhorst/grpc-gateway-build-env:1.12
4646
working_directory: /src/grpc-gateway
4747
steps:
4848
- checkout
@@ -76,7 +76,7 @@ jobs:
7676
when: always
7777
release:
7878
docker:
79-
- image: jfbrandhorst/grpc-gateway-build-env
79+
- image: jfbrandhorst/grpc-gateway-build-env:1.12
8080
working_directory: /src/grpc-gateway
8181
steps:
8282
- checkout

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ All submissions, including submissions by project members, require review.
2424
Great, it should be as simple as thus (run from the root of the directory):
2525

2626
```bash
27-
docker run -v $(pwd):/src/grpc-gateway --rm jfbrandhorst/grpc-gateway-build-env \
27+
docker run -v $(pwd):/src/grpc-gateway --rm jfbrandhorst/grpc-gateway-build-env:1.12 \
2828
/bin/bash -c 'cd /src/grpc-gateway && \
2929
make realclean && \
3030
make examples SWAGGER_CODEGEN="${SWAGGER_CODEGEN}"'

WORKSPACE

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
55

66
http_archive(
77
name = "io_bazel_rules_go",
8-
sha256 = "492c3ac68ed9dcf527a07e6a1b2dcbf199c6bf8b35517951467ac32e421c06c1",
9-
urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.17.0/rules_go-0.17.0.tar.gz"],
8+
sha256 = "6776d68ebb897625dead17ae510eac3d5f6342367327875210df44dbe2aeeb19",
9+
urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.17.1/rules_go-0.17.1.tar.gz"],
1010
)
1111

1212
http_archive(
1313
name = "bazel_gazelle",
14-
sha256 = "7949fc6cc17b5b191103e97481cf8889217263acf52e00b560683413af204fcb",
15-
urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/0.16.0/bazel-gazelle-0.16.0.tar.gz"],
14+
sha256 = "3c681998538231a2d24d0c07ed5a7658cb72bfb5fd4bf9911157c0e9ac6a2687",
15+
urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/0.17.0/bazel-gazelle-0.17.0.tar.gz"],
1616
)
1717

1818
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

examples/clients/abe/protobuf_field_mask.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
package abe
1212

13-
// paths: \"f.a\" paths: \"f.b.d\" Here `f` represents a field in some root message, `a` and `b` fields in the message found in `f`, and `d` a field found in the message in `f.b`. Field masks are used to specify a subset of fields that should be returned by a get operation or modified by an update operation. Field masks also have a custom JSON encoding (see below). # Field Masks in Projections When used in the context of a projection, a response message or sub-message is filtered by the API to only contain those fields as specified in the mask. For example, if the mask in the previous example is applied to a response message as follows: f { a : 22 b { d : 1 x : 2 } y : 13 } z: 8 The result will not contain specific values for fields x,y and z (their value will be set to the default, and omitted in proto text output): f { a : 22 b { d : 1 } } A repeated field is not allowed except at the last position of a paths string. If a FieldMask object is not present in a get operation, the operation applies to all fields (as if a FieldMask of all fields had been specified). Note that a field mask does not necessarily apply to the top-level response message. In case of a REST get operation, the field mask applies directly to the response, but in case of a REST list operation, the mask instead applies to each individual message in the returned resource list. In case of a REST custom method, other definitions may be used. Where the mask applies will be clearly documented together with its declaration in the API. In any case, the effect on the returned resource/resources is required behavior for APIs. # Field Masks in Update Operations A field mask in update operations specifies which fields of the targeted resource are going to be updated. The API is required to only change the values of the fields as specified in the mask and leave the others untouched. If a resource is passed in to describe the updated values, the API ignores the values of all fields not covered by the mask. If a repeated field is specified for an update operation, the existing repeated values in the target resource will be overwritten by the new values. Note that a repeated field is only allowed in the last position of a `paths` string. If a sub-message is specified in the last position of the field mask for an update operation, then the existing sub-message in the target resource is overwritten. Given the target message: f { b { d : 1 x : 2 } c : 1 } And an update message: f { b { d : 10 } } then if the field mask is: paths: \"f.b\" then the result will be: f { b { d : 10 } c : 1 } However, if the update mask was: paths: \"f.b.d\" then the result would be: f { b { d : 10 x : 2 } c : 1 } In order to reset a field's value to the default, the field must be in the mask and set to the default value in the provided resource. Hence, in order to reset all fields of a resource, provide a default instance of the resource and set all fields in the mask, or do not provide a mask as described below. If a field mask is not present on update, the operation applies to all fields (as if a field mask of all fields has been specified). Note that in the presence of schema evolution, this may mean that fields the client does not know and has therefore not filled into the request will be reset to their default. If this is unwanted behavior, a specific service may require a client to always specify a field mask, producing an error if not. As with get operations, the location of the resource which describes the updated values in the request message depends on the operation kind. In any case, the effect of the field mask is required to be honored by the API. ## Considerations for HTTP REST The HTTP kind of an update operation which uses a field mask must be set to PATCH instead of PUT in order to satisfy HTTP semantics (PUT must only be used for full updates). # JSON Encoding of Field Masks In JSON, a field mask is encoded as a single string where paths are separated by a comma. Fields name in each path are converted to/from lower-camel naming conventions. As an example, consider the following message declarations: message Profile { User user = 1; Photo photo = 2; } message User { string display_name = 1; string address = 2; } In proto a field mask for `Profile` may look as such: mask { paths: \"user.display_name\" paths: \"photo\" } In JSON, the same mask is represented as below: { mask: \"user.displayName,photo\" } # Field Masks and Oneof Fields Field masks treat fields in oneofs just as regular fields. Consider the following message: message SampleMessage { oneof test_oneof { string name = 4; SubMessage sub_message = 9; } } The field mask can be: mask { paths: \"name\" } Or: mask { paths: \"sub_message\" } Note that oneof type names (\"test_oneof\" in this case) cannot be used in paths.
13+
// paths: \"f.a\" paths: \"f.b.d\" Here `f` represents a field in some root message, `a` and `b` fields in the message found in `f`, and `d` a field found in the message in `f.b`. Field masks are used to specify a subset of fields that should be returned by a get operation or modified by an update operation. Field masks also have a custom JSON encoding (see below). # Field Masks in Projections When used in the context of a projection, a response message or sub-message is filtered by the API to only contain those fields as specified in the mask. For example, if the mask in the previous example is applied to a response message as follows: f { a : 22 b { d : 1 x : 2 } y : 13 } z: 8 The result will not contain specific values for fields x,y and z (their value will be set to the default, and omitted in proto text output): f { a : 22 b { d : 1 } } A repeated field is not allowed except at the last position of a paths string. If a FieldMask object is not present in a get operation, the operation applies to all fields (as if a FieldMask of all fields had been specified). Note that a field mask does not necessarily apply to the top-level response message. In case of a REST get operation, the field mask applies directly to the response, but in case of a REST list operation, the mask instead applies to each individual message in the returned resource list. In case of a REST custom method, other definitions may be used. Where the mask applies will be clearly documented together with its declaration in the API. In any case, the effect on the returned resource/resources is required behavior for APIs. # Field Masks in Update Operations A field mask in update operations specifies which fields of the targeted resource are going to be updated. The API is required to only change the values of the fields as specified in the mask and leave the others untouched. If a resource is passed in to describe the updated values, the API ignores the values of all fields not covered by the mask. If a repeated field is specified for an update operation, new values will be appended to the existing repeated field in the target resource. Note that a repeated field is only allowed in the last position of a `paths` string. If a sub-message is specified in the last position of the field mask for an update operation, then new value will be merged into the existing sub-message in the target resource. For example, given the target message: f { b { d: 1 x: 2 } c: [1] } And an update message: f { b { d: 10 } c: [2] } then if the field mask is: paths: [\"f.b\", \"f.c\"] then the result will be: f { b { d: 10 x: 2 } c: [1, 2] } An implementation may provide options to override this default behavior for repeated and message fields. In order to reset a field's value to the default, the field must be in the mask and set to the default value in the provided resource. Hence, in order to reset all fields of a resource, provide a default instance of the resource and set all fields in the mask, or do not provide a mask as described below. If a field mask is not present on update, the operation applies to all fields (as if a field mask of all fields has been specified). Note that in the presence of schema evolution, this may mean that fields the client does not know and has therefore not filled into the request will be reset to their default. If this is unwanted behavior, a specific service may require a client to always specify a field mask, producing an error if not. As with get operations, the location of the resource which describes the updated values in the request message depends on the operation kind. In any case, the effect of the field mask is required to be honored by the API. ## Considerations for HTTP REST The HTTP kind of an update operation which uses a field mask must be set to PATCH instead of PUT in order to satisfy HTTP semantics (PUT must only be used for full updates). # JSON Encoding of Field Masks In JSON, a field mask is encoded as a single string where paths are separated by a comma. Fields name in each path are converted to/from lower-camel naming conventions. As an example, consider the following message declarations: message Profile { User user = 1; Photo photo = 2; } message User { string display_name = 1; string address = 2; } In proto a field mask for `Profile` may look as such: mask { paths: \"user.display_name\" paths: \"photo\" } In JSON, the same mask is represented as below: { mask: \"user.displayName,photo\" } # Field Masks and Oneof Fields Field masks treat fields in oneofs just as regular fields. Consider the following message: message SampleMessage { oneof test_oneof { string name = 4; SubMessage sub_message = 9; } } The field mask can be: mask { paths: \"name\" } Or: mask { paths: \"sub_message\" } Note that oneof type names (\"test_oneof\" in this case) cannot be used in paths. ## Field Mask Verification The implementation of any API method which has a FieldMask type field in the request should verify the included field paths, and return an `INVALID_ARGUMENT` error if any path is duplicated or unmappable.
1414
type ProtobufFieldMask struct {
1515

1616
// The set of field mask paths.

examples/proto/examplepb/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ go_proto_library(
4040
name = "examplepb_go_proto",
4141
compilers = [
4242
"@io_bazel_rules_go//proto:go_grpc",
43-
"//protoc-gen-grpc-gateway:go_gen_grpc_gateway",
43+
"//protoc-gen-grpc-gateway:go_gen_grpc_gateway", # keep
4444
],
4545
importpath = "github.com/grpc-ecosystem/grpc-gateway/examples/proto/examplepb",
4646
proto = ":examplepb_proto",

0 commit comments

Comments
 (0)