-
Notifications
You must be signed in to change notification settings - Fork 40k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123529 from thockin/go-workspaces
Go workspaces for k/k and k/staging/*
- Loading branch information
Showing
579 changed files
with
21,326 additions
and
17,277 deletions.
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
4 changes: 2 additions & 2 deletions
4
LICENSES/vendor/k8s.io/gengo/LICENSE → LICENSES/vendor/k8s.io/gengo/v2/LICENSE
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -124,7 +124,8 @@ | |
"required": [ | ||
"type", | ||
"status", | ||
"reason" | ||
"reason", | ||
"message" | ||
], | ||
"type": "object" | ||
}, | ||
|
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
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
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,104 @@ | ||
## Purpose | ||
|
||
`import-boss` enforces optional import restrictions between packages. This is | ||
useful to manage the dependency graph within a large repository, such as | ||
[kubernetes](https://github.com/kubernetes/kubernetes). | ||
|
||
## How does it work? | ||
|
||
When a package is verified, `import-boss` looks for a file called | ||
`.import-restrictions` in the same directory and all parent directories, up to | ||
the module root (defined by the presence of a go.mod file). These files | ||
contain rules which are evaluated against each dependency of the package in | ||
question. | ||
|
||
Evaluation starts with the rules file closest to the package. If that file | ||
makes a determination to allow or forbid the import, evaluation is done. If | ||
the import does not match any rule, the next-closest rules file is consulted, | ||
and so forth. If the rules files are exhausted and no determination has been | ||
made, the import will be flagged as an error. | ||
|
||
### What are rules files? | ||
|
||
A rules file is a JSON or YAML document with two top-level keys, both optional: | ||
* `Rules` | ||
* `InverseRules` | ||
|
||
### What are Rules? | ||
|
||
A `rule` defines a policy to be enforced on packages which are depended on by | ||
the package in question. It consists of three parts: | ||
- A `SelectorRegexp`, to select the import paths that the rule applies to. | ||
- A list of `AllowedPrefixes` | ||
- A list of `ForbiddenPrefixes` | ||
|
||
An import is allowed if it matches at least one allowed prefix and does not | ||
match any forbidden prefixes. | ||
|
||
Rules also have a boolean `Transitive` option. When this option is true, the | ||
rule is applied to transitive imports. | ||
|
||
Example: | ||
|
||
```json | ||
{ | ||
"Rules": [ | ||
{ | ||
"SelectorRegexp": "example[.]com", | ||
"AllowedPrefixes": [ | ||
"example.com/project/package", | ||
"example.com/other/package" | ||
], | ||
"ForbiddenPrefixes": [ | ||
"example.com/legacy/package" | ||
] | ||
}, | ||
{ | ||
"SelectorRegexp": "^unsafe$", | ||
"AllowedPrefixes": [], | ||
"ForbiddenPrefixes": [ "" ], | ||
"Transitive": true | ||
} | ||
] | ||
} | ||
``` | ||
|
||
The `SelectorRegexp` specifies that this rule applies only to imports which | ||
match that regex. | ||
|
||
Note: an empty list (`[]`) matches nothing, and an empty string (`""`) is a | ||
prefix of everything. | ||
|
||
### What are InverseRules? | ||
|
||
In contrast to rules, which are defined in terms of "things this package | ||
depends on", inverse rules are defined in terms of "things which import this | ||
package". This allows for fine-grained import restrictions for "semi-private | ||
packages" which are more sophisticated than Go's `internal` convention. | ||
|
||
If inverse rules are found, then all known imports of the package are checked | ||
against each such rule, in the same fashion as regular rules. Note that this | ||
can only handle known imports, which is defined as any package which is also | ||
being considered by this `import-boss` run. For most repositories, `./...` will | ||
suffice. | ||
|
||
Example: | ||
|
||
```yaml | ||
inverseRules: | ||
- selectorRegexp: example[.]com | ||
allowedPrefixes: | ||
- example.com/this-same-repo | ||
- example.com/close-friend/legacy | ||
forbiddenPrefixes: | ||
- example.com/other-project | ||
- selectorRegexp: example[.]com | ||
transitive: true | ||
forbiddenPrefixes: | ||
- example.com/other-team | ||
``` | ||
## How do I run import-boss? | ||
For most scenarios, simply running `import-boss ./...` will work. For projects | ||
which use Go workspaces, this can even span multiple modules. |
Oops, something went wrong.