tyk
tyk copied to clipboard
Fix plugin build script
Description
Update plugin compiler smoke tests to align with the new changes in plugin compiler build where the plugin name has version and platform info in the name,
Also fix the plugin compiler build script - there seems to be an issue when there's an internal dependency in the go.mod
file(eg: github.com/TykTechnologies/tyk/certs
) - it causes the build to fail as it causes the the source tree to be deleted while building the plugin.
API tests result: success :white_check_mark:
Branch used: refs/pull/3998/merge
Commit:
Triggered by: pull_request (@asutosh)
Execution page
Needs a rebase.
We've used a different approach than the proposed go mod vendor
solution:
cd $TYK_SOURCE_PATH
go list -m -f '{{ if not .Main }}{{ .Path }} {{ .Version }}{{ end }}' all > dependencies.txt
# for any dependency also present in Tyk, change the module version to Tyk's version
cd $PLUGIN_SOURCE_PATH
# remove go module information
rm -rf go.mod go.sum
# initialize fresh module
go mod init mymodule
# add graphql-go-tools pinned version
go mod edit -replace github.com/jensneuse/graphql-go-tools=github.com/TykTechnologies/graphql-go-tools@$GOTOOLS_REF
# add Tyk version
go get github.com/TykTechnologies/tyk@$TYK_REF
# scan and update go dependencies
go mod tidy
# collect all plugin dependencies
go list -m -f '{{ if not .Main }}{{ .Path }} {{ .Version }}{{ end }}' all > dependencies.txt
# for any shared dependency, pin the version to Tyk gateway version
awk 'NR==FNR{seen[$1]=$2; next} seen[$1] && seen[$1] != $2' $PLUGIN_SOURCE_PATH/dependencies.txt $TYK_SOURCE_PATH/dependencies.txt | while read PKG VER; do
go mod edit -replace=$PKG=$PKG@$VER
done
This uses Go modules 'replace' behaviour to fix versions for any dependency which is shared with Tyk gateway.
By tweaking the Docker images for plugin-compiler a bit, we can ensure that listing all dependencies for Tyk gateway is done ahead of time (during the creation of the Docker image), since these dependencies are fixed for a specific version of Tyk
Hey @asutosh would you follow up on this?
https://tyktech.atlassian.net/browse/TT-6402 seems to indicate that GOOS and GOARCH cannot be overridden on the command line.
Thanks @blagerweij ! Will follow up on your suggested changes.