Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
024122a9
Commit
024122a9
authored
Oct 25, 2017
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
import-verifier: use yaml for inline comments
parent
d51d7fd2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
104 deletions
+82
-104
BUILD
cmd/importverifier/BUILD
+1
-0
importverifier.go
cmd/importverifier/importverifier.go
+12
-10
import-restrictions.json
hack/import-restrictions.json
+0
-93
import-restrictions.yaml
hack/import-restrictions.yaml
+68
-0
verify-imports.sh
hack/verify-imports.sh
+1
-1
No files found.
cmd/importverifier/BUILD
View file @
024122a9
...
...
@@ -16,6 +16,7 @@ go_library(
name = "go_default_library",
srcs = ["importverifier.go"],
importpath = "k8s.io/kubernetes/cmd/importverifier",
deps = ["//vendor/gopkg.in/yaml.v2:go_default_library"],
)
filegroup(
...
...
cmd/importverifier/importverifier.go
View file @
024122a9
...
...
@@ -27,15 +27,17 @@ import (
"os/exec"
"path/filepath"
"strings"
"gopkg.in/yaml.v2"
)
// Package is a subset of cmd/go.Package
type
Package
struct
{
Dir
string
`
json
:",omitempty"`
// directory containing package sources
ImportPath
string
`
json
:",omitempty"`
// import path of package in dir
Imports
[]
string
`
json
:",omitempty"`
// import paths used by this package
TestImports
[]
string
`
json
:",omitempty"`
// imports from TestGoFiles
XTestImports
[]
string
`
json
:",omitempty"`
// imports from XTestGoFiles
Dir
string
`
yaml
:",omitempty"`
// directory containing package sources
ImportPath
string
`
yaml
:",omitempty"`
// import path of package in dir
Imports
[]
string
`
yaml
:",omitempty"`
// import paths used by this package
TestImports
[]
string
`
yaml
:",omitempty"`
// imports from TestGoFiles
XTestImports
[]
string
`
yaml
:",omitempty"`
// imports from XTestGoFiles
}
// ImportRestriction describes a set of allowable import
...
...
@@ -44,17 +46,17 @@ type ImportRestriction struct {
// BaseDir is the root of the package tree that is
// restricted by this configuration, given as a
// relative path from the root of the repository
BaseDir
string
`
json
:"baseImportPath"`
BaseDir
string
`
yaml
:"baseImportPath"`
// IgnoredSubTrees are roots of sub-trees of the
// BaseDir for which we do not want to enforce
// any import restrictions whatsoever, given as
// relative paths from the root of the repository
IgnoredSubTrees
[]
string
`
json
:"ignoredSubTrees,omitempty"`
IgnoredSubTrees
[]
string
`
yaml
:"ignoredSubTrees,omitempty"`
// AllowedImports are roots of package trees that
// are allowed to be imported from the BaseDir,
// given as paths that would be used in a Go
// import statement
AllowedImports
[]
string
`
json
:"allowedImports"`
AllowedImports
[]
string
`
yaml
:"allowedImports"`
}
// ForbiddenImportsFor determines all of the forbidden
...
...
@@ -164,7 +166,7 @@ var rootPackage string
func
main
()
{
if
len
(
os
.
Args
)
!=
3
{
log
.
Fatalf
(
"Usage: %s ROOT RESTRICTIONS.
json
"
,
os
.
Args
[
0
])
log
.
Fatalf
(
"Usage: %s ROOT RESTRICTIONS.
yaml
"
,
os
.
Args
[
0
])
}
rootPackage
=
os
.
Args
[
1
]
...
...
@@ -214,7 +216,7 @@ func loadImportRestrictions(configFile string) ([]ImportRestriction, error) {
}
var
importRestrictions
[]
ImportRestriction
if
err
:=
json
.
Unmarshal
(
config
,
&
importRestrictions
);
err
!=
nil
{
if
err
:=
yaml
.
Unmarshal
(
config
,
&
importRestrictions
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to unmarshal from %s: %v"
,
configFile
,
err
)
}
...
...
hack/import-restrictions.json
deleted
100644 → 0
View file @
d51d7fd2
[
{
"baseImportPath"
:
"./vendor/k8s.io/apimachinery/"
,
"allowedImports"
:
[
"k8s.io/apimachinery"
,
"k8s.io/kube-openapi"
]
},
{
"baseImportPath"
:
"./vendor/k8s.io/api/"
,
"allowedImports"
:
[
"k8s.io/api"
,
"k8s.io/apimachinery"
]
},
{
"baseImportPath"
:
"./vendor/k8s.io/code-generator/"
,
"ignoredSubTrees"
:
[
"./vendor/k8s.io/code-generator/_test"
],
"allowedImports"
:
[
"k8s.io/gengo"
,
"k8s.io/code-generator"
,
"k8s.io/kube-openapi"
]
},
{
"baseImportPath"
:
"./vendor/k8s.io/client-go/"
,
"allowedImports"
:
[
"k8s.io/api"
,
"k8s.io/apimachinery"
,
"k8s.io/client-go"
]
},
{
"baseImportPath"
:
"./vendor/k8s.io/apiserver/"
,
"allowedImports"
:
[
"k8s.io/api"
,
"k8s.io/apimachinery"
,
"k8s.io/apiserver"
,
"k8s.io/client-go"
,
"k8s.io/kube-openapi"
]
},
{
"baseImportPath"
:
"./vendor/k8s.io/metrics/"
,
"allowedImports"
:
[
"k8s.io/api"
,
"k8s.io/apimachinery"
,
"k8s.io/client-go"
,
"k8s.io/metrics"
]
},
{
"baseImportPath"
:
"./vendor/k8s.io/kube-aggregator/"
,
"allowedImports"
:
[
"k8s.io/api"
,
"k8s.io/apimachinery"
,
"k8s.io/apiserver"
,
"k8s.io/client-go"
,
"k8s.io/kube-aggregator"
,
"k8s.io/kube-openapi"
]
},
{
"baseImportPath"
:
"./vendor/k8s.io/sample-apiserver/"
,
"allowedImports"
:
[
"k8s.io/api"
,
"k8s.io/apimachinery"
,
"k8s.io/apiserver"
,
"k8s.io/client-go"
,
"k8s.io/sample-apiserver"
]
},
{
"baseImportPath"
:
"./vendor/k8s.io/apiextensions-apiserver/"
,
"allowedImports"
:
[
"k8s.io/api"
,
"k8s.io/apiextensions-apiserver"
,
"k8s.io/apimachinery"
,
"k8s.io/apiserver"
,
"k8s.io/client-go"
]
},
{
"baseImportPath"
:
"./vendor/k8s.io/kube-openapi/"
,
"allowedImports"
:
[
"k8s.io/kube-openapi"
,
"k8s.io/gengo"
]
}
]
\ No newline at end of file
hack/import-restrictions.yaml
0 → 100644
View file @
024122a9
-
baseImportPath
:
"
./vendor/k8s.io/apimachinery/"
allowedImports
:
-
k8s.io/apimachinery
-
k8s.io/kube-openapi
-
baseImportPath
:
"
./vendor/k8s.io/api/"
allowedImports
:
-
k8s.io/api
-
k8s.io/apimachinery
-
baseImportPath
:
"
./vendor/k8s.io/code-generator/"
ignoredSubTrees
:
-
"
./vendor/k8s.io/code-generator/_test"
allowedImports
:
-
k8s.io/gengo
-
k8s.io/code-generator
-
k8s.io/kube-openapi
-
baseImportPath
:
"
./vendor/k8s.io/client-go/"
allowedImports
:
-
k8s.io/api
-
k8s.io/apimachinery
-
k8s.io/client-go
-
baseImportPath
:
"
./vendor/k8s.io/apiserver/"
allowedImports
:
-
k8s.io/api
-
k8s.io/apimachinery
-
k8s.io/apiserver
-
k8s.io/client-go
-
k8s.io/kube-openapi
-
baseImportPath
:
"
./vendor/k8s.io/metrics/"
allowedImports
:
-
k8s.io/api
-
k8s.io/apimachinery
-
k8s.io/client-go
-
k8s.io/metrics
-
baseImportPath
:
"
./vendor/k8s.io/kube-aggregator/"
allowedImports
:
-
k8s.io/api
-
k8s.io/apimachinery
-
k8s.io/apiserver
-
k8s.io/client-go
-
k8s.io/kube-aggregator
-
k8s.io/kube-openapi
-
baseImportPath
:
"
./vendor/k8s.io/sample-apiserver/"
allowedImports
:
-
k8s.io/api
-
k8s.io/apimachinery
-
k8s.io/apiserver
-
k8s.io/client-go
-
k8s.io/sample-apiserver
-
baseImportPath
:
"
./vendor/k8s.io/apiextensions-apiserver/"
allowedImports
:
-
k8s.io/api
-
k8s.io/apiextensions-apiserver
-
k8s.io/apimachinery
-
k8s.io/apiserver
-
k8s.io/client-go
-
baseImportPath
:
"
./vendor/k8s.io/kube-openapi/"
allowedImports
:
-
k8s.io/kube-openapi
-
k8s.io/gengo
hack/verify-imports.sh
View file @
024122a9
...
...
@@ -38,4 +38,4 @@ if [[ ! -x "$importverifier" ]]; then
exit
1
fi
"
${
importverifier
}
"
"k8s.io/"
"
${
KUBE_ROOT
}
/hack/import-restrictions.
json
"
"
${
importverifier
}
"
"k8s.io/"
"
${
KUBE_ROOT
}
/hack/import-restrictions.
yaml
"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment