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
c5059bd7
Unverified
Commit
c5059bd7
authored
Jan 23, 2017
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bump(k8s.io/gengo):c118aa8edfff53fe5b69127a970f54b6cf3a7563
parent
df831db3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
31 deletions
+55
-31
Godeps.json
Godeps/Godeps.json
+10
-10
deepcopy.go
...k8s.io/gengo/examples/deepcopy-gen/generators/deepcopy.go
+32
-7
parse.go
vendor/k8s.io/gengo/parser/parse.go
+12
-13
types.go
vendor/k8s.io/gengo/types/types.go
+1
-1
No files found.
Godeps/Godeps.json
View file @
c5059bd7
...
@@ -2663,43 +2663,43 @@
...
@@ -2663,43 +2663,43 @@
},
},
{
{
"ImportPath"
:
"k8s.io/gengo/args"
,
"ImportPath"
:
"k8s.io/gengo/args"
,
"Rev"
:
"
3c6a809462caf39389d70d9ea787ed24c5acffed
"
"Rev"
:
"
c118aa8edfff53fe5b69127a970f54b6cf3a7563
"
},
},
{
{
"ImportPath"
:
"k8s.io/gengo/examples/deepcopy-gen/generators"
,
"ImportPath"
:
"k8s.io/gengo/examples/deepcopy-gen/generators"
,
"Rev"
:
"
3c6a809462caf39389d70d9ea787ed24c5acffed
"
"Rev"
:
"
c118aa8edfff53fe5b69127a970f54b6cf3a7563
"
},
},
{
{
"ImportPath"
:
"k8s.io/gengo/examples/defaulter-gen/generators"
,
"ImportPath"
:
"k8s.io/gengo/examples/defaulter-gen/generators"
,
"Rev"
:
"
3c6a809462caf39389d70d9ea787ed24c5acffed
"
"Rev"
:
"
c118aa8edfff53fe5b69127a970f54b6cf3a7563
"
},
},
{
{
"ImportPath"
:
"k8s.io/gengo/examples/import-boss/generators"
,
"ImportPath"
:
"k8s.io/gengo/examples/import-boss/generators"
,
"Rev"
:
"
3c6a809462caf39389d70d9ea787ed24c5acffed
"
"Rev"
:
"
c118aa8edfff53fe5b69127a970f54b6cf3a7563
"
},
},
{
{
"ImportPath"
:
"k8s.io/gengo/examples/set-gen/generators"
,
"ImportPath"
:
"k8s.io/gengo/examples/set-gen/generators"
,
"Rev"
:
"
3c6a809462caf39389d70d9ea787ed24c5acffed
"
"Rev"
:
"
c118aa8edfff53fe5b69127a970f54b6cf3a7563
"
},
},
{
{
"ImportPath"
:
"k8s.io/gengo/examples/set-gen/sets"
,
"ImportPath"
:
"k8s.io/gengo/examples/set-gen/sets"
,
"Rev"
:
"
3c6a809462caf39389d70d9ea787ed24c5acffed
"
"Rev"
:
"
c118aa8edfff53fe5b69127a970f54b6cf3a7563
"
},
},
{
{
"ImportPath"
:
"k8s.io/gengo/generator"
,
"ImportPath"
:
"k8s.io/gengo/generator"
,
"Rev"
:
"
3c6a809462caf39389d70d9ea787ed24c5acffed
"
"Rev"
:
"
c118aa8edfff53fe5b69127a970f54b6cf3a7563
"
},
},
{
{
"ImportPath"
:
"k8s.io/gengo/namer"
,
"ImportPath"
:
"k8s.io/gengo/namer"
,
"Rev"
:
"
3c6a809462caf39389d70d9ea787ed24c5acffed
"
"Rev"
:
"
c118aa8edfff53fe5b69127a970f54b6cf3a7563
"
},
},
{
{
"ImportPath"
:
"k8s.io/gengo/parser"
,
"ImportPath"
:
"k8s.io/gengo/parser"
,
"Rev"
:
"
3c6a809462caf39389d70d9ea787ed24c5acffed
"
"Rev"
:
"
c118aa8edfff53fe5b69127a970f54b6cf3a7563
"
},
},
{
{
"ImportPath"
:
"k8s.io/gengo/types"
,
"ImportPath"
:
"k8s.io/gengo/types"
,
"Rev"
:
"
3c6a809462caf39389d70d9ea787ed24c5acffed
"
"Rev"
:
"
c118aa8edfff53fe5b69127a970f54b6cf3a7563
"
},
},
{
{
"ImportPath"
:
"k8s.io/heapster/metrics/api/v1/types"
,
"ImportPath"
:
"k8s.io/heapster/metrics/api/v1/types"
,
...
...
vendor/k8s.io/gengo/examples/deepcopy-gen/generators/deepcopy.go
View file @
c5059bd7
...
@@ -184,10 +184,25 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
...
@@ -184,10 +184,25 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
if
pkgNeedsGeneration
{
if
pkgNeedsGeneration
{
glog
.
V
(
3
)
.
Infof
(
"Package %q needs generation"
,
i
)
glog
.
V
(
3
)
.
Infof
(
"Package %q needs generation"
,
i
)
path
:=
pkg
.
Path
// if the source path is within a /vendor/ directory (for example,
// k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/meta/v1), allow
// generation to output to the proper relative path (under vendor).
// Otherwise, the generator will create the file in the wrong location
// in the output directory.
// TODO: build a more fundamental concept in gengo for dealing with modifications
// to vendored packages.
if
strings
.
HasPrefix
(
pkg
.
SourcePath
,
arguments
.
OutputBase
)
{
expandedPath
:=
strings
.
TrimPrefix
(
pkg
.
SourcePath
,
arguments
.
OutputBase
)
if
strings
.
Contains
(
expandedPath
,
"/vendor/"
)
{
path
=
expandedPath
glog
.
V
(
3
)
.
Infof
(
" %s"
,
path
)
}
}
packages
=
append
(
packages
,
packages
=
append
(
packages
,
&
generator
.
DefaultPackage
{
&
generator
.
DefaultPackage
{
PackageName
:
strings
.
Split
(
filepath
.
Base
(
pkg
.
Path
),
"."
)[
0
],
PackageName
:
strings
.
Split
(
filepath
.
Base
(
pkg
.
Path
),
"."
)[
0
],
PackagePath
:
p
kg
.
P
ath
,
PackagePath
:
path
,
HeaderText
:
header
,
HeaderText
:
header
,
GeneratorFunc
:
func
(
c
*
generator
.
Context
)
(
generators
[]
generator
.
Generator
)
{
GeneratorFunc
:
func
(
c
*
generator
.
Context
)
(
generators
[]
generator
.
Generator
)
{
return
[]
generator
.
Generator
{
return
[]
generator
.
Generator
{
...
@@ -524,15 +539,25 @@ func (g *genDeepCopy) doMap(t *types.Type, sw *generator.SnippetWriter) {
...
@@ -524,15 +539,25 @@ func (g *genDeepCopy) doMap(t *types.Type, sw *generator.SnippetWriter) {
}
}
func
(
g
*
genDeepCopy
)
doSlice
(
t
*
types
.
Type
,
sw
*
generator
.
SnippetWriter
)
{
func
(
g
*
genDeepCopy
)
doSlice
(
t
*
types
.
Type
,
sw
*
generator
.
SnippetWriter
)
{
if
hasDeepCopyMethod
(
t
)
{
sw
.
Do
(
"*out = in.DeepCopy()
\n
"
,
nil
)
return
}
sw
.
Do
(
"*out = make($.|raw$, len(*in))
\n
"
,
t
)
sw
.
Do
(
"*out = make($.|raw$, len(*in))
\n
"
,
t
)
if
t
.
Elem
.
Kind
==
types
.
Builtin
{
if
hasDeepCopyMethod
(
t
.
Elem
)
{
sw
.
Do
(
"for i := range *in {
\n
"
,
nil
)
sw
.
Do
(
"(*out)[i] = (*in)[i].DeepCopy()
\n
"
,
nil
)
sw
.
Do
(
"}
\n
"
,
nil
)
}
else
if
t
.
Elem
.
Kind
==
types
.
Builtin
||
t
.
Elem
.
IsAssignable
()
{
sw
.
Do
(
"copy(*out, *in)
\n
"
,
nil
)
sw
.
Do
(
"copy(*out, *in)
\n
"
,
nil
)
}
else
{
}
else
{
sw
.
Do
(
"for i := range *in {
\n
"
,
nil
)
sw
.
Do
(
"for i := range *in {
\n
"
,
nil
)
if
hasDeepCopyMethod
(
t
.
Elem
)
{
if
t
.
Elem
.
Kind
==
types
.
Slice
{
sw
.
Do
(
"(*out)[i] = (*in)[i].DeepCopy()
\n
"
,
nil
)
sw
.
Do
(
"if (*in)[i] != nil {
\n
"
,
nil
)
}
else
if
t
.
Elem
.
IsAssignable
()
{
sw
.
Do
(
"in, out := &(*in)[i], &(*out)[i]
\n
"
,
nil
)
sw
.
Do
(
"(*out)[i] = (*in)[i]
\n
"
,
nil
)
g
.
generateFor
(
t
.
Elem
,
sw
)
sw
.
Do
(
"}
\n
"
,
nil
)
}
else
if
g
.
copyableAndInBounds
(
t
.
Elem
)
{
}
else
if
g
.
copyableAndInBounds
(
t
.
Elem
)
{
sw
.
Do
(
"if err := $.type|dcFnName$(&(*in)[i], &(*out)[i], c); err != nil {
\n
"
,
argsFromType
(
t
.
Elem
))
sw
.
Do
(
"if err := $.type|dcFnName$(&(*in)[i], &(*out)[i], c); err != nil {
\n
"
,
argsFromType
(
t
.
Elem
))
sw
.
Do
(
"return err
\n
"
,
nil
)
sw
.
Do
(
"return err
\n
"
,
nil
)
...
@@ -582,7 +607,7 @@ func (g *genDeepCopy) doStruct(t *types.Type, sw *generator.SnippetWriter) {
...
@@ -582,7 +607,7 @@ func (g *genDeepCopy) doStruct(t *types.Type, sw *generator.SnippetWriter) {
sw
.
Do
(
"out.$.name$ = in.$.name$.DeepCopy()
\n
"
,
args
)
sw
.
Do
(
"out.$.name$ = in.$.name$.DeepCopy()
\n
"
,
args
)
sw
.
Do
(
"}
\n
"
,
nil
)
sw
.
Do
(
"}
\n
"
,
nil
)
}
else
{
}
else
{
// Fixup non-nil reference-sematic types.
// Fixup non-nil reference-sema
n
tic types.
sw
.
Do
(
"if in.$.name$ != nil {
\n
"
,
args
)
sw
.
Do
(
"if in.$.name$ != nil {
\n
"
,
args
)
sw
.
Do
(
"in, out := &in.$.name$, &out.$.name$
\n
"
,
args
)
sw
.
Do
(
"in, out := &in.$.name$, &out.$.name$
\n
"
,
args
)
g
.
generateFor
(
t
,
sw
)
g
.
generateFor
(
t
,
sw
)
...
...
vendor/k8s.io/gengo/parser/parse.go
View file @
c5059bd7
...
@@ -695,16 +695,16 @@ func (b *Builder) walkType(u types.Universe, useName *types.Name, in tc.Type) *t
...
@@ -695,16 +695,16 @@ func (b *Builder) walkType(u types.Universe, useName *types.Name, in tc.Type) *t
}
}
return
out
return
out
case
*
tc
.
Named
:
case
*
tc
.
Named
:
var
out
*
types
.
Type
switch
t
.
Underlying
()
.
(
type
)
{
switch
t
.
Underlying
()
.
(
type
)
{
case
*
tc
.
Named
,
*
tc
.
Basic
,
*
tc
.
Map
,
*
tc
.
Slice
:
case
*
tc
.
Named
,
*
tc
.
Basic
,
*
tc
.
Map
,
*
tc
.
Slice
:
name
:=
tcNameToName
(
t
.
String
())
name
:=
tcNameToName
(
t
.
String
())
out
:
=
u
.
Type
(
name
)
out
=
u
.
Type
(
name
)
if
out
.
Kind
!=
types
.
Unknown
{
if
out
.
Kind
!=
types
.
Unknown
{
return
out
return
out
}
}
out
.
Kind
=
types
.
Alias
out
.
Kind
=
types
.
Alias
out
.
Underlying
=
b
.
walkType
(
u
,
nil
,
t
.
Underlying
())
out
.
Underlying
=
b
.
walkType
(
u
,
nil
,
t
.
Underlying
())
return
out
default
:
default
:
// tc package makes everything "named" with an
// tc package makes everything "named" with an
// underlying anonymous type--we remove that annoying
// underlying anonymous type--we remove that annoying
...
@@ -714,20 +714,19 @@ func (b *Builder) walkType(u types.Universe, useName *types.Name, in tc.Type) *t
...
@@ -714,20 +714,19 @@ func (b *Builder) walkType(u types.Universe, useName *types.Name, in tc.Type) *t
if
out
:=
u
.
Type
(
name
);
out
.
Kind
!=
types
.
Unknown
{
if
out
:=
u
.
Type
(
name
);
out
.
Kind
!=
types
.
Unknown
{
return
out
// short circuit if we've already made this.
return
out
// short circuit if we've already made this.
}
}
out
:=
b
.
walkType
(
u
,
&
name
,
t
.
Underlying
())
out
=
b
.
walkType
(
u
,
&
name
,
t
.
Underlying
())
if
len
(
out
.
Methods
)
==
0
{
}
// If the underlying type didn't already add
// If the underlying type didn't already add methods, add them.
// methods, add them. (Interface types will
// (Interface types will have already added methods.)
// have already added methods.)
if
len
(
out
.
Methods
)
==
0
{
for
i
:=
0
;
i
<
t
.
NumMethods
();
i
++
{
for
i
:=
0
;
i
<
t
.
NumMethods
();
i
++
{
if
out
.
Methods
==
nil
{
if
out
.
Methods
==
nil
{
out
.
Methods
=
map
[
string
]
*
types
.
Type
{}
out
.
Methods
=
map
[
string
]
*
types
.
Type
{}
}
out
.
Methods
[
t
.
Method
(
i
)
.
Name
()]
=
b
.
walkType
(
u
,
nil
,
t
.
Method
(
i
)
.
Type
())
}
}
out
.
Methods
[
t
.
Method
(
i
)
.
Name
()]
=
b
.
walkType
(
u
,
nil
,
t
.
Method
(
i
)
.
Type
())
}
}
return
out
}
}
return
out
default
:
default
:
out
:=
u
.
Type
(
name
)
out
:=
u
.
Type
(
name
)
if
out
.
Kind
!=
types
.
Unknown
{
if
out
.
Kind
!=
types
.
Unknown
{
...
...
vendor/k8s.io/gengo/types/types.go
View file @
c5059bd7
...
@@ -163,7 +163,7 @@ func (p *Package) Function(funcName string) *Type {
...
@@ -163,7 +163,7 @@ func (p *Package) Function(funcName string) *Type {
return
t
return
t
}
}
// Variable gets the given var
ai
ble Type in this Package. If the variable is
// Variable gets the given var
ia
ble Type in this Package. If the variable is
// not already defined, this will add it. If a variable is added, it's the caller's
// not already defined, this will add it. If a variable is added, it's the caller's
// responsibility to finish construction of the variable by setting Underlying
// responsibility to finish construction of the variable by setting Underlying
// to the correct type.
// to the correct type.
...
...
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