Internal rename api.Minion -> api.Node

This commit is contained in:
Clayton Coleman
2014-12-07 22:44:27 -05:00
parent 650aead4c4
commit 19379b5a38
38 changed files with 212 additions and 213 deletions

View File

@@ -31,8 +31,8 @@ func init() {
&ReplicationController{},
&ServiceList{},
&Service{},
&MinionList{},
&Minion{},
&NodeList{},
&Node{},
&Status{},
&ServerOpList{},
&ServerOp{},
@@ -47,8 +47,8 @@ func init() {
&BoundPods{},
)
// Legacy names are supported
Scheme.AddKnownTypeWithName("", "Node", &Minion{})
Scheme.AddKnownTypeWithName("", "NodeList", &MinionList{})
Scheme.AddKnownTypeWithName("", "Minion", &Node{})
Scheme.AddKnownTypeWithName("", "MinionList", &NodeList{})
}
func (*Pod) IsAnAPIObject() {}
@@ -59,8 +59,8 @@ func (*Service) IsAnAPIObject() {}
func (*ServiceList) IsAnAPIObject() {}
func (*Endpoints) IsAnAPIObject() {}
func (*EndpointsList) IsAnAPIObject() {}
func (*Minion) IsAnAPIObject() {}
func (*MinionList) IsAnAPIObject() {}
func (*Node) IsAnAPIObject() {}
func (*NodeList) IsAnAPIObject() {}
func (*Binding) IsAnAPIObject() {}
func (*Status) IsAnAPIObject() {}
func (*ServerOp) IsAnAPIObject() {}

View File

