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
d1e0a9db
Commit
d1e0a9db
authored
Oct 23, 2017
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conversion-gen: cut off kube dependencies in extra-peer-dirs
parent
40212c17
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
16 deletions
+24
-16
Makefile.generated_files
build/root/Makefile.generated_files
+2
-0
conversion.go
...ode-generator/cmd/conversion-gen/generators/conversion.go
+17
-4
main.go
staging/src/k8s.io/code-generator/cmd/conversion-gen/main.go
+5
-12
No files found.
build/root/Makefile.generated_files
View file @
d1e0a9db
...
...
@@ -628,6 +628,7 @@ CONVERSION_DIRS := $(shell \
)
CONVERSION_FILES
:=
$
(
addsuffix /
$(CONVERSION_FILENAME)
,
$(CONVERSION_DIRS)
)
CONVERSION_EXTRA_PEER_DIRS
:=
k8s.io/kubernetes/pkg/api,k8s.io/kubernetes/pkg/api/v1,k8s.io/api/core/v1
# Shell function for reuse in rules.
RUN_GEN_CONVERSION
=
\
...
...
@@ -638,6 +639,7 @@ RUN_GEN_CONVERSION = \
echo
"DBG: running
$(CONVERSION_GEN)
for
$$
pkgs"
;
\
fi
;
\
./hack/run-in-gopath.sh
$(CONVERSION_GEN)
\
--extra-peer-dirs
$(CONVERSION_EXTRA_PEER_DIRS)
\
--v
$(KUBE_VERBOSE)
\
--logtostderr
\
-i
"
$$
pkgs"
\
...
...
staging/src/k8s.io/code-generator/cmd/conversion-gen/generators/conversion.go
View file @
d1e0a9db
...
...
@@ -32,9 +32,23 @@ import (
"github.com/golang/glog"
)
// DefaultBasePeerDirs are the peer-dirs nearly everybody will use, i.e. those coming from
// apimachinery.
var
DefaultBasePeerDirs
=
[]
string
{
"k8s.io/apimachinery/pkg/apis/meta/v1"
,
"k8s.io/apimachinery/pkg/conversion"
,
"k8s.io/apimachinery/pkg/runtime"
,
}
// CustomArgs is used by the gengo framework to pass args specific to this generator.
type
CustomArgs
struct
{
ExtraPeerDirs
[]
string
// Always consider these as last-ditch possibilities for conversions.
// Base peer dirs which nearly everybody will use, i.e. outside of Kubernetes core.
BasePeerDirs
[]
string
// Custom peer dirs which are application specific. Always consider these as
// last-ditch possibilities for conversions.
ExtraPeerDirs
[]
string
//
// Skipunsafe indicates whether to generate unsafe conversions to improve the efficiency
// of these operations. The unsafe operation is a direct pointer assignment via unsafe
// (within the allowed uses of unsafe) and is equivalent to a proposed Golang change to
...
...
@@ -247,9 +261,8 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
}
skipUnsafe
:=
false
if
customArgs
,
ok
:=
arguments
.
CustomArgs
.
(
*
CustomArgs
);
ok
{
if
len
(
customArgs
.
ExtraPeerDirs
)
>
0
{
peerPkgs
=
append
(
peerPkgs
,
customArgs
.
ExtraPeerDirs
...
)
}
peerPkgs
=
append
(
peerPkgs
,
customArgs
.
BasePeerDirs
...
)
peerPkgs
=
append
(
peerPkgs
,
customArgs
.
ExtraPeerDirs
...
)
skipUnsafe
=
customArgs
.
SkipUnsafe
}
...
...
staging/src/k8s.io/code-generator/cmd/conversion-gen/main.go
View file @
d1e0a9db
...
...
@@ -48,21 +48,14 @@ func main() {
arguments
:=
args
.
Default
()
// Custom args.
// TODO: make callers pass this in. It is too opaque here, and any use of
// the flag that DOESN'T include these is broken.
customArgs
:=
&
generators
.
CustomArgs
{
ExtraPeerDirs
:
[]
string
{
"k8s.io/kubernetes/pkg/api"
,
"k8s.io/kubernetes/pkg/api/v1"
,
"k8s.io/api/core/v1"
,
"k8s.io/apimachinery/pkg/apis/meta/v1"
,
"k8s.io/apimachinery/pkg/conversion"
,
"k8s.io/apimachinery/pkg/runtime"
,
},
SkipUnsafe
:
false
,
BasePeerDirs
:
generators
.
DefaultBasePeerDirs
,
SkipUnsafe
:
false
,
}
pflag
.
CommandLine
.
StringSliceVar
(
&
customArgs
.
BasePeerDirs
,
"base-peer-dirs"
,
customArgs
.
BasePeerDirs
,
"Comma-separated list of apimachinery import paths which are considered, after tag-specified peers, for conversions. Only change these if you have very good reasons."
)
pflag
.
CommandLine
.
StringSliceVar
(
&
customArgs
.
ExtraPeerDirs
,
"extra-peer-dirs"
,
customArgs
.
ExtraPeerDirs
,
"
Comma-separated list of import paths which are considered, after tag-specified pee
rs, for conversions."
)
"
Application specific comma-separated list of import paths which are considered, after tag-specified peers and base-peer-di
rs, for conversions."
)
pflag
.
CommandLine
.
BoolVar
(
&
customArgs
.
SkipUnsafe
,
"skip-unsafe"
,
customArgs
.
SkipUnsafe
,
"If true, will not generate code using unsafe pointer conversions; resulting code may be slower."
)
...
...
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