mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 06:54:01 +00:00
Merge pull request #1102 from lavalamp/fixApi
Fix incorrect tag in MinionList
This commit is contained in:
commit
821f9bd5e7
@ -61,6 +61,23 @@ func init() {
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
||||
// MinionList.Items had a wrong name in v1beta1
|
||||
func(in *MinionList, out *v1beta1.MinionList) error {
|
||||
Convert(&in.JSONBase, &out.JSONBase)
|
||||
Convert(&in.Items, &out.Items)
|
||||
out.Minions = out.Items
|
||||
return nil
|
||||
},
|
||||
func(in *v1beta1.MinionList, out *MinionList) error {
|
||||
Convert(&in.JSONBase, &out.JSONBase)
|
||||
if len(in.Items) == 0 {
|
||||
Convert(&in.Minions, &out.Items)
|
||||
} else {
|
||||
Convert(&in.Items, &out.Items)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
}
|
||||
|
@ -110,3 +110,82 @@ func TestVolumeMountConversionToNew(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMinionListConversionToNew(t *testing.T) {
|
||||
oldMinion := func(id string) v1beta1.Minion {
|
||||
return v1beta1.Minion{JSONBase: v1beta1.JSONBase{ID: id}}
|
||||
}
|
||||
newMinion := func(id string) Minion {
|
||||
return Minion{JSONBase: JSONBase{ID: id}}
|
||||
}
|
||||
oldMinions := []v1beta1.Minion{
|
||||
oldMinion("foo"),
|
||||
oldMinion("bar"),
|
||||
}
|
||||
newMinions := []Minion{
|
||||
newMinion("foo"),
|
||||
newMinion("bar"),
|
||||
}
|
||||
|
||||
table := []struct {
|
||||
oldML *v1beta1.MinionList
|
||||
newML *MinionList
|
||||
}{
|
||||
{
|
||||
oldML: &v1beta1.MinionList{Items: oldMinions},
|
||||
newML: &MinionList{Items: newMinions},
|
||||
}, {
|
||||
oldML: &v1beta1.MinionList{Minions: oldMinions},
|
||||
newML: &MinionList{Items: newMinions},
|
||||
}, {
|
||||
oldML: &v1beta1.MinionList{
|
||||
Items: oldMinions,
|
||||
Minions: []v1beta1.Minion{oldMinion("baz")},
|
||||
},
|
||||
newML: &MinionList{Items: newMinions},
|
||||
},
|
||||
}
|
||||
|
||||
for _, item := range table {
|
||||
got := &MinionList{}
|
||||
err := Convert(item.oldML, got)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
if e, a := item.newML, got; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("Expected: %#v, got %#v", e, a)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMinionListConversionToOld(t *testing.T) {
|
||||
oldMinion := func(id string) v1beta1.Minion {
|
||||
return v1beta1.Minion{JSONBase: v1beta1.JSONBase{ID: id}}
|
||||
}
|
||||
newMinion := func(id string) Minion {
|
||||
return Minion{JSONBase: JSONBase{ID: id}}
|
||||
}
|
||||
oldMinions := []v1beta1.Minion{
|
||||
oldMinion("foo"),
|
||||
oldMinion("bar"),
|
||||
}
|
||||
newMinions := []Minion{
|
||||
newMinion("foo"),
|
||||
newMinion("bar"),
|
||||
}
|
||||
|
||||
newML := &MinionList{Items: newMinions}
|
||||
oldML := &v1beta1.MinionList{
|
||||
Items: oldMinions,
|
||||
Minions: oldMinions,
|
||||
}
|
||||
|
||||
got := &v1beta1.MinionList{}
|
||||
err := Convert(newML, got)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
if e, a := oldML, got; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("Expected: %#v, got %#v", e, a)
|
||||
}
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ type Minion struct {
|
||||
// MinionList is a list of minions.
|
||||
type MinionList struct {
|
||||
JSONBase `json:",inline" yaml:",inline"`
|
||||
Items []Minion `json:"minions,omitempty" yaml:"minions,omitempty"`
|
||||
Items []Minion `json:"items,omitempty" yaml:"items,omitempty"`
|
||||
}
|
||||
|
||||
// Binding is written by a scheduler to cause a pod to be bound to a host.
|
||||
|
@ -349,7 +349,10 @@ type Minion struct {
|
||||
// MinionList is a list of minions.
|
||||
type MinionList struct {
|
||||
JSONBase `json:",inline" yaml:",inline"`
|
||||
Items []Minion `json:"minions,omitempty" yaml:"minions,omitempty"`
|
||||
// DEPRECATED: the below Minions is due to a naming mistake and
|
||||
// will be replaced with Items in the future.
|
||||
Minions []Minion `json:"minions,omitempty" yaml:"minions,omitempty"`
|
||||
Items []Minion `json:"items,omitempty" yaml:"items,omitempty"`
|
||||
}
|
||||
|
||||
// Binding is written by a scheduler to cause a pod to be bound to a host.
|
||||
|
Loading…
Reference in New Issue
Block a user