This can be done as a separate change when needed.
Also should analyze if this would affect the gogo
incompatibility issues with newer proto.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This patch updates the script and Dockerfile to prevent issues when using go
modules.
The first change is to use a plain `git clone` instead of `go get -d` to download
the source. While (like "pre go-modules") `go get -d` won't *build* the binaries
when go modules are used, it *will* use go modules to download the package
(and dependencies); as a result:
- no git repository will be cloned in gopath
- go modules will be downloaded for "master" (not the version that we specify
to build)
Note: Once we update to Go 1.16, this script could be updated to use `go install <repo>@version`
The second change is an update to the `update-generated-files` script to detect
the correct version of google/protobuf to use from the `go.mod`'s `replace` rule,
to make sure we generate (and verify) using the correct version.
The Dockerfile was also updated to update the default versions specified in the
PROTOBUF_VERSION and GOGO_VERSION build-args (although not strictly necessary).
Regenerating the files with this version resulted in a minor formatting change.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Modelled after the vendor support provide a validator and an updator for files
produced by `go generate` (which today just means `*.pb.go`).
Main difference from the vendor support is that we are no longer simply nuking
and replacing a single directory, so I ended up hardcoding `*.pb.go` in a bunch
of places which I don't like but cannot see a way around which doesn't risk
nuking people's other local changes.
The generated files are placed in an unpacked form in a `FROM scratch`
container for update. Use a subdirectory and `tar --strip-components` (portable
to MacOS and Linux according to `tar(1)`) since trying to do a `docker export`
of just the root ends up adding `.dockerenv`, `sys`, `proc` and `dev` to the
source tree.
The validate container is not `FROM scratch` because we want `cat`.
The run in `frontend/gateway/pb/generate.go` was missing an include so fix
that.
The versions of `protoc` and the gogo plugins were chosen to regenerate the
existing code as closely as possible. The updates to `*.pg.go` here are all the
result of regenerating with go1.9 which fixed
https://github.com/golang/go/issues/17663 and replaced an invalid timestamp in
the gzip header of the data encoded in `fileDescriptor*`, and adopted a new
standard for marking generated files.
Finally, I noticed that my `docker run`s were missing an `--rm` which I
inherited from `validate-vendor`, so fix all those.
Closes: #322
Signed-off-by: Ian Campbell <ijc@docker.com>