mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 07:57:35 +00:00
refactor: use metav1.ObjectMeta in other types
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/client/restclient"
|
||||
@@ -33,13 +34,13 @@ import (
|
||||
|
||||
func TestValidateLabels(t *testing.T) {
|
||||
tests := []struct {
|
||||
meta *api.ObjectMeta
|
||||
meta *metav1.ObjectMeta
|
||||
labels map[string]string
|
||||
expectErr bool
|
||||
test string
|
||||
}{
|
||||
{
|
||||
meta: &api.ObjectMeta{
|
||||
meta: &metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"a": "b",
|
||||
"c": "d",
|
||||
@@ -53,7 +54,7 @@ func TestValidateLabels(t *testing.T) {
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
meta: &api.ObjectMeta{
|
||||
meta: &metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"a": "b",
|
||||
"c": "d",
|
||||
@@ -67,7 +68,7 @@ func TestValidateLabels(t *testing.T) {
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
meta: &api.ObjectMeta{
|
||||
meta: &metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"a": "b",
|
||||
"c": "d",
|
||||
@@ -80,7 +81,7 @@ func TestValidateLabels(t *testing.T) {
|
||||
test: "no overlap",
|
||||
},
|
||||
{
|
||||
meta: &api.ObjectMeta{},
|
||||
meta: &metav1.ObjectMeta{},
|
||||
labels: map[string]string{
|
||||
"b": "a",
|
||||
"d": "c",
|
||||
@@ -165,7 +166,7 @@ func TestLabelFunc(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
obj: &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{"a": "b"},
|
||||
},
|
||||
},
|
||||
@@ -174,41 +175,41 @@ func TestLabelFunc(t *testing.T) {
|
||||
},
|
||||
{
|
||||
obj: &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{"a": "b"},
|
||||
},
|
||||
},
|
||||
labels: map[string]string{"a": "c"},
|
||||
overwrite: true,
|
||||
expected: &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{"a": "c"},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
obj: &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{"a": "b"},
|
||||
},
|
||||
},
|
||||
labels: map[string]string{"c": "d"},
|
||||
expected: &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{"a": "b", "c": "d"},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
obj: &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{"a": "b"},
|
||||
},
|
||||
},
|
||||
labels: map[string]string{"c": "d"},
|
||||
version: "2",
|
||||
expected: &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{"a": "b", "c": "d"},
|
||||
ResourceVersion: "2",
|
||||
},
|
||||
@@ -216,28 +217,28 @@ func TestLabelFunc(t *testing.T) {
|
||||
},
|
||||
{
|
||||
obj: &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{"a": "b"},
|
||||
},
|
||||
},
|
||||
labels: map[string]string{},
|
||||
remove: []string{"a"},
|
||||
expected: &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
obj: &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{"a": "b", "c": "d"},
|
||||
},
|
||||
},
|
||||
labels: map[string]string{"e": "f"},
|
||||
remove: []string{"a"},
|
||||
expected: &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"c": "d",
|
||||
"e": "f",
|
||||
@@ -247,11 +248,11 @@ func TestLabelFunc(t *testing.T) {
|
||||
},
|
||||
{
|
||||
obj: &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{},
|
||||
ObjectMeta: metav1.ObjectMeta{},
|
||||
},
|
||||
labels: map[string]string{"a": "b"},
|
||||
expected: &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{"a": "b"},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user