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
997d55d7
Unverified
Commit
997d55d7
authored
May 19, 2016
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Conversions were mutating the internal object
Internal objects can be shared, it is not allowed to mutate an internal object in conversion.
parent
ef952efb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
13 deletions
+22
-13
conversion.go
pkg/api/v1/conversion.go
+22
-13
No files found.
pkg/api/v1/conversion.go
View file @
997d55d7
...
...
@@ -274,15 +274,14 @@ func Convert_api_PodStatusResult_To_v1_PodStatusResult(in *api.PodStatusResult,
}
out
.
Annotations
[
PodInitContainerStatusesAnnotationKey
]
=
string
(
value
)
}
else
{
delete
(
in
.
Annotations
,
PodInitContainerStatusesAnnotationKey
)
delete
(
out
.
Annotations
,
PodInitContainerStatusesAnnotationKey
)
}
return
nil
}
func
Convert_v1_PodStatusResult_To_api_PodStatusResult
(
in
*
PodStatusResult
,
out
*
api
.
PodStatusResult
,
s
conversion
.
Scope
)
error
{
// TODO: when we move init container to beta, remove these conversions
if
value
:=
in
.
Annotations
[
PodInitContainerStatusesAnnotationKey
];
len
(
value
)
>
0
{
delete
(
in
.
Annotations
,
PodInitContainerStatusesAnnotationKey
)
if
value
,
ok
:=
in
.
Annotations
[
PodInitContainerStatusesAnnotationKey
];
ok
{
var
values
[]
ContainerStatus
if
err
:=
json
.
Unmarshal
([]
byte
(
value
),
&
values
);
err
!=
nil
{
return
err
...
...
@@ -290,7 +289,11 @@ func Convert_v1_PodStatusResult_To_api_PodStatusResult(in *PodStatusResult, out
in
.
Status
.
InitContainerStatuses
=
values
}
return
autoConvert_v1_PodStatusResult_To_api_PodStatusResult
(
in
,
out
,
s
)
if
err
:=
autoConvert_v1_PodStatusResult_To_api_PodStatusResult
(
in
,
out
,
s
);
err
!=
nil
{
return
err
}
delete
(
out
.
Annotations
,
PodInitContainerStatusesAnnotationKey
)
return
nil
}
func
Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec
(
in
*
api
.
PodTemplateSpec
,
out
*
PodTemplateSpec
,
s
conversion
.
Scope
)
error
{
...
...
@@ -316,8 +319,7 @@ func Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec(in *api.PodTemplateSpec,
func
Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec
(
in
*
PodTemplateSpec
,
out
*
api
.
PodTemplateSpec
,
s
conversion
.
Scope
)
error
{
// TODO: when we move init container to beta, remove these conversions
if
value
:=
in
.
Annotations
[
PodInitContainersAnnotationKey
];
len
(
value
)
>
0
{
delete
(
in
.
Annotations
,
PodInitContainersAnnotationKey
)
if
value
,
ok
:=
in
.
Annotations
[
PodInitContainersAnnotationKey
];
ok
{
var
values
[]
Container
if
err
:=
json
.
Unmarshal
([]
byte
(
value
),
&
values
);
err
!=
nil
{
return
err
...
...
@@ -325,7 +327,11 @@ func Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(in *PodTemplateSpec, out
in
.
Spec
.
InitContainers
=
values
}
return
autoConvert_v1_PodTemplateSpec_To_api_PodTemplateSpec
(
in
,
out
,
s
)
if
err
:=
autoConvert_v1_PodTemplateSpec_To_api_PodTemplateSpec
(
in
,
out
,
s
);
err
!=
nil
{
return
err
}
delete
(
out
.
Annotations
,
PodInitContainersAnnotationKey
)
return
nil
}
// The following two PodSpec conversions are done here to support ServiceAccount
...
...
@@ -533,7 +539,7 @@ func Convert_api_Pod_To_v1_Pod(in *api.Pod, out *Pod, s conversion.Scope) error
}
out
.
Annotations
[
PodInitContainerStatusesAnnotationKey
]
=
string
(
value
)
}
else
{
delete
(
in
.
Annotations
,
PodInitContainerStatusesAnnotationKey
)
delete
(
out
.
Annotations
,
PodInitContainerStatusesAnnotationKey
)
}
// We need to reset certain fields for mirror pods from pre-v1.1 kubelet
...
...
@@ -552,16 +558,14 @@ func Convert_api_Pod_To_v1_Pod(in *api.Pod, out *Pod, s conversion.Scope) error
func
Convert_v1_Pod_To_api_Pod
(
in
*
Pod
,
out
*
api
.
Pod
,
s
conversion
.
Scope
)
error
{
// TODO: when we move init container to beta, remove these conversions
if
value
:=
in
.
Annotations
[
PodInitContainersAnnotationKey
];
len
(
value
)
>
0
{
delete
(
in
.
Annotations
,
PodInitContainersAnnotationKey
)
if
value
,
ok
:=
in
.
Annotations
[
PodInitContainersAnnotationKey
];
ok
{
var
values
[]
Container
if
err
:=
json
.
Unmarshal
([]
byte
(
value
),
&
values
);
err
!=
nil
{
return
err
}
in
.
Spec
.
InitContainers
=
values
}
if
value
:=
in
.
Annotations
[
PodInitContainerStatusesAnnotationKey
];
len
(
value
)
>
0
{
delete
(
in
.
Annotations
,
PodInitContainerStatusesAnnotationKey
)
if
value
,
ok
:=
in
.
Annotations
[
PodInitContainerStatusesAnnotationKey
];
ok
{
var
values
[]
ContainerStatus
if
err
:=
json
.
Unmarshal
([]
byte
(
value
),
&
values
);
err
!=
nil
{
return
err
...
...
@@ -569,7 +573,12 @@ func Convert_v1_Pod_To_api_Pod(in *Pod, out *api.Pod, s conversion.Scope) error
in
.
Status
.
InitContainerStatuses
=
values
}
return
autoConvert_v1_Pod_To_api_Pod
(
in
,
out
,
s
)
if
err
:=
autoConvert_v1_Pod_To_api_Pod
(
in
,
out
,
s
);
err
!=
nil
{
return
err
}
delete
(
out
.
Annotations
,
PodInitContainersAnnotationKey
)
delete
(
out
.
Annotations
,
PodInitContainerStatusesAnnotationKey
)
return
nil
}
func
Convert_api_ServiceSpec_To_v1_ServiceSpec
(
in
*
api
.
ServiceSpec
,
out
*
ServiceSpec
,
s
conversion
.
Scope
)
error
{
...
...
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