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
42e7ecda
Commit
42e7ecda
authored
Mar 23, 2016
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bunch of issues with conversion generator.
parent
2777cd7e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
62 additions
and
41 deletions
+62
-41
conversion.go
cmd/libs/go2idl/conversion-gen/generators/conversion.go
+0
-0
main.go
cmd/libs/go2idl/conversion-gen/main.go
+2
-0
snippet_writer.go
cmd/libs/go2idl/generator/snippet_writer.go
+3
-0
types.go
cmd/libs/go2idl/types/types.go
+9
-0
run-codegen.sh
hack/after-build/run-codegen.sh
+3
-0
update-codegen.sh
hack/update-codegen.sh
+1
-0
conversion_generated.go
pkg/api/v1/conversion_generated.go
+2
-2
embedded.go
pkg/runtime/embedded.go
+42
-39
No files found.
cmd/libs/go2idl/conversion-gen/generators/conversion.go
View file @
42e7ecda
This diff is collapsed.
Click to expand it.
cmd/libs/go2idl/conversion-gen/main.go
View file @
42e7ecda
...
@@ -34,6 +34,8 @@ func main() {
...
@@ -34,6 +34,8 @@ func main() {
// Override defaults. These are Kubernetes specific input locations.
// Override defaults. These are Kubernetes specific input locations.
arguments
.
InputDirs
=
[]
string
{
arguments
.
InputDirs
=
[]
string
{
"k8s.io/kubernetes/pkg/api/v1"
,
"k8s.io/kubernetes/pkg/api/v1"
,
"k8s.io/kubernetes/pkg/api"
,
"k8s.io/kubernetes/pkg/runtime"
,
}
}
if
err
:=
arguments
.
Execute
(
if
err
:=
arguments
.
Execute
(
...
...
cmd/libs/go2idl/generator/snippet_writer.go
View file @
42e7ecda
...
@@ -93,6 +93,9 @@ func NewSnippetWriter(w io.Writer, c *Context, left, right string) *SnippetWrite
...
@@ -93,6 +93,9 @@ func NewSnippetWriter(w io.Writer, c *Context, left, right string) *SnippetWrite
// becomes a requirement. You can do arbitrary logic inside these templates,
// becomes a requirement. You can do arbitrary logic inside these templates,
// but you should consider doing the logic in go and stitching them together
// but you should consider doing the logic in go and stitching them together
// for the sake of your readers.
// for the sake of your readers.
//
// TODO: Change Do() to optionally take a list of pairt of parameters (key, value)
// and have it construct a combined map with that and args.
func
(
s
*
SnippetWriter
)
Do
(
format
string
,
args
interface
{})
*
SnippetWriter
{
func
(
s
*
SnippetWriter
)
Do
(
format
string
,
args
interface
{})
*
SnippetWriter
{
if
s
.
err
!=
nil
{
if
s
.
err
!=
nil
{
return
s
return
s
...
...
cmd/libs/go2idl/types/types.go
View file @
42e7ecda
...
@@ -417,3 +417,12 @@ var (
...
@@ -417,3 +417,12 @@ var (
Name
:
""
,
Name
:
""
,
}
}
)
)
func
IsInteger
(
t
*
Type
)
bool
{
switch
t
{
case
Int
,
Int64
,
Int32
,
Int16
,
Uint
,
Uint64
,
Uint32
,
Uint16
,
Byte
:
return
true
default
:
return
false
}
}
hack/after-build/run-codegen.sh
View file @
42e7ecda
...
@@ -24,6 +24,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
...
@@ -24,6 +24,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
kube::golang::setup_env
kube::golang::setup_env
clientgen
=
$(
kube::util::find-binary
"client-gen"
)
clientgen
=
$(
kube::util::find-binary
"client-gen"
)
conversiongen
=
$(
kube::util::find-binary
"conversion-gen"
)
deepcopygen
=
$(
kube::util::find-binary
"deepcopy-gen"
)
deepcopygen
=
$(
kube::util::find-binary
"deepcopy-gen"
)
setgen
=
$(
kube::util::find-binary
"set-gen"
)
setgen
=
$(
kube::util::find-binary
"set-gen"
)
...
@@ -34,6 +35,8 @@ setgen=$(kube::util::find-binary "set-gen")
...
@@ -34,6 +35,8 @@ setgen=$(kube::util::find-binary "set-gen")
# update- and verify- scripts.
# update- and verify- scripts.
${
clientgen
}
"
$@
"
${
clientgen
}
"
$@
"
${
clientgen
}
-t
"
$@
"
${
clientgen
}
-t
"
$@
"
# TODO: Enable when conversion generator is ready.
# ${conversiongen} "$@"
${
deepcopygen
}
"
$@
"
${
deepcopygen
}
"
$@
"
${
setgen
}
"
$@
"
${
setgen
}
"
$@
"
...
...
hack/update-codegen.sh
View file @
42e7ecda
...
@@ -26,6 +26,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
...
@@ -26,6 +26,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
kube::golang::setup_env
kube::golang::setup_env
"
${
KUBE_ROOT
}
/hack/build-go.sh"
cmd/libs/go2idl/client-gen
"
${
KUBE_ROOT
}
/hack/build-go.sh"
cmd/libs/go2idl/client-gen
"
${
KUBE_ROOT
}
/hack/build-go.sh"
cmd/libs/go2idl/conversion-gen
"
${
KUBE_ROOT
}
/hack/build-go.sh"
cmd/libs/go2idl/deepcopy-gen
"
${
KUBE_ROOT
}
/hack/build-go.sh"
cmd/libs/go2idl/deepcopy-gen
"
${
KUBE_ROOT
}
/hack/build-go.sh"
cmd/libs/go2idl/set-gen
"
${
KUBE_ROOT
}
/hack/build-go.sh"
cmd/libs/go2idl/set-gen
...
...
pkg/api/v1/conversion_generated.go
View file @
42e7ecda
...
@@ -1298,7 +1298,7 @@ func autoConvert_api_List_To_v1_List(in *api.List, out *List, s conversion.Scope
...
@@ -1298,7 +1298,7 @@ func autoConvert_api_List_To_v1_List(in *api.List, out *List, s conversion.Scope
if
in
.
Items
!=
nil
{
if
in
.
Items
!=
nil
{
out
.
Items
=
make
([]
runtime
.
RawExtension
,
len
(
in
.
Items
))
out
.
Items
=
make
([]
runtime
.
RawExtension
,
len
(
in
.
Items
))
for
i
:=
range
in
.
Items
{
for
i
:=
range
in
.
Items
{
if
err
:=
s
.
Convert
(
&
in
.
Items
[
i
],
&
out
.
Items
[
i
],
0
);
err
!=
nil
{
if
err
:=
runtime
.
Convert_runtime_Object_To_runtime_RawExtension
(
&
in
.
Items
[
i
],
&
out
.
Items
[
i
],
s
);
err
!=
nil
{
return
err
return
err
}
}
}
}
...
@@ -4571,7 +4571,7 @@ func autoConvert_v1_List_To_api_List(in *List, out *api.List, s conversion.Scope
...
@@ -4571,7 +4571,7 @@ func autoConvert_v1_List_To_api_List(in *List, out *api.List, s conversion.Scope
if
in
.
Items
!=
nil
{
if
in
.
Items
!=
nil
{
out
.
Items
=
make
([]
runtime
.
Object
,
len
(
in
.
Items
))
out
.
Items
=
make
([]
runtime
.
Object
,
len
(
in
.
Items
))
for
i
:=
range
in
.
Items
{
for
i
:=
range
in
.
Items
{
if
err
:=
s
.
Convert
(
&
in
.
Items
[
i
],
&
out
.
Items
[
i
],
0
);
err
!=
nil
{
if
err
:=
runtime
.
Convert_runtime_RawExtension_To_runtime_Object
(
&
in
.
Items
[
i
],
&
out
.
Items
[
i
],
s
);
err
!=
nil
{
return
err
return
err
}
}
}
}
...
...
pkg/runtime/embedded.go
View file @
42e7ecda
...
@@ -88,46 +88,49 @@ func (re Unknown) MarshalJSON() ([]byte, error) {
...
@@ -88,46 +88,49 @@ func (re Unknown) MarshalJSON() ([]byte, error) {
return
re
.
Raw
,
nil
return
re
.
Raw
,
nil
}
}
func
Convert_runtime_Object_To_runtime_RawExtension
(
in
*
Object
,
out
*
RawExtension
,
s
conversion
.
Scope
)
error
{
if
in
==
nil
{
out
.
Raw
=
[]
byte
(
"null"
)
return
nil
}
obj
:=
*
in
if
unk
,
ok
:=
obj
.
(
*
Unknown
);
ok
{
if
unk
.
Raw
!=
nil
{
out
.
Raw
=
unk
.
Raw
return
nil
}
obj
=
out
.
Object
}
if
obj
==
nil
{
out
.
Raw
=
nil
return
nil
}
out
.
Object
=
obj
return
nil
}
func
Convert_runtime_RawExtension_To_runtime_Object
(
in
*
RawExtension
,
out
*
Object
,
s
conversion
.
Scope
)
error
{
if
in
.
Object
!=
nil
{
*
out
=
in
.
Object
return
nil
}
data
:=
in
.
Raw
if
len
(
data
)
==
0
||
(
len
(
data
)
==
4
&&
string
(
data
)
==
"null"
)
{
*
out
=
nil
return
nil
}
*
out
=
&
Unknown
{
Raw
:
data
,
// TODO: Set ContentEncoding and ContentType appropriately.
// Currently we set ContentTypeJSON to make tests passing.
ContentType
:
ContentTypeJSON
,
}
return
nil
}
func
DefaultEmbeddedConversions
()
[]
interface
{}
{
func
DefaultEmbeddedConversions
()
[]
interface
{}
{
return
[]
interface
{}{
return
[]
interface
{}{
func
(
in
*
Object
,
out
*
RawExtension
,
s
conversion
.
Scope
)
error
{
Convert_runtime_Object_To_runtime_RawExtension
,
if
in
==
nil
{
Convert_runtime_RawExtension_To_runtime_Object
,
out
.
Raw
=
[]
byte
(
"null"
)
return
nil
}
obj
:=
*
in
if
unk
,
ok
:=
obj
.
(
*
Unknown
);
ok
{
if
unk
.
Raw
!=
nil
{
out
.
Raw
=
unk
.
Raw
return
nil
}
obj
=
out
.
Object
}
if
obj
==
nil
{
out
.
Raw
=
nil
return
nil
}
out
.
Object
=
obj
return
nil
},
func
(
in
*
RawExtension
,
out
*
Object
,
s
conversion
.
Scope
)
error
{
if
in
.
Object
!=
nil
{
*
out
=
in
.
Object
return
nil
}
data
:=
in
.
Raw
if
len
(
data
)
==
0
||
(
len
(
data
)
==
4
&&
string
(
data
)
==
"null"
)
{
*
out
=
nil
return
nil
}
*
out
=
&
Unknown
{
Raw
:
data
,
// TODO: Set ContentEncoding and ContentType appropriately.
// Currently we set ContentTypeJSON to make tests passing.
ContentType
:
ContentTypeJSON
,
}
return
nil
},
}
}
}
}
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