mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 07:27:21 +00:00
v1beta1 should return Minion as kind, rather than Node
This changes the internal name logic (for conversion) to prefer the internal registered preferred name for a resource, and then makes v1beta1 and v1beta2 prefer Minion. Fixes #3010
This commit is contained in:
@@ -17,10 +17,11 @@ limitations under the License.
|
||||
package v1beta2_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
newer "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
current "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
||||
current "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta2"
|
||||
)
|
||||
|
||||
func TestServiceEmptySelector(t *testing.T) {
|
||||
@@ -56,6 +57,15 @@ func TestServiceEmptySelector(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNodeConversion(t *testing.T) {
|
||||
version, kind, err := newer.Scheme.ObjectVersionAndKind(¤t.Minion{})
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if version != "v1beta2" || kind != "Minion" {
|
||||
t.Errorf("unexpected version and kind: %s %s", version, kind)
|
||||
}
|
||||
|
||||
newer.Scheme.Log(t)
|
||||
obj, err := current.Codec.Decode([]byte(`{"kind":"Node","apiVersion":"v1beta2"}`))
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
@@ -76,4 +86,17 @@ func TestNodeConversion(t *testing.T) {
|
||||
if err := current.Codec.DecodeInto([]byte(`{"kind":"Node","apiVersion":"v1beta2"}`), obj); err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
obj = &newer.Node{}
|
||||
data, err := current.Codec.Encode(obj)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
m := map[string]interface{}{}
|
||||
if err := json.Unmarshal(data, &m); err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if m["kind"] != "Minion" {
|
||||
t.Errorf("unexpected encoding: %s - %#v", m["kind"], string(data))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user