@@ -672,10 +672,9 @@ type ResourceName string
type ResourceList map[ResourceName]util.IntOrString
// Minion is a worker node in Kubernetenes
// The name of the minion according to etcd is in ObjectMeta.Name.
// TODO: Rename to Node
type Minion struct {
// Node is a worker node in Kubernetenes
// The name of the node according to etcd is in ObjectMeta.Name.
type Node struct {
TypeMeta `json:",inline"`
ObjectMeta `json:"metadata,omitempty"`
@@ -686,12 +685,12 @@ type Minion struct {
Status NodeStatus `json:"status,omitempty"`
}
// MinionList is a list of minions.
type MinionList struct {
// NodeList is a list of minions.
type NodeList struct {
TypeMeta `json:",inline"`
ListMeta `json:"metadata,omitempty"`
Items []Minion `json:"items"`
Items []Node `json:"items"`
}
// Binding is written by a scheduler to cause a pod to be bound to a host.

View File

@@ -137,7 +137,7 @@ func init() {
},
// MinionList.Items had a wrong name in v1beta1
func(in *newer.MinionList, out *MinionList, s conversion.Scope) error {
func(in *newer.NodeList, out *MinionList, s conversion.Scope) error {
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
return err
}
@@ -150,7 +150,7 @@ func init() {
out.Minions = out.Items
return nil
},
func(in *MinionList, out *newer.MinionList, s conversion.Scope) error {
func(in *MinionList, out *newer.NodeList, s conversion.Scope) error {
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
return err
}
@@ -444,7 +444,7 @@ func init() {
return nil
},
func(in *newer.Minion, out *Minion, s conversion.Scope) error {
func(in *newer.Node, out *Minion, s conversion.Scope) error {
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
return err
}
@@ -458,7 +458,7 @@ func init() {
out.HostIP = in.Status.HostIP
return s.Convert(&in.Spec.Capacity, &out.NodeResources.Capacity, 0)
},
func(in *Minion, out *newer.Minion, s conversion.Scope) error {
func(in *Minion, out *newer.Node, s conversion.Scope) error {
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
return err
}

View File

@@ -31,7 +31,7 @@ func TestNodeConversion(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if _, ok := obj.(*newer.Minion); !ok {
if _, ok := obj.(*newer.Node); !ok {
t.Errorf("unexpected type: %#v", obj)
}
@@ -39,7 +39,7 @@ func TestNodeConversion(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if _, ok := obj.(*newer.MinionList); !ok {
if _, ok := obj.(*newer.NodeList); !ok {
t.Errorf("unexpected type: %#v", obj)
}
@@ -141,39 +141,39 @@ func TestMinionListConversionToNew(t *testing.T) {
oldMinion := func(id string) current.Minion {
return current.Minion{TypeMeta: current.TypeMeta{ID: id}}
}
newMinion := func(id string) newer.Minion {
return newer.Minion{ObjectMeta: newer.ObjectMeta{Name: id}}
newMinion := func(id string) newer.Node {
return newer.Node{ObjectMeta: newer.ObjectMeta{Name: id}}
}
oldMinions := []current.Minion{
oldMinion("foo"),
oldMinion("bar"),
}
newMinions := []newer.Minion{
newMinions := []newer.Node{
newMinion("foo"),
newMinion("bar"),
}
table := []struct {
oldML *current.MinionList
newML *newer.MinionList
newML *newer.NodeList
}{
{
oldML: &current.MinionList{Items: oldMinions},
newML: &newer.MinionList{Items: newMinions},
newML: &newer.NodeList{Items: newMinions},
}, {
oldML: &current.MinionList{Minions: oldMinions},
newML: &newer.MinionList{Items: newMinions},
newML: &newer.NodeList{Items: newMinions},
}, {
oldML: &current.MinionList{
Items: oldMinions,
Minions: []current.Minion{oldMinion("baz")},
},
newML: &newer.MinionList{Items: newMinions},
newML: &newer.NodeList{Items: newMinions},
},
}
for _, item := range table {
got := &newer.MinionList{}
got := &newer.NodeList{}
err := Convert(item.oldML, got)
if err != nil {
t.Errorf("Unexpected error: %v", err)
@@ -188,19 +188,19 @@ func TestMinionListConversionToOld(t *testing.T) {
oldMinion := func(id string) current.Minion {
return current.Minion{TypeMeta: current.TypeMeta{ID: id}}
}
newMinion := func(id string) newer.Minion {
return newer.Minion{ObjectMeta: newer.ObjectMeta{Name: id}}
newMinion := func(id string) newer.Node {
return newer.Node{ObjectMeta: newer.ObjectMeta{Name: id}}
}
oldMinions := []current.Minion{
oldMinion("foo"),
oldMinion("bar"),
}
newMinions := []newer.Minion{
newMinions := []newer.Node{
newMinion("foo"),
newMinion("bar"),
}
newML := &newer.MinionList{Items: newMinions}
newML := &newer.NodeList{Items: newMinions}
oldML := &current.MinionList{
Items: oldMinions,
Minions: oldMinions,

View File

@@ -374,7 +374,7 @@ func init() {
return nil
},
func(in *newer.Minion, out *Minion, s conversion.Scope) error {
func(in *newer.Node, out *Minion, s conversion.Scope) error {
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
return err
}
@@ -388,7 +388,7 @@ func init() {
out.HostIP = in.Status.HostIP
return s.Convert(&in.Spec.Capacity, &out.NodeResources.Capacity, 0)
},
func(in *Minion, out *newer.Minion, s conversion.Scope) error {
func(in *Minion, out *newer.Node, s conversion.Scope) error {
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
return err
}

View File

@@ -60,7 +60,7 @@ func TestNodeConversion(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if _, ok := obj.(*newer.Minion); !ok {
if _, ok := obj.(*newer.Node); !ok {
t.Errorf("unexpected type: %#v", obj)
}
@@ -68,7 +68,7 @@ func TestNodeConversion(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if _, ok := obj.(*newer.MinionList); !ok {
if _, ok := obj.(*newer.NodeList); !ok {
t.Errorf("unexpected type: %#v", obj)
}

View File

@@ -28,7 +28,7 @@ func TestNodeConversion(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if _, ok := obj.(*newer.Minion); !ok {
if _, ok := obj.(*newer.Node); !ok {
t.Errorf("unexpected type: %#v", obj)
}
@@ -36,7 +36,7 @@ func TestNodeConversion(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if _, ok := obj.(*newer.MinionList); !ok {
if _, ok := obj.(*newer.NodeList); !ok {
t.Errorf("unexpected type: %#v", obj)
}

View File

@@ -550,7 +550,7 @@ func ValidateBoundPod(pod *api.BoundPod) (errors []error) {
}
// ValidateMinion tests if required fields in the minion are set.
func ValidateMinion(minion *api.Minion) errs.ValidationErrorList {
func ValidateMinion(minion *api.Node) errs.ValidationErrorList {
allErrs := errs.ValidationErrorList{}
if len(minion.Namespace) != 0 {
allErrs = append(allErrs, errs.NewFieldInvalid("namespace", minion.Namespace, ""))
@@ -563,7 +563,7 @@ func ValidateMinion(minion *api.Minion) errs.ValidationErrorList {
}
// ValidateMinionUpdate tests to make sure a minion update can be applied. Modifies oldMinion.
func ValidateMinionUpdate(oldMinion *api.Minion, minion *api.Minion) errs.ValidationErrorList {
func ValidateMinionUpdate(oldMinion *api.Node, minion *api.Node) errs.ValidationErrorList {
allErrs := errs.ValidationErrorList{}
oldMinion.Labels = minion.Labels
if !reflect.DeepEqual(oldMinion, minion) {

View File

@@ -1077,7 +1077,7 @@ func TestValidateBoundPodNoName(t *testing.T) {
func TestValidateMinion(t *testing.T) {
validSelector := map[string]string{"a": "b"}
invalidSelector := map[string]string{"NoUppercaseOrSpecialCharsLike=Equals": "b"}
successCases := []api.Minion{
successCases := []api.Node{
{
ObjectMeta: api.ObjectMeta{
Name: "abc",
@@ -1100,7 +1100,7 @@ func TestValidateMinion(t *testing.T) {
}
}
errorCases := map[string]api.Minion{
errorCases := map[string]api.Node{
"zero-length Name": {
ObjectMeta: api.ObjectMeta{
Name: "",
@@ -1134,45 +1134,45 @@ func TestValidateMinion(t *testing.T) {
func TestValidateMinionUpdate(t *testing.T) {
tests := []struct {
oldMinion api.Minion
minion api.Minion
oldMinion api.Node
minion api.Node
valid bool
}{
{api.Minion{}, api.Minion{}, true},
{api.Minion{
{api.Node{}, api.Node{}, true},
{api.Node{
ObjectMeta: api.ObjectMeta{
Name: "foo"}},
api.Minion{
api.Node{
ObjectMeta: api.ObjectMeta{
Name: "bar"},
}, false},
{api.Minion{
{api.Node{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{"foo": "bar"},
},
}, api.Minion{
}, api.Node{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{"foo": "baz"},
},
}, true},
{api.Minion{
{api.Node{
ObjectMeta: api.ObjectMeta{
Name: "foo",
},
}, api.Minion{
}, api.Node{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{"foo": "baz"},
},
}, true},
{api.Minion{
{api.Node{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{"bar": "foo"},
},
}, api.Minion{
}, api.Node{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{"foo": "baz"},