istio-operator
istio-operator copied to clipboard
API in release-1.11 not usable (protobuf dependency)
Describe the bug The protobuf marshaller referenced by the API module is not compatible.
Steps to reproduce the issue:
- Create a project and add
require github.com/banzaicloud/istio-operator/api/v2 v2.0.0-20211217152025-f1b654fb609f
to your go.mod. - Use IstioMeshGateway struct in your code.
- Compiling will ultimately fail.
Expected behavior Compiling should succeed.
Additional context Line in question is https://github.com/banzaicloud/istio-operator/blob/f1b654fb609ffe8360bace8ed5fda08cc8c692c2/api/v1alpha1/common_json.gen.go#L225 .
Maybe it would be a good idea to exclude the gogo/protobuf in all your go.mod and require the waynz0r/protobuf as a dependency in the API go.mod.
Workaround
add a replace github.com/gogo/protobuf => github.com/waynz0r/protobuf v1.3.3-0.20210811122234-64636cae0910
to your project's go.mod.
Hi @Tanemahuta,
Thanks for raising this issue!
I think you have a completely valid point that it would be nice if the API was usable without any replace directives.
The thing is though that I think we cannot easily require waynz0r/protobuf
instead of gogo/protobuf
in the API go.mod, because gogo/protobuf
is used in a lot of generated GO files in the api/v1alpha1
directory. So the code generation should be changed accordingly to generate GO files with waynz0r/protobuf
usage, which does not seem trivial to me, we might need to fork GO file generator lib as well or do some other hackish stuff, but I don't think that's the best way to go.
I'd rather consult with @waynz0r about this fork whether we need to keep it or is there a better workaround to handle this dependency. @waynz0r could you please take a look at this once you are back and whenever have time?
All fine. In the meantime adding that replace directive to the go.mod of the API would be nice 🙌 thank you
All fine. In the meantime adding that replace directive to the go.mod of the API would be nice 🙌 thank you
Unfortunately, it doesn't work like that. The other dependencies used in the API go.mod use the gogo/protobuf
lib and because of that even when replace github.com/gogo/protobuf => github.com/waynz0r/protobuf v1.3.3-0.20210811122234-64636cae0910
is added to the API go.mod, those other dependencies require
gogo/protobuf
in their own go.mod and since waynz0r/protobuf
has the same go module name as gogo/protobuf
at the end of the day it won't be replaced in your project unless you explicitly replace it.
➜ go mod graph | grep "github.com/gogo/[email protected]"
...
istio.io/[email protected] github.com/gogo/[email protected]
istio.io/[email protected] github.com/gogo/[email protected]
Let us know if you can make it work somehow, but I'm afraid the reality is that you need to replace it in your own project for now.
We either fork those other repos and make sure that the forks are used everywhere from the API (which is a way I don't want to go) or find a solution to omit our fork altogether.
True, I forgot about replace not being transient. Meh. A pity. At least there's a solution and it can be found when searching through the issues.
@Tanemahuta, this was fixed here for the release-1.15
branch.
Reopening because of this PR: https://github.com/banzaicloud/istio-operator/pull/868