Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-10-10 17:09:20 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-10-10 17:10:31 +0300
commit0cd4b87513b7d76d30c2d424161d3635b13dba21 (patch)
tree937b459ccb6ede730fa7510b3c8a2cfb67f12d48 /tools/goimports
parent8751343f230ee12a009546c8e6e5ad7c3c09db61 (diff)
Makefile: Track Go tool versions via separate Go modules
Right now we track versions of our Go tooling directly in our Makefile. While this is simple, it has several drawbacks: - We're susceptible to supply-chain attacks in case an adversary manages to replace the code used to build any of our tools. - We cannot use proper dependencies in our Makefile, which adds the need for `*.version` files. - It is hard to build the tools outside of our Makefile as we don't have a way to properly pull in the correct version. - Upgrading our tooling requires us to manually hunt down new releases for all of our tools. We can fix these issues by following the approach that is efficially recommended by the Go project [1]: every tool has its own Go module in `tools/` with a "tool.go" file that imports the tool of interest. Like this we can use Go's normal tooling to keep track of versions: - We record hashes of the tool's sources as well as all of its dependencies, making supply-chain attacks almost impossible. - We can now provide proper dependencies in our Makefile: every tool depends on "tool.go", "go.mod" and "go.sum". If any of them changes we need to rebuild. - The tools can be installed in the correct version simply by using `go install` with the correct `go.mod` file. - Upgrading tools is as simple as running `go get -u`, so no more manual hunting for new versions. While these benefits are great on their own already, we can go even further with this refactoring: now that each tool has its own `go.mod` file we can adapt the Renovate bot to pick up these files. This means that we don't have to remember upgrading at all anymore, but instead the bot will automatically upgrade them for us. [1]: https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module
Diffstat (limited to 'tools/goimports')
-rw-r--r--tools/goimports/go.mod10
-rw-r--r--tools/goimports/go.sum31
-rw-r--r--tools/goimports/tool.go5
3 files changed, 46 insertions, 0 deletions
diff --git a/tools/goimports/go.mod b/tools/goimports/go.mod
new file mode 100644
index 000000000..5235db9e3
--- /dev/null
+++ b/tools/goimports/go.mod
@@ -0,0 +1,10 @@
+module gitlab.com/gitlab-org/gitaly/tools/goimports
+
+go 1.17
+
+require golang.org/x/tools v0.1.10
+
+require (
+ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
+ golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 // indirect
+)
diff --git a/tools/goimports/go.sum b/tools/goimports/go.sum
new file mode 100644
index 000000000..67cbb3158
--- /dev/null
+++ b/tools/goimports/go.sum
@@ -0,0 +1,31 @@
+github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
+golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
+golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
+golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 h1:v6hYoSR9T5oet+pMXwUWkbiVqx/63mlHjefrHmxwfeY=
+golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.1.10 h1:QjFRCZxdOhBJ/UNgnBZLbNV13DlbnK0quyivTnXJM20=
+golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
+golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
diff --git a/tools/goimports/tool.go b/tools/goimports/tool.go
new file mode 100644
index 000000000..fff59ac0a
--- /dev/null
+++ b/tools/goimports/tool.go
@@ -0,0 +1,5 @@
+package gofumpt
+
+import (
+ _ "golang.org/x/tools/cmd/goimports"
+)