Skip to content

Commit

Permalink
Upgrade generator and runtime versions (grpc-ecosystem#889)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
johanbrandhorst authored Mar 2, 2019
1 parent cc6fc94 commit 15c52a7
Show file tree
Hide file tree
Showing 24 changed files with 101 additions and 101 deletions.
6 changes: 3 additions & 3 deletions .circleci/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.11
FROM golang:1.12

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

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

# Install node
ENV NODE_VERSION=v6.1
ENV NODE_VERSION=v10.15.2
RUN apt-get install -y wget bzip2 && \
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash && \
apt-get remove -y wget
Expand Down
2 changes: 1 addition & 1 deletion .circleci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Contained within is the CI test setup for the Gateway. It runs on Circle CI.
Great, it should be as simple as thus (run from the root of the directory):

```bash
$ docker run -v $(pwd):/go/src/github.com/grpc-ecosystem/grpc-gateway --rm jfbrandhorst/grpc-gateway-build-env \
$ docker run -v $(pwd):/go/src/github.com/grpc-ecosystem/grpc-gateway --rm jfbrandhorst/grpc-gateway-build-env:1.12 \
/bin/bash -c 'cd /go/src/github.com/grpc-ecosystem/grpc-gateway && \
make realclean && \
make examples SWAGGER_CODEGEN="${SWAGGER_CODEGEN}"'
Expand Down
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ version: 2
jobs:
build:
docker:
- image: jfbrandhorst/grpc-gateway-build-env
- image: jfbrandhorst/grpc-gateway-build-env:1.12
working_directory: /src/grpc-gateway
steps:
- checkout
- run: go build ./...
test:
docker:
- image: jfbrandhorst/grpc-gateway-build-env
- image: jfbrandhorst/grpc-gateway-build-env:1.12
working_directory: /src/grpc-gateway
environment:
GLOG_logtostderr: '1'
Expand All @@ -19,7 +19,7 @@ jobs:
- run: bash <(curl -s https://codecov.io/bash)
node_test:
docker:
- image: jfbrandhorst/grpc-gateway-build-env
- image: jfbrandhorst/grpc-gateway-build-env:1.12
working_directory: /src/grpc-gateway
steps:
- checkout
Expand All @@ -32,7 +32,7 @@ jobs:
./node_modules/.bin/gulp
generate:
docker:
- image: jfbrandhorst/grpc-gateway-build-env
- image: jfbrandhorst/grpc-gateway-build-env:1.12
working_directory: /src/grpc-gateway
steps:
- checkout
Expand All @@ -42,7 +42,7 @@ jobs:
- run: git diff --exit-code
lint:
docker:
- image: jfbrandhorst/grpc-gateway-build-env
- image: jfbrandhorst/grpc-gateway-build-env:1.12
working_directory: /src/grpc-gateway
steps:
- checkout
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
when: always
release:
docker:
- image: jfbrandhorst/grpc-gateway-build-env
- image: jfbrandhorst/grpc-gateway-build-env:1.12
working_directory: /src/grpc-gateway
steps:
- checkout
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ All submissions, including submissions by project members, require review.
Great, it should be as simple as thus (run from the root of the directory):

```bash
docker run -v $(pwd):/src/grpc-gateway --rm jfbrandhorst/grpc-gateway-build-env \
docker run -v $(pwd):/src/grpc-gateway --rm jfbrandhorst/grpc-gateway-build-env:1.12 \
/bin/bash -c 'cd /src/grpc-gateway && \
make realclean && \
make examples SWAGGER_CODEGEN="${SWAGGER_CODEGEN}"'
Expand Down
8 changes: 4 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

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

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

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
Expand Down
2 changes: 1 addition & 1 deletion examples/clients/abe/protobuf_field_mask.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

package abe

// 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.
// 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.
type ProtobufFieldMask struct {

// The set of field mask paths.
Expand Down
2 changes: 1 addition & 1 deletion examples/proto/examplepb/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ go_proto_library(
name = "examplepb_go_proto",
compilers = [
"@io_bazel_rules_go//proto:go_grpc",
"//protoc-gen-grpc-gateway:go_gen_grpc_gateway",
"//protoc-gen-grpc-gateway:go_gen_grpc_gateway", # keep
],
importpath = "github.com/grpc-ecosystem/grpc-gateway/examples/proto/examplepb",
proto = ":examplepb_proto",
Expand Down
Loading

0 comments on commit 15c52a7

Please sign in to comment.