-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5fd574f
commit 5c9e6c0
Showing
26 changed files
with
180 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
TOOL=import-boss | ||
|
||
all: test | ||
|
||
test: build test_rules test_inverse | ||
|
||
build: | ||
@go build -o /tmp/$(TOOL) | ||
|
||
test_rules: | ||
/tmp/$(TOOL) --logtostderr --v=4 -i $$(go list ./tests/rules/a) | ||
! /tmp/$(TOOL) --logtostderr --v=4 -i $$(go list ./tests/rules/b) | ||
/tmp/$(TOOL) --logtostderr --v=4 -i ./tests/rules/c | ||
! /tmp/$(TOOL) --logtostderr --v=4 -i ./tests/rules/nested | ||
/tmp/$(TOOL) --logtostderr --v=4 -i ./tests/rules/nested/nested | ||
! /tmp/$(TOOL) --logtostderr --v=4 -i ./tests/rules/nested/nested/nested | ||
! /tmp/$(TOOL) --logtostderr --v=4 -i ./tests/rules/nested/nested/nested/inherit | ||
|
||
test_inverse: | ||
/tmp/$(TOOL) --logtostderr --v=4 -i $$(go list ./tests/inverse/a ./tests/inverse/lib/... | grep -v quarantine | paste -sd',' -) | ||
! /tmp/$(TOOL) --logtostderr --v=4 -i $$(go list ./tests/inverse/b ./tests/inverse/lib/... | grep -v quarantine | paste -sd',' -) | ||
/tmp/$(TOOL) --logtostderr --v=4 -i $$(go list ./tests/inverse/c ./tests/inverse/lib/... | grep -v quarantine | paste -sd',' -) | ||
! /tmp/$(TOOL) --logtostderr --v=4 -i $$(go list ./tests/inverse/d ./tests/inverse/lib/... | grep -v quarantine | paste -sd',' -) | ||
! /tmp/$(TOOL) --logtostderr --v=4 -i $$(go list ./tests/inverse/lib/... | paste -sd',' -) | ||
|
||
! /tmp/$(TOOL) --logtostderr --v=4 -i $$(go list ./tests/inverse/lib/... | paste -sd',' -) | ||
|
||
.PHONY: build test test_rules test_inverse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// a only imports public packages. | ||
package a | ||
|
||
import ( | ||
_ "k8s.io/gengo/examples/import-boss/tests/inverse/lib/public" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// b only imports public and private packages. The latter it shouldn't. | ||
package b | ||
|
||
import ( | ||
_ "k8s.io/gengo/examples/import-boss/tests/inverse/lib/private" | ||
_ "k8s.io/gengo/examples/import-boss/tests/inverse/lib/public" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// c imports the library root, which in turn imports the public and private packages. This is fine because | ||
// the private package is not directly imported. | ||
package c | ||
|
||
import ( | ||
_ "k8s.io/gengo/examples/import-boss/tests/inverse/lib" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// c imports non-prod code. It shouldn't. | ||
package d | ||
|
||
import ( | ||
_ "k8s.io/gengo/examples/import-boss/tests/inverse/lib/nonprod" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package lib | ||
|
||
import ( | ||
_ "k8s.io/gengo/examples/import-boss/tests/inverse/lib/private" | ||
_ "k8s.io/gengo/examples/import-boss/tests/inverse/lib/public" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package lib | ||
|
||
import ( | ||
_ "k8s.io/gengo/examples/import-boss/tests/inverse/lib/nonprod" | ||
) |
9 changes: 9 additions & 0 deletions
9
examples/import-boss/tests/inverse/lib/nonprod/.import-restrictions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"InverseRules": [{ | ||
"Transitive": true, | ||
"SelectorRegexp": "k8s[.]io/gengo", | ||
"AllowedPrefixes": [ | ||
"k8s.io/gengo/examples/import-boss/tests/inverse/lib" | ||
] | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// nonprod is non-production code that should not be linked into any outside package. | ||
package nonprod |
11 changes: 11 additions & 0 deletions
11
examples/import-boss/tests/inverse/lib/private/.import-restrictions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"InverseRules": [{ | ||
"SelectorRegexp": "k8s[.]io/gengo", | ||
"AllowedPrefixes": [ | ||
"k8s.io/gengo/examples/import-boss/tests/inverse/lib" | ||
], | ||
"ForbiddenPrefixes": [ | ||
"k8s.io/gengo/examples/import-boss/tests/inverse/lib/quarantine" | ||
] | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package private |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// quarantine is inside the library, but should not import the private package. But it does! | ||
package quarantine | ||
|
||
import ( | ||
_ "k8s.io/gengo/examples/import-boss/tests/inverse/lib/private" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"Rules": [{ | ||
"SelectorRegexp": "k8s[.]io/gengo", | ||
"AllowedPrefixes": [ | ||
"k8s.io/gengo/examples/import-boss/tests/rules/b" | ||
], | ||
"ForbiddenPrefixes": [ | ||
"k8s.io/gengo/examples/import-boss/tests/rules/c" | ||
] | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package a | ||
|
||
import ( | ||
_ "k8s.io/gengo/examples/import-boss/tests/rules/b" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"Rules": [{ | ||
"SelectorRegexp": "k8s[.]io/gengo", | ||
"AllowedPrefixes": [ | ||
"" | ||
], | ||
"ForbiddenPrefixes": [ | ||
"k8s.io/gengo/examples/import-boss/tests/rules/c" | ||
] | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// b only public and private packages. The latter it shouldn't. | ||
package b | ||
|
||
import ( | ||
_ "k8s.io/gengo/examples/import-boss/tests/rules/c" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package c |
10 changes: 10 additions & 0 deletions
10
examples/import-boss/tests/rules/nested/.import-restrictions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"Rules": [{ | ||
"SelectorRegexp": "k8s[.]io/gengo", | ||
"AllowedPrefixes": [ | ||
], | ||
"ForbiddenPrefixes": [ | ||
"k8s.io/gengo/examples/import-boss/tests/rules/c" | ||
] | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package nested | ||
|
||
import ( | ||
_ "k8s.io/gengo/examples/import-boss/tests/rules/c" | ||
) |
10 changes: 10 additions & 0 deletions
10
examples/import-boss/tests/rules/nested/nested/.import-restrictions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"Rules": [{ | ||
"SelectorRegexp": "k8s[.]io/gengo", | ||
"AllowedPrefixes": [ | ||
"k8s.io/gengo/examples/import-boss/tests/rules/c" | ||
], | ||
"ForbiddenPrefixes": [ | ||
] | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package nested | ||
|
||
import ( | ||
_ "k8s.io/gengo/examples/import-boss/tests/rules/c" | ||
) |
10 changes: 10 additions & 0 deletions
10
examples/import-boss/tests/rules/nested/nested/nested/.import-restrictions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"Rules": [{ | ||
"SelectorRegexp": "k8s[.]io/gengo", | ||
"AllowedPrefixes": [ | ||
], | ||
"ForbiddenPrefixes": [ | ||
"k8s.io/gengo/examples/import-boss/tests/rules/c" | ||
] | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package nested | ||
|
||
import ( | ||
_ "k8s.io/gengo/examples/import-boss/tests/rules/c" | ||
) |
5 changes: 5 additions & 0 deletions
5
examples/import-boss/tests/rules/nested/nested/nested/inherit/doc.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package inherit | ||
|
||
import ( | ||
_ "k8s.io/gengo/examples/import-boss/tests/rules/c" | ||
) |