Skip to content

Commit

Permalink
Implement import restrictions with import-boss
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Valdes <[email protected]>
  • Loading branch information
ivanvc committed Aug 7, 2024
1 parent 0041a29 commit f2c30d8
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fuzz:
verify: verify-gofmt verify-bom verify-lint verify-dep verify-shellcheck verify-goword \
verify-govet verify-license-header verify-receiver-name verify-mod-tidy \
verify-shellws verify-proto-annotations verify-genproto verify-yamllint \
verify-govet-shadow verify-markdown-marker verify-go-versions
verify-govet-shadow verify-markdown-marker verify-go-versions verify-import-boss

.PHONY: fix
fix: fix-bom fix-lint fix-yamllint sync-toolchain-directive
Expand Down Expand Up @@ -155,6 +155,10 @@ verify-govet-shadow:
verify-markdown-marker:
PASSES="markdown_marker" ./scripts/test.sh

.PHONY: verify-import-boss
verify-import-boss: install-import-boss
PASSES="import_boss" ./scripts/test.sh

YAMLFMT_VERSION = $(shell cd go list -m -f '{{.Version}}' github.com/google/yamlfmt)

.PHONY: fix-yamllint
Expand All @@ -180,6 +184,14 @@ ifeq (, $(shell which golangci-lint))
$(shell curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin $(GOLANGCI_LINT_VERSION))
endif

.PHONY: install-import-boss
install-import-boss:
ifeq (, $(shell which import-boss))
# TODO: This is versionless until v1.31.0 is released
$(shell go install k8s.io/kubernetes/cmd/import-boss)
endif


.PHONY: install-lazyfs
install-lazyfs: bin/lazyfs
bin/lazyfs:
Expand Down
5 changes: 5 additions & 0 deletions api/.import-restrictions
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
rules:
# prevent import of go.etcd.io/etcd
- selectorRegexp: go[.]etcd[.]io/etcd
allowedPrefixes:
- go.etcd.io/etcd/api/v3
6 changes: 6 additions & 0 deletions client/internal/v2/.import-restrictions
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
rules:
# prevent import of go.etcd.io/etcd
- selectorRegexp: go[.]etcd[.]io/etcd
allowedPrefixes:
- go.etcd.io/etcd/api/v3
- go.etcd.io/etcd/client/pkg/v3
7 changes: 7 additions & 0 deletions client/v3/.import-restrictions
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rules:
# prevent import of go.etcd.io/etcd
- selectorRegexp: go[.]etcd[.]io/etcd
allowedPrefixes:
- go.etcd.io/etcd/api/v3
- go.etcd.io/etcd/client/pkg/v3
- go.etcd.io/etcd/client/v3
9 changes: 9 additions & 0 deletions etcdctl/.import-restrictions
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
rules:
# prevent import of go.etcd.io/etcd
- selectorRegexp: go[.]etcd[.]io/etcd
allowedPrefixes:
- go.etcd.io/etcd/api/v3
- go.etcd.io/etcd/client/pkg/v3
- go.etcd.io/etcd/client/v3
- go.etcd.io/etcd/etcdctl/v3
- go.etcd.io/etcd/pkg/v3
10 changes: 10 additions & 0 deletions etcdutl/.import-restrictions
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
rules:
# prevent import of go.etcd.io/etcd
- selectorRegexp: go[.]etcd[.]io/etcd
allowedPrefixes:
- go.etcd.io/etcd/api/v3
- go.etcd.io/etcd/client/pkg/v3
- go.etcd.io/etcd/client/v3
- go.etcd.io/etcd/etcdutl/v3
- go.etcd.io/etcd/pkg/v3
- go.etcd.io/etcd/server/v3
6 changes: 6 additions & 0 deletions pkg/.import-restrictions
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
rules:
# prevent import of go.etcd.io/etcd
- selectorRegexp: go[.]etcd[.]io/etcd
allowedPrefixes:
- go.etcd.io/etcd/client/pkg/v3
- go.etcd.io/etcd/pkg/v3
4 changes: 4 additions & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,10 @@ function lint_fix_pass {
run_for_modules generic_checker run golangci-lint run --config "${ETCD_ROOT_DIR}/tools/.golangci.yaml" --fix
}

function import_boss_pass {
run_for_modules generic_checker run import-boss
}

function license_header_per_module {
# bash 3.x compatible replacement of: mapfile -t gofiles < <(go_srcs_in_module)
local gofiles=()
Expand Down
10 changes: 10 additions & 0 deletions server/.import-restrictions
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
rules:
# prevent import of go.etcd.io/etcd
- selectorRegexp: go[.]etcd[.]io/etcd
allowedPrefixes:
- go.etcd.io/etcd/server/v3
- go.etcd.io/etcd/api/v3
- go.etcd.io/etcd/client/pkg/v3
- go.etcd.io/etcd/pkg/v3
- go.etcd.io/etcd/client/v3
- go.etcd.io/etcd/client/v2

0 comments on commit f2c30d8

Please sign in to comment.