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
c4e239b3
Commit
c4e239b3
authored
May 20, 2016
by
Filip Grzadkowski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #25918 from smarterclayton/init_annotation_mutation
Conversions were mutating the internal object
parents
ab104843
997d55d7
Show 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 @
c4e239b3
...
@@ -272,15 +272,14 @@ func Convert_api_PodStatusResult_To_v1_PodStatusResult(in *api.PodStatusResult,
...
@@ -272,15 +272,14 @@ func Convert_api_PodStatusResult_To_v1_PodStatusResult(in *api.PodStatusResult,
}
}
out
.
Annotations
[
PodInitContainerStatusesAnnotationKey
]
=
string
(
value
)
out
.
Annotations
[
PodInitContainerStatusesAnnotationKey
]
=
string
(
value
)
}
else
{
}
else
{
delete
(
in
.
Annotations
,
PodInitContainerStatusesAnnotationKey
)
delete
(
out
.
Annotations
,
PodInitContainerStatusesAnnotationKey
)
}
}
return
nil
return
nil
}
}
func
Convert_v1_PodStatusResult_To_api_PodStatusResult
(
in
*
PodStatusResult
,
out
*
api
.
PodStatusResult
,
s
conversion
.
Scope
)
error
{
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
// TODO: when we move init container to beta, remove these conversions
if
value
:=
in
.
Annotations
[
PodInitContainerStatusesAnnotationKey
];
len
(
value
)
>
0
{
if
value
,
ok
:=
in
.
Annotations
[
PodInitContainerStatusesAnnotationKey
];
ok
{
delete
(
in
.
Annotations
,
PodInitContainerStatusesAnnotationKey
)
var
values
[]
ContainerStatus
var
values
[]
ContainerStatus
if
err
:=
json
.
Unmarshal
([]
byte
(
value
),
&
values
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
([]
byte
(
value
),
&
values
);
err
!=
nil
{
return
err
return
err
...
@@ -288,7 +287,11 @@ func Convert_v1_PodStatusResult_To_api_PodStatusResult(in *PodStatusResult, out
...
@@ -288,7 +287,11 @@ func Convert_v1_PodStatusResult_To_api_PodStatusResult(in *PodStatusResult, out
in
.
Status
.
InitContainerStatuses
=
values
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
{
func
Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec
(
in
*
api
.
PodTemplateSpec
,
out
*
PodTemplateSpec
,
s
conversion
.
Scope
)
error
{
...
@@ -314,8 +317,7 @@ func Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec(in *api.PodTemplateSpec,
...
@@ -314,8 +317,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
{
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
// TODO: when we move init container to beta, remove these conversions
if
value
:=
in
.
Annotations
[
PodInitContainersAnnotationKey
];
len
(
value
)
>
0
{
if
value
,
ok
:=
in
.
Annotations
[
PodInitContainersAnnotationKey
];
ok
{
delete
(
in
.
Annotations
,
PodInitContainersAnnotationKey
)
var
values
[]
Container
var
values
[]
Container
if
err
:=
json
.
Unmarshal
([]
byte
(
value
),
&
values
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
([]
byte
(
value
),
&
values
);
err
!=
nil
{
return
err
return
err
...
@@ -323,7 +325,11 @@ func Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(in *PodTemplateSpec, out
...
@@ -323,7 +325,11 @@ func Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(in *PodTemplateSpec, out
in
.
Spec
.
InitContainers
=
values
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
// The following two PodSpec conversions are done here to support ServiceAccount
...
@@ -531,7 +537,7 @@ func Convert_api_Pod_To_v1_Pod(in *api.Pod, out *Pod, s conversion.Scope) error
...
@@ -531,7 +537,7 @@ func Convert_api_Pod_To_v1_Pod(in *api.Pod, out *Pod, s conversion.Scope) error
}
}
out
.
Annotations
[
PodInitContainerStatusesAnnotationKey
]
=
string
(
value
)
out
.
Annotations
[
PodInitContainerStatusesAnnotationKey
]
=
string
(
value
)
}
else
{
}
else
{
delete
(
in
.
Annotations
,
PodInitContainerStatusesAnnotationKey
)
delete
(
out
.
Annotations
,
PodInitContainerStatusesAnnotationKey
)
}
}
// We need to reset certain fields for mirror pods from pre-v1.1 kubelet
// We need to reset certain fields for mirror pods from pre-v1.1 kubelet
...
@@ -550,16 +556,14 @@ func Convert_api_Pod_To_v1_Pod(in *api.Pod, out *Pod, s conversion.Scope) error
...
@@ -550,16 +556,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
{
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
// TODO: when we move init container to beta, remove these conversions
if
value
:=
in
.
Annotations
[
PodInitContainersAnnotationKey
];
len
(
value
)
>
0
{
if
value
,
ok
:=
in
.
Annotations
[
PodInitContainersAnnotationKey
];
ok
{
delete
(
in
.
Annotations
,
PodInitContainersAnnotationKey
)
var
values
[]
Container
var
values
[]
Container
if
err
:=
json
.
Unmarshal
([]
byte
(
value
),
&
values
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
([]
byte
(
value
),
&
values
);
err
!=
nil
{
return
err
return
err
}
}
in
.
Spec
.
InitContainers
=
values
in
.
Spec
.
InitContainers
=
values
}
}
if
value
:=
in
.
Annotations
[
PodInitContainerStatusesAnnotationKey
];
len
(
value
)
>
0
{
if
value
,
ok
:=
in
.
Annotations
[
PodInitContainerStatusesAnnotationKey
];
ok
{
delete
(
in
.
Annotations
,
PodInitContainerStatusesAnnotationKey
)
var
values
[]
ContainerStatus
var
values
[]
ContainerStatus
if
err
:=
json
.
Unmarshal
([]
byte
(
value
),
&
values
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
([]
byte
(
value
),
&
values
);
err
!=
nil
{
return
err
return
err
...
@@ -567,7 +571,12 @@ func Convert_v1_Pod_To_api_Pod(in *Pod, out *api.Pod, s conversion.Scope) error
...
@@ -567,7 +571,12 @@ func Convert_v1_Pod_To_api_Pod(in *Pod, out *api.Pod, s conversion.Scope) error
in
.
Status
.
InitContainerStatuses
=
values
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
{
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