refactor: use metav1.ObjectMeta in other types

This commit is contained in:
Clayton Coleman
2017-01-16 22:38:19 -05:00
parent 5a5d31555b
commit 9a2a50cda7
822 changed files with 11914 additions and 9290 deletions

View File

@@ -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"
@@ -32,13 +33,13 @@ import (
func TestValidateAnnotationOverwrites(t *testing.T) {
tests := []struct {
meta *api.ObjectMeta
meta *metav1.ObjectMeta
annotations map[string]string
expectErr bool
scenario string
}{
{
meta: &api.ObjectMeta{
meta: &metav1.ObjectMeta{
Annotations: map[string]string{
"a": "A",
"b": "B",
@@ -52,7 +53,7 @@ func TestValidateAnnotationOverwrites(t *testing.T) {
expectErr: true,
},
{
meta: &api.ObjectMeta{
meta: &metav1.ObjectMeta{
Annotations: map[string]string{
"a": "A",
"c": "C",
@@ -66,7 +67,7 @@ func TestValidateAnnotationOverwrites(t *testing.T) {
expectErr: true,
},
{
meta: &api.ObjectMeta{
meta: &metav1.ObjectMeta{
Annotations: map[string]string{
"a": "A",
"c": "C",
@@ -79,7 +80,7 @@ func TestValidateAnnotationOverwrites(t *testing.T) {
scenario: "no overlap",
},
{
meta: &api.ObjectMeta{},
meta: &metav1.ObjectMeta{},
annotations: map[string]string{
"a": "A",
"b": "B",
@@ -214,7 +215,7 @@ func TestUpdateAnnotations(t *testing.T) {
}{
{
obj: &api.Pod{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{"a": "b"},
},
},
@@ -223,41 +224,41 @@ func TestUpdateAnnotations(t *testing.T) {
},
{
obj: &api.Pod{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{"a": "b"},
},
},
annotations: map[string]string{"a": "c"},
overwrite: true,
expected: &api.Pod{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{"a": "c"},
},
},
},
{
obj: &api.Pod{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{"a": "b"},
},
},
annotations: map[string]string{"c": "d"},
expected: &api.Pod{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{"a": "b", "c": "d"},
},
},
},
{
obj: &api.Pod{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{"a": "b"},
},
},
annotations: map[string]string{"c": "d"},
version: "2",
expected: &api.Pod{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{"a": "b", "c": "d"},
ResourceVersion: "2",
},
@@ -265,28 +266,28 @@ func TestUpdateAnnotations(t *testing.T) {
},
{
obj: &api.Pod{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{"a": "b"},
},
},
annotations: map[string]string{},
remove: []string{"a"},
expected: &api.Pod{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{},
},
},
},
{
obj: &api.Pod{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{"a": "b", "c": "d"},
},
},
annotations: map[string]string{"e": "f"},
remove: []string{"a"},
expected: &api.Pod{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"c": "d",
"e": "f",
@@ -296,14 +297,14 @@ func TestUpdateAnnotations(t *testing.T) {
},
{
obj: &api.Pod{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{"a": "b", "c": "d"},
},
},
annotations: map[string]string{"e": "f"},
remove: []string{"g"},
expected: &api.Pod{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"a": "b",
"c": "d",
@@ -314,13 +315,13 @@ func TestUpdateAnnotations(t *testing.T) {
},
{
obj: &api.Pod{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{"a": "b", "c": "d"},
},
},
remove: []string{"e"},
expected: &api.Pod{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"a": "b",
"c": "d",
@@ -330,11 +331,11 @@ func TestUpdateAnnotations(t *testing.T) {
},
{
obj: &api.Pod{
ObjectMeta: api.ObjectMeta{},
ObjectMeta: metav1.ObjectMeta{},
},
annotations: map[string]string{"a": "b"},
expected: &api.Pod{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{"a": "b"},
},
},