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
f290819f
Unverified
Commit
f290819f
authored
Sep 27, 2017
by
Anthony Yeh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix loss of selector during RC/RS conversion.
The `out` parameter in Convert_map_to_unversioned_LabelSelector was being ignored.
parent
5adfb24f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
1 deletion
+54
-1
BUILD
pkg/api/v1/BUILD
+1
-0
conversion.go
pkg/api/v1/conversion.go
+1
-0
conversion_test.go
pkg/api/v1/conversion_test.go
+52
-0
conversion.go
...ng/src/k8s.io/apimachinery/pkg/apis/meta/v1/conversion.go
+0
-1
No files found.
pkg/api/v1/BUILD
View file @
f290819f
...
...
@@ -46,6 +46,7 @@ go_test(
"//pkg/api:go_default_library",
"//pkg/api/legacyscheme:go_default_library",
"//pkg/api/testapi:go_default_library",
"//pkg/apis/extensions:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
...
...
pkg/api/v1/conversion.go
View file @
f290819f
...
...
@@ -236,6 +236,7 @@ func Convert_v1_ReplicationController_to_extensions_ReplicaSet(in *v1.Replicatio
func
Convert_v1_ReplicationControllerSpec_to_extensions_ReplicaSetSpec
(
in
*
v1
.
ReplicationControllerSpec
,
out
*
extensions
.
ReplicaSetSpec
,
s
conversion
.
Scope
)
error
{
out
.
Replicas
=
*
in
.
Replicas
if
in
.
Selector
!=
nil
{
out
.
Selector
=
new
(
metav1
.
LabelSelector
)
metav1
.
Convert_map_to_unversioned_LabelSelector
(
&
in
.
Selector
,
out
.
Selector
,
s
)
}
if
in
.
Template
!=
nil
{
...
...
pkg/api/v1/conversion_test.go
View file @
f290819f
...
...
@@ -17,6 +17,7 @@ limitations under the License.
package
v1_test
import
(
"encoding/json"
"net/url"
"reflect"
"testing"
...
...
@@ -31,6 +32,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/legacyscheme"
k8s_api_v1
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/extensions"
// enforce that all types are installed
_
"k8s.io/kubernetes/pkg/api/testapi"
...
...
@@ -226,3 +228,53 @@ func TestResourceListConversion(t *testing.T) {
}
}
}
func
TestReplicationControllerConversion
(
t
*
testing
.
T
)
{
// If we start with a RC, we should always have round-trip fidelity.
replicas
:=
int32
(
1
)
in
:=
&
v1
.
ReplicationController
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"name"
,
Namespace
:
"namespace"
,
},
Spec
:
v1
.
ReplicationControllerSpec
{
Replicas
:
&
replicas
,
Selector
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"bar"
:
"foo"
},
Template
:
&
v1
.
PodTemplateSpec
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"bar"
:
"foo"
},
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{
{
Name
:
"container"
,
Image
:
"image"
,
},
},
},
},
},
Status
:
v1
.
ReplicationControllerStatus
{
Replicas
:
1
,
FullyLabeledReplicas
:
2
,
ReadyReplicas
:
3
,
AvailableReplicas
:
4
,
ObservedGeneration
:
5
,
Conditions
:
[]
v1
.
ReplicationControllerCondition
{},
},
}
in
=
roundTrip
(
t
,
in
)
.
(
*
v1
.
ReplicationController
)
rs
:=
&
extensions
.
ReplicaSet
{}
if
err
:=
k8s_api_v1
.
Convert_v1_ReplicationController_to_extensions_ReplicaSet
(
in
,
rs
,
nil
);
err
!=
nil
{
t
.
Fatalf
(
"can't convert RC to RS: %v"
,
err
)
}
out
:=
&
v1
.
ReplicationController
{}
if
err
:=
k8s_api_v1
.
Convert_extensions_ReplicaSet_to_v1_ReplicationController
(
rs
,
out
,
nil
);
err
!=
nil
{
t
.
Fatalf
(
"can't convert RS to RC: %v"
,
err
)
}
if
!
apiequality
.
Semantic
.
DeepEqual
(
in
,
out
)
{
instr
,
_
:=
json
.
MarshalIndent
(
in
,
""
,
" "
)
outstr
,
_
:=
json
.
MarshalIndent
(
out
,
""
,
" "
)
t
.
Errorf
(
"RC-RS conversion round-trip failed:
\n
in:
\n
%s
\n
out:
\n
%s"
,
instr
,
outstr
)
}
}
staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/conversion.go
View file @
f290819f
...
...
@@ -252,7 +252,6 @@ func Convert_map_to_unversioned_LabelSelector(in *map[string]string, out *LabelS
if
in
==
nil
{
return
nil
}
out
=
new
(
LabelSelector
)
for
labelKey
,
labelValue
:=
range
*
in
{
AddLabelToSelector
(
out
,
labelKey
,
labelValue
)
}
...
...
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