How to actually decide the version of GitHub - TykTechnologies/tyk: Tyk Open Source API Gateway written in Go, supporting REST, GraphQL, TCP and gRPC protocols v1.7.0-rc9 in the go.mod for building a custom go plugin? Let’s say my tyk-gateway is of version 5.2.2.
How to actually decide the version of github.com/TykTechnologies/tyk v1.7.0-rc9 for go custom plugin
Hi,
I’m not sure what you’re asking but is it for the commit hash for the go get
command?
If so then this is how I get it. From a local clone of the tyk repo:
$ git show-ref tags/v5.2.2
af872f97490afc87137bfc5a340e60df85e2e01f refs/tags/v5.2.2
So the go get
command would be
go get github.com/TykTechnologies/tyk@af872f97490afc87137bfc5a340e60df85e2e01f
From 5.2.3 it’s possible to have the plugin compiler do this during the build by running the container with -e GO_GET=1
Similarly from 5.2.3 it’s possible to also set -e GO_TIDY=1
to have the container run the go mod tidy
as well.
Here’s a sample invocation with all of that included. The final parameter $(date +%s)
returns the epoch seconds (on Linux so please correct for your OS) which ensures that the plugin internal ID is unique. This helps with ensuring you don’t get the annoying ‘plugin is already loaded’ error.
docker container run -e GO_GET=1 -e GO_TIDY=1 -v $PWD:/plugin-source --rm tykio/tyk-plugin-compiler:v5.2.5 tyk_plugin.so $(date +%s)
Cheers,
Pete
is there any workaround similar to that if I use 5.2.2 version for the gateway? Because we have two separate environment, one is 5.2.5 for the local development and the other one is 5.2.2 for the production.
is there any way to get the commit hash direclty in the build server for a certain tag without cloning the repo? Or for version 5.2.2 or below, I should set the commit hash manually?