Skip to content

Commit da267f1

Browse files
authored
Merge pull request #20748 from ivanvc/use-gomodguard-to-forbid-dependencies
Use gomodguard to forbid dependencies
2 parents 682d4fb + 3062d2b commit da267f1

File tree

17 files changed

+84
-54
lines changed

17 files changed

+84
-54
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ fuzz:
9999
verify: verify-gofmt verify-bom verify-lint verify-dep verify-shellcheck verify-goword \
100100
verify-govet verify-license-header verify-mod-tidy \
101101
verify-shellws verify-proto-annotations verify-genproto verify-yamllint \
102-
verify-govet-shadow verify-markdown-marker verify-go-versions
102+
verify-govet-shadow verify-markdown-marker verify-go-versions verify-gomodguard
103103

104104
.PHONY: fix
105105
fix: fix-bom fix-lint fix-yamllint sync-toolchain-directive
@@ -233,6 +233,10 @@ clean:
233233
verify-go-versions:
234234
./scripts/verify_go_versions.sh
235235

236+
.PHONY: verify-gomodguard
237+
verify-gomodguard:
238+
PASSES="gomodguard" ./scripts/test.sh
239+
236240
.PHONY: sync-toolchain-directive
237241
sync-toolchain-directive:
238242
./scripts/sync_go_toolchain_directive.sh

api/.gomodguard.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
blocked:
3+
modules:
4+
- go.etcd.io/etcd:
5+
reason: "Forbidden dependency"
6+
- go.etcd.io/etcd/api/v3:
7+
reason: "Forbidden dependency"
8+
- go.etcd.io/etcd/pkg/v3:
9+
reason: "Forbidden dependency"
10+
- go.etcd.io/etcd/tests/v3:
11+
reason: "Forbidden dependency"
12+
- go.etcd.io/etcd/v3:
13+
reason: "Forbidden dependency"

api/go.mod

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,3 @@ require (
2626
google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 // indirect
2727
gopkg.in/yaml.v3 v3.0.1 // indirect
2828
)
29-
30-
// Bad imports are sometimes causing attempts to pull that code.
31-
// This makes the error more explicit.
32-
replace (
33-
go.etcd.io/etcd => ./FORBIDDEN_DEPENDENCY
34-
go.etcd.io/etcd/api/v3 => ./FORBIDDEN_DEPENDENCY
35-
go.etcd.io/etcd/pkg/v3 => ./FORBIDDEN_DEPENDENCY
36-
go.etcd.io/etcd/tests/v3 => ./FORBIDDEN_DEPENDENCY
37-
go.etcd.io/etcd/v3 => ./FORBIDDEN_DEPENDENCY
38-
)

client/v3/.gomodguard.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
blocked:
3+
modules:
4+
- go.etcd.io/etcd:
5+
reason: "Forbidden dependency"
6+
- go.etcd.io/etcd/pkg/v3:
7+
reason: "Forbidden dependency"
8+
- go.etcd.io/etcd/tests/v3:
9+
reason: "Forbidden dependency"
10+
- go.etcd.io/etcd/v3:
11+
reason: "Forbidden dependency"

client/v3/go.mod

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,3 @@ replace (
4646
go.etcd.io/etcd/api/v3 => ../../api
4747
go.etcd.io/etcd/client/pkg/v3 => ../pkg
4848
)
49-
50-
// Bad imports are sometimes causing attempts to pull that code.
51-
// This makes the error more explicit.
52-
replace (
53-
go.etcd.io/etcd => ./FORBIDDEN_DEPENDENCY
54-
go.etcd.io/etcd/pkg/v3 => ./FORBIDDEN_DEPENDENCY
55-
go.etcd.io/etcd/v3 => ./FORBIDDEN_DEPENDENCY
56-
go.etcd.io/tests/v3 => ./FORBIDDEN_DEPENDENCY
57-
)

etcdctl/.gomodguard.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
blocked:
3+
modules:
4+
- go.etcd.io/etcd:
5+
reason: "Forbidden dependency"
6+
- go.etcd.io/etcd/tests/v3:
7+
reason: "Forbidden dependency"
8+
- go.etcd.io/etcd/v3:
9+
reason: "Forbidden dependency"

etcdctl/go.mod

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,3 @@ replace (
5454
go.etcd.io/etcd/client/v3 => ../client/v3
5555
go.etcd.io/etcd/pkg/v3 => ../pkg
5656
)
57-
58-
// Bad imports are sometimes causing attempts to pull that code.
59-
// This makes the error more explicit.
60-
replace (
61-
go.etcd.io/etcd => ./FORBIDDEN_DEPENDENCY
62-
go.etcd.io/etcd/v3 => ./FORBIDDEN_DEPENDENCY
63-
go.etcd.io/tests/v3 => ./FORBIDDEN_DEPENDENCY
64-
)

etcdutl/.gomodguard.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
blocked:
3+
modules:
4+
- go.etcd.io/etcd:
5+
reason: "Forbidden dependency"
6+
- go.etcd.io/etcd/tests/v3:
7+
reason: "Forbidden dependency"
8+
- go.etcd.io/etcd/v3:
9+
reason: "Forbidden dependency"

etcdutl/go.mod

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@ replace (
1212
go.etcd.io/etcd/server/v3 => ../server
1313
)
1414

15-
// Bad imports are sometimes causing attempts to pull that code.
16-
// This makes the error more explicit.
17-
replace (
18-
go.etcd.io/etcd => ./FORBIDDEN_DEPENDENCY
19-
go.etcd.io/etcd/v3 => ./FORBIDDEN_DEPENDENCY
20-
go.etcd.io/tests/v3 => ./FORBIDDEN_DEPENDENCY
21-
)
22-
2315
require (
2416
github.com/coreos/go-semver v0.3.1
2517
github.com/dustin/go-humanize v1.0.1

pkg/.gomodguard.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
blocked:
3+
modules:
4+
- go.etcd.io/etcd:
5+
reason: "Forbidden dependency"
6+
- go.etcd.io/etcd/api/v3:
7+
reason: "Forbidden dependency"
8+
- go.etcd.io/etcd/tests/v3:
9+
reason: "Forbidden dependency"
10+
- go.etcd.io/etcd/v3:
11+
reason: "Forbidden dependency"

0 commit comments

Comments
 (0)