Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transition to use golang/protobuf to support automated code generation #226

Merged
merged 10 commits into from
Sep 10, 2019

Conversation

kyessenov
Copy link
Contributor

Fixes #213

Warning This is a breaking change due to the switch from gogo/protobuf to golang/protobuf. Please use branch gogo if you would like to continue using gogo/protobuf.

kyessenov and others added 10 commits September 9, 2019 10:53
Signed-off-by: Kuat Yessenov <kuat@google.com>
Signed-off-by: Kuat Yessenov <kuat@google.com>
Signed-off-by: Kuat Yessenov <kuat@google.com>
Signed-off-by: Kuat Yessenov <kuat@google.com>
Signed-off-by: Kuat Yessenov <kuat@google.com>
Signed-off-by: Kuat Yessenov <kuat@google.com>
Signed-off-by: Kuat Yessenov <kuat@google.com>
Needed to be compatible with internal build rules.

Signed-off-by: Teju Nareddy <nareddyt@google.com>
Signed-off-by: Kuat Yessenov <kuat@google.com>
Signed-off-by: Kuat Yessenov <kuat@google.com>
Signed-off-by: Kuat Yessenov <kuat@google.com>
@@ -1,3 +0,0 @@
[submodule "data-plane-api"]
path = data-plane-api
url = https://github.com/envoyproxy/data-plane-api
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?? why remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stubs will be pushed from envoy repo directly. I want to have the first commit done manually before I automate the pushes since we still need to validate go module build (which bazel doesn't do).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@yangminzhu yangminzhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not following with the changes so just some questions to learn about the change, do we need to run generate_go_protobuf.py manually to generate all these go files in this repo? Or is it done by some bots automatically? If so how often is it pushed? Thanks

@kyessenov
Copy link
Contributor Author

This PR was done by manually running the script. The automation is a follow-up. The script will be triggered by any change to APIs.

@jyotimahapatra
Copy link
Contributor

jyotimahapatra commented Sep 17, 2019

@kyessenov I am trying this out with my sample control plane which was working before this change.
I am getting errors like this

./main.go:13:2: imported and not used: "github.com/envoyproxy/go-control-plane/envoy/api/v2/auth" as envoy_api_v2_auth
./main.go:14:2: imported and not used: "github.com/envoyproxy/go-control-plane/envoy/api/v2/core" as envoy_api_v2_core
./main.go:15:2: imported and not used: "github.com/envoyproxy/go-control-plane/envoy/api/v2/route" as envoy_api_v2_route
./main.go:24:11: undefined: core
./main.go:31:24: undefined: core
./main.go:96:8: undefined: core
./main.go:108:3: cannot use &duration (type *time.Duration) as type *duration.Duration in field value
./main.go:111:28: undefined: core
./main.go:112:26: undefined: auth
./main.go:117:20: undefined: route
./main.go:117:20: too many errors

Is there an easy way to fix this?

@kyessenov
Copy link
Contributor Author

Name every import, e.g.

import (
  auth "github.com/envoyproxy/go-control-plane/envoy/api/v2/auth"
)

@jyotimahapatra
Copy link
Contributor

jyotimahapatra commented Sep 17, 2019

@kyessenov
I tried that, but this doesn't work

v2 "github.com/envoyproxy/go-control-plane/envoy/api/v2"
"github.com/gogo/protobuf/jsonpb"
"github.com/gogo/protobuf/proto"
..
..
xDS := map[string]proto.Message{
                "rds": &v2.RouteConfiguration{},
                "cds": &v2.Cluster{},
        }

./tools/xds-validator/xds-validator -t rds -p generated/routes/ file: xyz.json error: unknown field "exact_match" in envoy_api_v2_route.HeaderMatcher

@kyessenov
Copy link
Contributor Author

Please use golang/protobuf/jsonpb and not gogo/protobuf/jsonpb to parse JSON into golang/protos.

@jyotimahapatra
Copy link
Contributor

jyotimahapatra commented Sep 18, 2019

Thank you @kyessenov . While I was migrating all usages of gogo to golang, my project's glide up failed with this piece of error

^[[0;32m[INFO]  ^[[m--> Setting version for github.com/envoyproxy/go-control-plane to v0.9.0.
[DEBUG] Unlocking git-gh.neting.cc-lyft-go-analytics
[DEBUG] Unlocking https-gh.neting.cc-onsi-gomega
^[[0;32m[INFO]  ^[[m--> Setting version for github.com/golang/protobuf to v1.3.2.
...
...
...
[DEBUG] Trying to open github.com/envoyproxy/go-control-plane/envoy/api/v2 (/Users/jmahapatra/.glide/cache/src/https-gh.neting.cc-envoyproxy-go-control-plane/envoy/api/v2)
[DEBUG] Package github.com/envoyproxy/go-control-plane/envoy/api/v2 imports github.com/envoyproxy/go-control-plane/envoy/api/v2/auth
[DEBUG] In vendor: github.com/envoyproxy/go-control-plane/envoy/api/v2/auth
[DEBUG] Package github.com/envoyproxy/go-control-plane/envoy/api/v2 imports github.com/envoyproxy/go-control-plane/envoy/api/v2/cluster
[DEBUG] In vendor: github.com/envoyproxy/go-control-plane/envoy/api/v2/cluster
[DEBUG] Package github.com/envoyproxy/go-control-plane/envoy/api/v2 imports github.com/envoyproxy/go-control-plane/envoy/api/v2/core
[DEBUG] In vendor: github.com/envoyproxy/go-control-plane/envoy/api/v2/core
[DEBUG] Package github.com/envoyproxy/go-control-plane/envoy/api/v2 imports github.com/envoyproxy/go-control-plane/envoy/api/v2/endpoint
[DEBUG] In vendor: github.com/envoyproxy/go-control-plane/envoy/api/v2/endpoint
[DEBUG] Package github.com/envoyproxy/go-control-plane/envoy/api/v2 imports github.com/envoyproxy/go-control-plane/envoy/api/v2/listener
[DEBUG] In vendor: github.com/envoyproxy/go-control-plane/envoy/api/v2/listener
[DEBUG] Package github.com/envoyproxy/go-control-plane/envoy/api/v2 imports github.com/envoyproxy/go-control-plane/envoy/api/v2/route
[DEBUG] In vendor: github.com/envoyproxy/go-control-plane/envoy/api/v2/route
[DEBUG] Package github.com/envoyproxy/go-control-plane/envoy/api/v2 imports github.com/envoyproxy/go-control-plane/envoy/type
[DEBUG] In vendor: github.com/envoyproxy/go-control-plane/envoy/type
[DEBUG] Package github.com/envoyproxy/go-control-plane/envoy/api/v2 imports github.com/envoyproxy/protoc-gen-validate/validate
[DEBUG] In vendor: github.com/envoyproxy/protoc-gen-validate/validate
[DEBUG] Marking github.com/envoyproxy/protoc-gen-validate/validate to be scanned.
^[[0;32m[INFO]  ^[[m--> Fetching updates for github.com/envoyproxy/protoc-gen-validate
[DEBUG] Package github.com/envoyproxy/go-control-plane/envoy/api/v2 imports github.com/golang/protobuf/proto
[DEBUG] In vendor: github.com/golang/protobuf/proto
[DEBUG] Marking github.com/golang/protobuf/proto to be scanned.
[DEBUG] Dependency github.com/golang/protobuf has already been pinned. Fetching updates skipped
^[[0;32m[INFO]  ^[[m--> Setting version for github.com/golang/protobuf to v1.1.0.
.....
.....
.....
[[0;31m[ERROR] ^[[mFailed to generate lock file: Generating lock produced conflicting versions of github.com/golang/protobuf. import (v1.1.0), testImport (v1.3.2)

Is it something because of this ? or is it a mistake on my part?

@kyessenov
Copy link
Contributor Author

It could be, but I'm not an expert in the interplay between glide and go mod. If you have a suggestion, we can merge a fix here.

@jyotimahapatra
Copy link
Contributor

@kyessenov You've been immensely helpful and we could finally migrate from go-control-plane v0.8.0 to v0.9.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace gogo protobuf with golang protobuf
5 participants