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

@ -79,7 +79,7 @@ var parser = kubecfg.NewParser(map[string]runtime.Object{
"pods": &api.Pod{}, "pods": &api.Pod{},
"services": &api.Service{}, "services": &api.Service{},
"replicationControllers": &api.ReplicationController{}, "replicationControllers": &api.ReplicationController{},
"minions": &api.Minion{}, "minions": &api.Node{},
"events": &api.Event{}, "events": &api.Event{},
}) })

View File

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

View File

@ -672,10 +672,9 @@ type ResourceName string
type ResourceList map[ResourceName]util.IntOrString type ResourceList map[ResourceName]util.IntOrString
// Minion is a worker node in Kubernetenes // Node is a worker node in Kubernetenes
// The name of the minion according to etcd is in ObjectMeta.Name. // The name of the node according to etcd is in ObjectMeta.Name.
// TODO: Rename to Node type Node struct {
type Minion struct {
TypeMeta `json:",inline"` TypeMeta `json:",inline"`
ObjectMeta `json:"metadata,omitempty"` ObjectMeta `json:"metadata,omitempty"`
@ -686,12 +685,12 @@ type Minion struct {
Status NodeStatus `json:"status,omitempty"` Status NodeStatus `json:"status,omitempty"`
} }
// MinionList is a list of minions. // NodeList is a list of minions.
type MinionList struct { type NodeList struct {
TypeMeta `json:",inline"` TypeMeta `json:",inline"`
ListMeta `json:"metadata,omitempty"` 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. // 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 // 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 { if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
return err return err
} }
@ -150,7 +150,7 @@ func init() {
out.Minions = out.Items out.Minions = out.Items
return nil 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 { if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
return err return err
} }
@ -444,7 +444,7 @@ func init() {
return nil 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 { if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
return err return err
} }
@ -458,7 +458,7 @@ func init() {
out.HostIP = in.Status.HostIP out.HostIP = in.Status.HostIP
return s.Convert(&in.Spec.Capacity, &out.NodeResources.Capacity, 0) 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 { if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
return err return err
} }

View File

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

View File

@ -374,7 +374,7 @@ func init() {
return nil 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 { if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
return err return err
} }
@ -388,7 +388,7 @@ func init() {
out.HostIP = in.Status.HostIP out.HostIP = in.Status.HostIP
return s.Convert(&in.Spec.Capacity, &out.NodeResources.Capacity, 0) 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 { if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
return err return err
} }

View File

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

View File

@ -28,7 +28,7 @@ func TestNodeConversion(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("unexpected error: %v", err) t.Fatalf("unexpected error: %v", err)
} }
if _, ok := obj.(*newer.Minion); !ok { if _, ok := obj.(*newer.Node); !ok {
t.Errorf("unexpected type: %#v", obj) t.Errorf("unexpected type: %#v", obj)
} }
@ -36,7 +36,7 @@ func TestNodeConversion(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("unexpected error: %v", err) t.Fatalf("unexpected error: %v", err)
} }
if _, ok := obj.(*newer.MinionList); !ok { if _, ok := obj.(*newer.NodeList); !ok {
t.Errorf("unexpected type: %#v", obj) 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. // 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{} allErrs := errs.ValidationErrorList{}
if len(minion.Namespace) != 0 { if len(minion.Namespace) != 0 {
allErrs = append(allErrs, errs.NewFieldInvalid("namespace", minion.Namespace, "")) 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. // 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{} allErrs := errs.ValidationErrorList{}
oldMinion.Labels = minion.Labels oldMinion.Labels = minion.Labels
if !reflect.DeepEqual(oldMinion, minion) { if !reflect.DeepEqual(oldMinion, minion) {

View File

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

View File

@ -604,7 +604,7 @@ func TestGetServerAPIVersions(t *testing.T) {
func TestListMinions(t *testing.T) { func TestListMinions(t *testing.T) {
c := &testClient{ c := &testClient{
Request: testRequest{Method: "GET", Path: "/minions"}, Request: testRequest{Method: "GET", Path: "/minions"},
Response: Response{StatusCode: 200, Body: &api.MinionList{ListMeta: api.ListMeta{ResourceVersion: "1"}}}, Response: Response{StatusCode: 200, Body: &api.NodeList{ListMeta: api.ListMeta{ResourceVersion: "1"}}},
} }
response, err := c.Setup().Minions().List() response, err := c.Setup().Minions().List()
c.Validate(t, response, err) c.Validate(t, response, err)
@ -613,14 +613,14 @@ func TestListMinions(t *testing.T) {
func TestGetMinion(t *testing.T) { func TestGetMinion(t *testing.T) {
c := &testClient{ c := &testClient{
Request: testRequest{Method: "GET", Path: "/minions/1"}, Request: testRequest{Method: "GET", Path: "/minions/1"},
Response: Response{StatusCode: 200, Body: &api.Minion{ObjectMeta: api.ObjectMeta{Name: "minion-1"}}}, Response: Response{StatusCode: 200, Body: &api.Node{ObjectMeta: api.ObjectMeta{Name: "minion-1"}}},
} }
response, err := c.Setup().Minions().Get("1") response, err := c.Setup().Minions().Get("1")
c.Validate(t, response, err) c.Validate(t, response, err)
} }
func TestCreateMinion(t *testing.T) { func TestCreateMinion(t *testing.T) {
requestMinion := &api.Minion{ requestMinion := &api.Node{
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
Name: "minion-1", Name: "minion-1",
}, },

View File

@ -39,7 +39,7 @@ type Fake struct {
Ctrl api.ReplicationController Ctrl api.ReplicationController
ServiceList api.ServiceList ServiceList api.ServiceList
EndpointsList api.EndpointsList EndpointsList api.EndpointsList
MinionsList api.MinionList MinionsList api.NodeList
EventsList api.EventList EventsList api.EventList
Err error Err error
Watch watch.Interface Watch watch.Interface

View File

@ -26,19 +26,19 @@ type FakeMinions struct {
Fake *Fake Fake *Fake
} }
func (c *FakeMinions) Get(name string) (*api.Minion, error) { func (c *FakeMinions) Get(name string) (*api.Node, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "get-minion", Value: name}) c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "get-minion", Value: name})
return &api.Minion{}, nil return &api.Node{}, nil
} }
func (c *FakeMinions) List() (*api.MinionList, error) { func (c *FakeMinions) List() (*api.NodeList, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "list-minions", Value: nil}) c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "list-minions", Value: nil})
return &c.Fake.MinionsList, nil return &c.Fake.MinionsList, nil
} }
func (c *FakeMinions) Create(minion *api.Minion) (*api.Minion, error) { func (c *FakeMinions) Create(minion *api.Node) (*api.Node, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "create-minion", Value: minion}) c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "create-minion", Value: minion})
return &api.Minion{}, nil return &api.Node{}, nil
} }
func (c *FakeMinions) Delete(id string) error { func (c *FakeMinions) Delete(id string) error {

View File

@ -23,9 +23,9 @@ type MinionsInterface interface {
} }
type MinionInterface interface { type MinionInterface interface {
Get(id string) (result *api.Minion, err error) Get(id string) (result *api.Node, err error)
Create(minion *api.Minion) (*api.Minion, error) Create(minion *api.Node) (*api.Node, error)
List() (*api.MinionList, error) List() (*api.NodeList, error)
Delete(id string) error Delete(id string) error
} }
@ -40,22 +40,22 @@ func newMinions(c *Client) *minions {
} }
// Create creates a new minion. // Create creates a new minion.
func (c *minions) Create(minion *api.Minion) (*api.Minion, error) { func (c *minions) Create(minion *api.Node) (*api.Node, error) {
result := &api.Minion{} result := &api.Node{}
err := c.r.Post().Path("minions").Body(minion).Do().Into(result) err := c.r.Post().Path("minions").Body(minion).Do().Into(result)
return result, err return result, err
} }
// List lists all the minions in the cluster. // List lists all the minions in the cluster.
func (c *minions) List() (*api.MinionList, error) { func (c *minions) List() (*api.NodeList, error) {
result := &api.MinionList{} result := &api.NodeList{}
err := c.r.Get().Path("minions").Do().Into(result) err := c.r.Get().Path("minions").Do().Into(result)
return result, err return result, err
} }
// Get gets an existing minion // Get gets an existing minion
func (c *minions) Get(id string) (*api.Minion, error) { func (c *minions) Get(id string) (*api.Node, error) {
result := &api.Minion{} result := &api.Node{}
err := c.r.Get().Path("minions").Path(id).Do().Into(result) err := c.r.Get().Path("minions").Path(id).Do().Into(result)
return result, err return result, err
} }

View File

@ -73,7 +73,7 @@ func (s *MinionController) SyncStatic(period time.Duration) error {
if registered.Has(minionID) { if registered.Has(minionID) {
continue continue
} }
_, err := s.kubeClient.Minions().Create(&api.Minion{ _, err := s.kubeClient.Minions().Create(&api.Node{
ObjectMeta: api.ObjectMeta{Name: minionID}, ObjectMeta: api.ObjectMeta{Name: minionID},
Spec: api.NodeSpec{ Spec: api.NodeSpec{
Capacity: s.staticResources.Capacity, Capacity: s.staticResources.Capacity,
@ -101,7 +101,7 @@ func (s *MinionController) SyncCloud() error {
if err != nil { if err != nil {
return err return err
} }
minionMap := make(map[string]*api.Minion) minionMap := make(map[string]*api.Node)
for _, minion := range minions.Items { for _, minion := range minions.Items {
minionMap[minion.Name] = &minion minionMap[minion.Name] = &minion
} }
@ -128,8 +128,8 @@ func (s *MinionController) SyncCloud() error {
return nil return nil
} }
// cloudMinions constructs and returns api.MinionList from cloudprovider. // cloudMinions constructs and returns api.NodeList from cloudprovider.
func (s *MinionController) cloudMinions() (*api.MinionList, error) { func (s *MinionController) cloudMinions() (*api.NodeList, error) {
instances, ok := s.cloud.Instances() instances, ok := s.cloud.Instances()
if !ok { if !ok {
return nil, fmt.Errorf("cloud doesn't support instances") return nil, fmt.Errorf("cloud doesn't support instances")
@ -138,8 +138,8 @@ func (s *MinionController) cloudMinions() (*api.MinionList, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
result := &api.MinionList{ result := &api.NodeList{
Items: make([]api.Minion, len(matches)), Items: make([]api.Node, len(matches)),
} }
for i := range matches { for i := range matches {
result.Items[i].Name = matches[i] result.Items[i].Name = matches[i]

View File

@ -26,8 +26,8 @@ import (
fake_cloud "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/fake" fake_cloud "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/fake"
) )
func newMinion(name string) *api.Minion { func newMinion(name string) *api.Node {
return &api.Minion{ObjectMeta: api.ObjectMeta{Name: name}} return &api.Node{ObjectMeta: api.ObjectMeta{Name: name}}
} }
type FakeMinionHandler struct { type FakeMinionHandler struct {
@ -35,12 +35,12 @@ type FakeMinionHandler struct {
client.FakeMinions client.FakeMinions
// Input: Hooks determine if request is valid or not // Input: Hooks determine if request is valid or not
CreateHook func(*FakeMinionHandler, *api.Minion) bool CreateHook func(*FakeMinionHandler, *api.Node) bool
Existing []*api.Minion Existing []*api.Node
// Output // Output
CreatedMinions []*api.Minion CreatedMinions []*api.Node
DeletedMinions []*api.Minion DeletedMinions []*api.Node
RequestCount int RequestCount int
} }
@ -48,7 +48,7 @@ func (c *FakeMinionHandler) Minions() client.MinionInterface {
return c return c
} }
func (m *FakeMinionHandler) Create(minion *api.Minion) (*api.Minion, error) { func (m *FakeMinionHandler) Create(minion *api.Node) (*api.Node, error) {
defer func() { m.RequestCount++ }() defer func() { m.RequestCount++ }()
if m.CreateHook == nil || m.CreateHook(m, minion) { if m.CreateHook == nil || m.CreateHook(m, minion) {
m.CreatedMinions = append(m.CreatedMinions, minion) m.CreatedMinions = append(m.CreatedMinions, minion)
@ -58,9 +58,9 @@ func (m *FakeMinionHandler) Create(minion *api.Minion) (*api.Minion, error) {
} }
} }
func (m *FakeMinionHandler) List() (*api.MinionList, error) { func (m *FakeMinionHandler) List() (*api.NodeList, error) {
defer func() { m.RequestCount++ }() defer func() { m.RequestCount++ }()
minions := []api.Minion{} minions := []api.Node{}
for i := 0; i < len(m.Existing); i++ { for i := 0; i < len(m.Existing); i++ {
if !contains(m.Existing[i], m.DeletedMinions) { if !contains(m.Existing[i], m.DeletedMinions) {
minions = append(minions, *m.Existing[i]) minions = append(minions, *m.Existing[i])
@ -71,7 +71,7 @@ func (m *FakeMinionHandler) List() (*api.MinionList, error) {
minions = append(minions, *m.CreatedMinions[i]) minions = append(minions, *m.CreatedMinions[i])
} }
} }
return &api.MinionList{Items: minions}, nil return &api.NodeList{Items: minions}, nil
} }
func (m *FakeMinionHandler) Delete(id string) error { func (m *FakeMinionHandler) Delete(id string) error {
@ -82,7 +82,7 @@ func (m *FakeMinionHandler) Delete(id string) error {
func TestSyncStaticCreateMinion(t *testing.T) { func TestSyncStaticCreateMinion(t *testing.T) {
fakeMinionHandler := &FakeMinionHandler{ fakeMinionHandler := &FakeMinionHandler{
CreateHook: func(fake *FakeMinionHandler, minion *api.Minion) bool { CreateHook: func(fake *FakeMinionHandler, minion *api.Node) bool {
return true return true
}, },
} }
@ -104,7 +104,7 @@ func TestSyncStaticCreateMinion(t *testing.T) {
func TestSyncStaticCreateMinionWithError(t *testing.T) { func TestSyncStaticCreateMinionWithError(t *testing.T) {
fakeMinionHandler := &FakeMinionHandler{ fakeMinionHandler := &FakeMinionHandler{
CreateHook: func(fake *FakeMinionHandler, minion *api.Minion) bool { CreateHook: func(fake *FakeMinionHandler, minion *api.Node) bool {
if fake.RequestCount == 0 { if fake.RequestCount == 0 {
return false return false
} }
@ -129,7 +129,7 @@ func TestSyncStaticCreateMinionWithError(t *testing.T) {
func TestSyncCloudCreateMinion(t *testing.T) { func TestSyncCloudCreateMinion(t *testing.T) {
fakeMinionHandler := &FakeMinionHandler{ fakeMinionHandler := &FakeMinionHandler{
Existing: []*api.Minion{newMinion("minion0")}, Existing: []*api.Node{newMinion("minion0")},
} }
instances := []string{"minion0", "minion1"} instances := []string{"minion0", "minion1"}
fakeCloud := fake_cloud.FakeCloud{ fakeCloud := fake_cloud.FakeCloud{
@ -153,7 +153,7 @@ func TestSyncCloudCreateMinion(t *testing.T) {
func TestSyncCloudDeleteMinion(t *testing.T) { func TestSyncCloudDeleteMinion(t *testing.T) {
fakeMinionHandler := &FakeMinionHandler{ fakeMinionHandler := &FakeMinionHandler{
Existing: []*api.Minion{newMinion("minion0"), newMinion("minion1")}, Existing: []*api.Node{newMinion("minion0"), newMinion("minion1")},
} }
instances := []string{"minion0"} instances := []string{"minion0"}
fakeCloud := fake_cloud.FakeCloud{ fakeCloud := fake_cloud.FakeCloud{
@ -177,7 +177,7 @@ func TestSyncCloudDeleteMinion(t *testing.T) {
func TestSyncCloudRegexp(t *testing.T) { func TestSyncCloudRegexp(t *testing.T) {
fakeMinionHandler := &FakeMinionHandler{ fakeMinionHandler := &FakeMinionHandler{
Existing: []*api.Minion{newMinion("minion0")}, Existing: []*api.Node{newMinion("minion0")},
} }
instances := []string{"minion0", "minion1", "node0"} instances := []string{"minion0", "minion1", "node0"}
fakeCloud := fake_cloud.FakeCloud{ fakeCloud := fake_cloud.FakeCloud{
@ -199,7 +199,7 @@ func TestSyncCloudRegexp(t *testing.T) {
} }
} }
func contains(minion *api.Minion, minions []*api.Minion) bool { func contains(minion *api.Node, minions []*api.Node) bool {
for i := 0; i < len(minions); i++ { for i := 0; i < len(minions); i++ {
if minion.Name == minions[i].Name { if minion.Name == minions[i].Name {
return true return true

View File

@ -248,12 +248,12 @@ func printServiceList(list *api.ServiceList, w io.Writer) error {
return nil return nil
} }
func printMinion(minion *api.Minion, w io.Writer) error { func printMinion(minion *api.Node, w io.Writer) error {
_, err := fmt.Fprintf(w, "%s\t%s\n", minion.Name, labels.Set(minion.Labels)) _, err := fmt.Fprintf(w, "%s\t%s\n", minion.Name, labels.Set(minion.Labels))
return err return err
} }
func printMinionList(list *api.MinionList, w io.Writer) error { func printMinionList(list *api.NodeList, w io.Writer) error {
for _, minion := range list.Items { for _, minion := range list.Items {
if err := printMinion(&minion, w); err != nil { if err := printMinion(&minion, w); err != nil {
return err return err

View File

@ -296,12 +296,12 @@ func printServiceList(list *api.ServiceList, w io.Writer) error {
return nil return nil
} }
func printMinion(minion *api.Minion, w io.Writer) error { func printMinion(minion *api.Node, w io.Writer) error {
_, err := fmt.Fprintf(w, "%s\t%s\n", minion.Name, formatLabels(minion.Labels)) _, err := fmt.Fprintf(w, "%s\t%s\n", minion.Name, formatLabels(minion.Labels))
return err return err
} }
func printMinionList(list *api.MinionList, w io.Writer) error { func printMinionList(list *api.NodeList, w io.Writer) error {
for _, minion := range list.Items { for _, minion := range list.Items {
if err := printMinion(&minion, w); err != nil { if err := printMinion(&minion, w); err != nil {
return err return err

View File

@ -559,26 +559,26 @@ func makeMinionKey(minionID string) string {
return "/registry/minions/" + minionID return "/registry/minions/" + minionID
} }
func (r *Registry) ListMinions(ctx api.Context) (*api.MinionList, error) { func (r *Registry) ListMinions(ctx api.Context) (*api.NodeList, error) {
minions := &api.MinionList{} minions := &api.NodeList{}
err := r.ExtractToList("/registry/minions", minions) err := r.ExtractToList("/registry/minions", minions)
return minions, err return minions, err
} }
func (r *Registry) CreateMinion(ctx api.Context, minion *api.Minion) error { func (r *Registry) CreateMinion(ctx api.Context, minion *api.Node) error {
// TODO: Add some validations. // TODO: Add some validations.
err := r.CreateObj(makeMinionKey(minion.Name), minion, 0) err := r.CreateObj(makeMinionKey(minion.Name), minion, 0)
return etcderr.InterpretCreateError(err, "minion", minion.Name) return etcderr.InterpretCreateError(err, "minion", minion.Name)
} }
func (r *Registry) UpdateMinion(ctx api.Context, minion *api.Minion) error { func (r *Registry) UpdateMinion(ctx api.Context, minion *api.Node) error {
// TODO: Add some validations. // TODO: Add some validations.
err := r.SetObj(makeMinionKey(minion.Name), minion) err := r.SetObj(makeMinionKey(minion.Name), minion)
return etcderr.InterpretUpdateError(err, "minion", minion.Name) return etcderr.InterpretUpdateError(err, "minion", minion.Name)
} }
func (r *Registry) GetMinion(ctx api.Context, minionID string) (*api.Minion, error) { func (r *Registry) GetMinion(ctx api.Context, minionID string) (*api.Node, error) {
var minion api.Minion var minion api.Node
key := makeMinionKey(minionID) key := makeMinionKey(minionID)
err := r.ExtractObj(key, &minion, false) err := r.ExtractObj(key, &minion, false)
if err != nil { if err != nil {

View File

@ -1364,12 +1364,12 @@ func TestEtcdListMinions(t *testing.T) {
Node: &etcd.Node{ Node: &etcd.Node{
Nodes: []*etcd.Node{ Nodes: []*etcd.Node{
{ {
Value: runtime.EncodeOrDie(latest.Codec, &api.Minion{ Value: runtime.EncodeOrDie(latest.Codec, &api.Node{
ObjectMeta: api.ObjectMeta{Name: "foo"}, ObjectMeta: api.ObjectMeta{Name: "foo"},
}), }),
}, },
{ {
Value: runtime.EncodeOrDie(latest.Codec, &api.Minion{ Value: runtime.EncodeOrDie(latest.Codec, &api.Node{
ObjectMeta: api.ObjectMeta{Name: "bar"}, ObjectMeta: api.ObjectMeta{Name: "bar"},
}), }),
}, },
@ -1393,7 +1393,7 @@ func TestEtcdCreateMinion(t *testing.T) {
ctx := api.NewContext() ctx := api.NewContext()
fakeClient := tools.NewFakeEtcdClient(t) fakeClient := tools.NewFakeEtcdClient(t)
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
err := registry.CreateMinion(ctx, &api.Minion{ err := registry.CreateMinion(ctx, &api.Node{
ObjectMeta: api.ObjectMeta{Name: "foo"}, ObjectMeta: api.ObjectMeta{Name: "foo"},
}) })
if err != nil { if err != nil {
@ -1405,7 +1405,7 @@ func TestEtcdCreateMinion(t *testing.T) {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
var minion api.Minion var minion api.Node
err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &minion) err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &minion)
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
@ -1419,7 +1419,7 @@ func TestEtcdCreateMinion(t *testing.T) {
func TestEtcdGetMinion(t *testing.T) { func TestEtcdGetMinion(t *testing.T) {
ctx := api.NewContext() ctx := api.NewContext()
fakeClient := tools.NewFakeEtcdClient(t) fakeClient := tools.NewFakeEtcdClient(t)
fakeClient.Set("/registry/minions/foo", runtime.EncodeOrDie(latest.Codec, &api.Minion{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0) fakeClient.Set("/registry/minions/foo", runtime.EncodeOrDie(latest.Codec, &api.Node{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0)
registry := NewTestEtcdRegistry(fakeClient) registry := NewTestEtcdRegistry(fakeClient)
minion, err := registry.GetMinion(ctx, "foo") minion, err := registry.GetMinion(ctx, "foo")
if err != nil { if err != nil {

View File

@ -36,7 +36,7 @@ func NewHealthyRegistry(delegate Registry, client client.KubeletHealthChecker) R
} }
} }
func (r *HealthyRegistry) GetMinion(ctx api.Context, minionID string) (*api.Minion, error) { func (r *HealthyRegistry) GetMinion(ctx api.Context, minionID string) (*api.Node, error) {
minion, err := r.delegate.GetMinion(ctx, minionID) minion, err := r.delegate.GetMinion(ctx, minionID)
if minion == nil { if minion == nil {
return nil, ErrDoesNotExist return nil, ErrDoesNotExist
@ -58,16 +58,16 @@ func (r *HealthyRegistry) DeleteMinion(ctx api.Context, minionID string) error {
return r.delegate.DeleteMinion(ctx, minionID) return r.delegate.DeleteMinion(ctx, minionID)
} }
func (r *HealthyRegistry) CreateMinion(ctx api.Context, minion *api.Minion) error { func (r *HealthyRegistry) CreateMinion(ctx api.Context, minion *api.Node) error {
return r.delegate.CreateMinion(ctx, minion) return r.delegate.CreateMinion(ctx, minion)
} }
func (r *HealthyRegistry) UpdateMinion(ctx api.Context, minion *api.Minion) error { func (r *HealthyRegistry) UpdateMinion(ctx api.Context, minion *api.Node) error {
return r.delegate.UpdateMinion(ctx, minion) return r.delegate.UpdateMinion(ctx, minion)
} }
func (r *HealthyRegistry) ListMinions(ctx api.Context) (currentMinions *api.MinionList, err error) { func (r *HealthyRegistry) ListMinions(ctx api.Context) (currentMinions *api.NodeList, err error) {
result := &api.MinionList{} result := &api.NodeList{}
list, err := r.delegate.ListMinions(ctx) list, err := r.delegate.ListMinions(ctx)
if err != nil { if err != nil {
return result, err return result, err

View File

@ -45,7 +45,7 @@ func TestBasicDelegation(t *testing.T) {
if !reflect.DeepEqual(list, &mockMinionRegistry.Minions) { if !reflect.DeepEqual(list, &mockMinionRegistry.Minions) {
t.Errorf("Expected %v, Got %v", mockMinionRegistry.Minions, list) t.Errorf("Expected %v, Got %v", mockMinionRegistry.Minions, list)
} }
err = healthy.CreateMinion(ctx, &api.Minion{ err = healthy.CreateMinion(ctx, &api.Node{
ObjectMeta: api.ObjectMeta{Name: "foo"}, ObjectMeta: api.ObjectMeta{Name: "foo"},
}) })
if err != nil { if err != nil {

View File

@ -20,9 +20,9 @@ import "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
// MinionRegistry is an interface for things that know how to store minions. // MinionRegistry is an interface for things that know how to store minions.
type Registry interface { type Registry interface {
ListMinions(ctx api.Context) (*api.MinionList, error) ListMinions(ctx api.Context) (*api.NodeList, error)
CreateMinion(ctx api.Context, minion *api.Minion) error CreateMinion(ctx api.Context, minion *api.Node) error
UpdateMinion(ctx api.Context, minion *api.Minion) error UpdateMinion(ctx api.Context, minion *api.Node) error
GetMinion(ctx api.Context, minionID string) (*api.Minion, error) GetMinion(ctx api.Context, minionID string) (*api.Node, error)
DeleteMinion(ctx api.Context, minionID string) error DeleteMinion(ctx api.Context, minionID string) error
} }

View File

@ -47,7 +47,7 @@ var ErrDoesNotExist = errors.New("The requested resource does not exist.")
var ErrNotHealty = errors.New("The requested minion is not healthy.") var ErrNotHealty = errors.New("The requested minion is not healthy.")
func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan apiserver.RESTResult, error) { func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan apiserver.RESTResult, error) {
minion, ok := obj.(*api.Minion) minion, ok := obj.(*api.Node)
if !ok { if !ok {
return nil, fmt.Errorf("not a minion: %#v", obj) return nil, fmt.Errorf("not a minion: %#v", obj)
} }
@ -93,11 +93,11 @@ func (rs *REST) List(ctx api.Context, label, field labels.Selector) (runtime.Obj
} }
func (rs *REST) New() runtime.Object { func (rs *REST) New() runtime.Object {
return &api.Minion{} return &api.Node{}
} }
func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan apiserver.RESTResult, error) { func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan apiserver.RESTResult, error) {
minion, ok := obj.(*api.Minion) minion, ok := obj.(*api.Node)
if !ok { if !ok {
return nil, fmt.Errorf("not a minion: %#v", obj) return nil, fmt.Errorf("not a minion: %#v", obj)
} }
@ -121,8 +121,8 @@ func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan apiserver.RE
}), nil }), nil
} }
func (rs *REST) toApiMinion(name string) *api.Minion { func (rs *REST) toApiMinion(name string) *api.Node {
return &api.Minion{ObjectMeta: api.ObjectMeta{Name: name}} return &api.Node{ObjectMeta: api.ObjectMeta{Name: name}}
} }
// ResourceLocation returns a URL to which one can send traffic for the specified minion. // ResourceLocation returns a URL to which one can send traffic for the specified minion.

View File

@ -28,28 +28,28 @@ import (
func TestMinionREST(t *testing.T) { func TestMinionREST(t *testing.T) {
ms := NewREST(registrytest.NewMinionRegistry([]string{"foo", "bar"}, api.NodeResources{})) ms := NewREST(registrytest.NewMinionRegistry([]string{"foo", "bar"}, api.NodeResources{}))
ctx := api.NewContext() ctx := api.NewContext()
if obj, err := ms.Get(ctx, "foo"); err != nil || obj.(*api.Minion).Name != "foo" { if obj, err := ms.Get(ctx, "foo"); err != nil || obj.(*api.Node).Name != "foo" {
t.Errorf("missing expected object") t.Errorf("missing expected object")
} }
if obj, err := ms.Get(ctx, "bar"); err != nil || obj.(*api.Minion).Name != "bar" { if obj, err := ms.Get(ctx, "bar"); err != nil || obj.(*api.Node).Name != "bar" {
t.Errorf("missing expected object") t.Errorf("missing expected object")
} }
if _, err := ms.Get(ctx, "baz"); err != ErrDoesNotExist { if _, err := ms.Get(ctx, "baz"); err != ErrDoesNotExist {
t.Errorf("has unexpected object") t.Errorf("has unexpected object")
} }
c, err := ms.Create(ctx, &api.Minion{ObjectMeta: api.ObjectMeta{Name: "baz"}}) c, err := ms.Create(ctx, &api.Node{ObjectMeta: api.ObjectMeta{Name: "baz"}})
if err != nil { if err != nil {
t.Errorf("insert failed") t.Errorf("insert failed")
} }
obj := <-c obj := <-c
if !api.HasObjectMetaSystemFieldValues(&obj.Object.(*api.Minion).ObjectMeta) { if !api.HasObjectMetaSystemFieldValues(&obj.Object.(*api.Node).ObjectMeta) {
t.Errorf("storage did not populate object meta field values") t.Errorf("storage did not populate object meta field values")
} }
if m, ok := obj.Object.(*api.Minion); !ok || m.Name != "baz" { if m, ok := obj.Object.(*api.Node); !ok || m.Name != "baz" {
t.Errorf("insert return value was weird: %#v", obj) t.Errorf("insert return value was weird: %#v", obj)
} }
if obj, err := ms.Get(ctx, "baz"); err != nil || obj.(*api.Minion).Name != "baz" { if obj, err := ms.Get(ctx, "baz"); err != nil || obj.(*api.Node).Name != "baz" {
t.Errorf("insert didn't actually insert") t.Errorf("insert didn't actually insert")
} }
@ -74,14 +74,14 @@ func TestMinionREST(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("got error calling List") t.Errorf("got error calling List")
} }
expect := []api.Minion{ expect := []api.Node{
{ {
ObjectMeta: api.ObjectMeta{Name: "foo"}, ObjectMeta: api.ObjectMeta{Name: "foo"},
}, { }, {
ObjectMeta: api.ObjectMeta{Name: "baz"}, ObjectMeta: api.ObjectMeta{Name: "baz"},
}, },
} }
nodeList := list.(*api.MinionList) nodeList := list.(*api.NodeList)
if len(expect) != len(nodeList.Items) || !contains(nodeList, "foo") || !contains(nodeList, "baz") { if len(expect) != len(nodeList.Items) || !contains(nodeList, "foo") || !contains(nodeList, "baz") {
t.Errorf("Unexpected list value: %#v", list) t.Errorf("Unexpected list value: %#v", list)
} }
@ -97,12 +97,12 @@ func TestMinionStorageWithHealthCheck(t *testing.T) {
ms := NewREST(&minionHealthRegistry) ms := NewREST(&minionHealthRegistry)
ctx := api.NewContext() ctx := api.NewContext()
c, err := ms.Create(ctx, &api.Minion{ObjectMeta: api.ObjectMeta{Name: "m1"}}) c, err := ms.Create(ctx, &api.Node{ObjectMeta: api.ObjectMeta{Name: "m1"}})
if err != nil { if err != nil {
t.Errorf("insert failed") t.Errorf("insert failed")
} }
result := <-c result := <-c
if m, ok := result.Object.(*api.Minion); !ok || m.Name != "m1" { if m, ok := result.Object.(*api.Node); !ok || m.Name != "m1" {
t.Errorf("insert return value was weird: %#v", result) t.Errorf("insert return value was weird: %#v", result)
} }
if _, err := ms.Get(ctx, "m1"); err == nil { if _, err := ms.Get(ctx, "m1"); err == nil {
@ -110,7 +110,7 @@ func TestMinionStorageWithHealthCheck(t *testing.T) {
} }
} }
func contains(nodes *api.MinionList, nodeID string) bool { func contains(nodes *api.NodeList, nodeID string) bool {
for _, node := range nodes.Items { for _, node := range nodes.Items {
if node.Name == nodeID { if node.Name == nodeID {
return true return true
@ -126,7 +126,7 @@ func TestMinionStorageInvalidUpdate(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("Unexpected error: %v", err) t.Errorf("Unexpected error: %v", err)
} }
minion, ok := obj.(*api.Minion) minion, ok := obj.(*api.Node)
if !ok { if !ok {
t.Fatalf("Object is not a minion: %#v", obj) t.Fatalf("Object is not a minion: %#v", obj)
} }
@ -143,7 +143,7 @@ func TestMinionStorageValidUpdate(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("Unexpected error: %v", err) t.Errorf("Unexpected error: %v", err)
} }
minion, ok := obj.(*api.Minion) minion, ok := obj.(*api.Node)
if !ok { if !ok {
t.Fatalf("Object is not a minion: %#v", obj) t.Fatalf("Object is not a minion: %#v", obj)
} }
@ -161,7 +161,7 @@ func TestMinionStorageValidatesCreate(t *testing.T) {
ctx := api.NewContext() ctx := api.NewContext()
validSelector := map[string]string{"a": "b"} validSelector := map[string]string{"a": "b"}
invalidSelector := map[string]string{"NoUppercaseOrSpecialCharsLike=Equals": "b"} invalidSelector := map[string]string{"NoUppercaseOrSpecialCharsLike=Equals": "b"}
failureCases := map[string]api.Minion{ failureCases := map[string]api.Node{
"zero-length Name": { "zero-length Name": {
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
Name: "", Name: "",

View File

@ -370,8 +370,8 @@ func TestGetPodCloud(t *testing.T) {
func TestMakePodStatus(t *testing.T) { func TestMakePodStatus(t *testing.T) {
fakeClient := client.Fake{ fakeClient := client.Fake{
MinionsList: api.MinionList{ MinionsList: api.NodeList{
Items: []api.Minion{ Items: []api.Node{
{ {
ObjectMeta: api.ObjectMeta{Name: "machine"}, ObjectMeta: api.ObjectMeta{Name: "machine"},
}, },

View File

@ -25,13 +25,13 @@ import (
type MinionRegistry struct { type MinionRegistry struct {
Err error Err error
Minion string Minion string
Minions api.MinionList Minions api.NodeList
sync.Mutex sync.Mutex
} }
func MakeMinionList(minions []string, nodeResources api.NodeResources) *api.MinionList { func MakeMinionList(minions []string, nodeResources api.NodeResources) *api.NodeList {
list := api.MinionList{ list := api.NodeList{
Items: make([]api.Minion, len(minions)), Items: make([]api.Node, len(minions)),
} }
for i := range minions { for i := range minions {
list.Items[i].Name = minions[i] list.Items[i].Name = minions[i]
@ -46,13 +46,13 @@ func NewMinionRegistry(minions []string, nodeResources api.NodeResources) *Minio
} }
} }
func (r *MinionRegistry) ListMinions(ctx api.Context) (*api.MinionList, error) { func (r *MinionRegistry) ListMinions(ctx api.Context) (*api.NodeList, error) {
r.Lock() r.Lock()
defer r.Unlock() defer r.Unlock()
return &r.Minions, r.Err return &r.Minions, r.Err
} }
func (r *MinionRegistry) CreateMinion(ctx api.Context, minion *api.Minion) error { func (r *MinionRegistry) CreateMinion(ctx api.Context, minion *api.Node) error {
r.Lock() r.Lock()
defer r.Unlock() defer r.Unlock()
r.Minion = minion.Name r.Minion = minion.Name
@ -60,7 +60,7 @@ func (r *MinionRegistry) CreateMinion(ctx api.Context, minion *api.Minion) error
return r.Err return r.Err
} }
func (r *MinionRegistry) UpdateMinion(ctx api.Context, minion *api.Minion) error { func (r *MinionRegistry) UpdateMinion(ctx api.Context, minion *api.Node) error {
r.Lock() r.Lock()
defer r.Unlock() defer r.Unlock()
for i, node := range r.Minions.Items { for i, node := range r.Minions.Items {
@ -72,7 +72,7 @@ func (r *MinionRegistry) UpdateMinion(ctx api.Context, minion *api.Minion) error
return r.Err return r.Err
} }
func (r *MinionRegistry) GetMinion(ctx api.Context, minionID string) (*api.Minion, error) { func (r *MinionRegistry) GetMinion(ctx api.Context, minionID string) (*api.Node, error) {
r.Lock() r.Lock()
defer r.Unlock() defer r.Unlock()
for _, node := range r.Minions.Items { for _, node := range r.Minions.Items {
@ -86,10 +86,10 @@ func (r *MinionRegistry) GetMinion(ctx api.Context, minionID string) (*api.Minio
func (r *MinionRegistry) DeleteMinion(ctx api.Context, minionID string) error { func (r *MinionRegistry) DeleteMinion(ctx api.Context, minionID string) error {
r.Lock() r.Lock()
defer r.Unlock() defer r.Unlock()
var newList []api.Minion var newList []api.Node
for _, node := range r.Minions.Items { for _, node := range r.Minions.Items {
if node.Name != minionID { if node.Name != minionID {
newList = append(newList, api.Minion{ObjectMeta: api.ObjectMeta{Name: node.Name}}) newList = append(newList, api.Node{ObjectMeta: api.ObjectMeta{Name: node.Name}})
} }
} }
r.Minions.Items = newList r.Minions.Items = newList

View File

@ -154,7 +154,7 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan apiserver.RE
}), nil }), nil
} }
func hostsFromMinionList(list *api.MinionList) []string { func hostsFromMinionList(list *api.NodeList) []string {
result := make([]string, len(list.Items)) result := make([]string, len(list.Items))
for ix := range list.Items { for ix := range list.Items {
result[ix] = list.Items[ix].Name result[ix] = list.Items[ix].Name

View File

@ -76,18 +76,18 @@ func (g *genericScheduler) selectHost(priorityList HostPriorityList) (string, er
// Filters the minions to find the ones that fit based on the given predicate functions // Filters the minions to find the ones that fit based on the given predicate functions
// Each minion is passed through the predicate functions to determine if it is a fit // Each minion is passed through the predicate functions to determine if it is a fit
func findNodesThatFit(pod api.Pod, podLister PodLister, predicates []FitPredicate, nodes api.MinionList) (api.MinionList, error) { func findNodesThatFit(pod api.Pod, podLister PodLister, predicates []FitPredicate, nodes api.NodeList) (api.NodeList, error) {
filtered := []api.Minion{} filtered := []api.Node{}
machineToPods, err := MapPodsToMachines(podLister) machineToPods, err := MapPodsToMachines(podLister)
if err != nil { if err != nil {
return api.MinionList{}, err return api.NodeList{}, err
} }
for _, node := range nodes.Items { for _, node := range nodes.Items {
fits := true fits := true
for _, predicate := range predicates { for _, predicate := range predicates {
fit, err := predicate(pod, machineToPods[node.Name], node.Name) fit, err := predicate(pod, machineToPods[node.Name], node.Name)
if err != nil { if err != nil {
return api.MinionList{}, err return api.NodeList{}, err
} }
if !fit { if !fit {
fits = false fits = false
@ -98,7 +98,7 @@ func findNodesThatFit(pod api.Pod, podLister PodLister, predicates []FitPredicat
filtered = append(filtered, node) filtered = append(filtered, node)
} }
} }
return api.MinionList{Items: filtered}, nil return api.NodeList{Items: filtered}, nil
} }
// Prioritizes the minions by running the individual priority functions sequentially. // Prioritizes the minions by running the individual priority functions sequentially.

View File

@ -83,9 +83,9 @@ func reverseNumericPriority(pod api.Pod, podLister PodLister, minionLister Minio
return reverseResult, nil return reverseResult, nil
} }
func makeMinionList(nodeNames []string) api.MinionList { func makeMinionList(nodeNames []string) api.NodeList {
result := api.MinionList{ result := api.NodeList{
Items: make([]api.Minion, len(nodeNames)), Items: make([]api.Node, len(nodeNames)),
} }
for ix := range nodeNames { for ix := range nodeNames {
result.Items[ix].Name = nodeNames[ix] result.Items[ix].Name = nodeNames[ix]

View File

@ -23,15 +23,15 @@ import (
// MinionLister interface represents anything that can list minions for a scheduler. // MinionLister interface represents anything that can list minions for a scheduler.
type MinionLister interface { type MinionLister interface {
List() (list api.MinionList, err error) List() (list api.NodeList, err error)
} }
// FakeMinionLister implements MinionLister on a []string for test purposes. // FakeMinionLister implements MinionLister on a []string for test purposes.
type FakeMinionLister api.MinionList type FakeMinionLister api.NodeList
// List returns minions as a []string. // List returns minions as a []string.
func (f FakeMinionLister) List() (api.MinionList, error) { func (f FakeMinionLister) List() (api.NodeList, error) {
return api.MinionList(f), nil return api.NodeList(f), nil
} }
// PodLister interface represents anything that can list pods for a scheduler. // PodLister interface represents anything that can list pods for a scheduler.

View File

@ -27,14 +27,14 @@ import (
) )
type NodeInfo interface { type NodeInfo interface {
GetNodeInfo(nodeID string) (*api.Minion, error) GetNodeInfo(nodeID string) (*api.Node, error)
} }
type StaticNodeInfo struct { type StaticNodeInfo struct {
*api.MinionList *api.NodeList
} }
func (nodes StaticNodeInfo) GetNodeInfo(nodeID string) (*api.Minion, error) { func (nodes StaticNodeInfo) GetNodeInfo(nodeID string) (*api.Node, error) {
for ix := range nodes.Items { for ix := range nodes.Items {
if nodes.Items[ix].Name == nodeID { if nodes.Items[ix].Name == nodeID {
return &nodes.Items[ix], nil return &nodes.Items[ix], nil
@ -47,7 +47,7 @@ type ClientNodeInfo struct {
*client.Client *client.Client
} }
func (nodes ClientNodeInfo) GetNodeInfo(nodeID string) (*api.Minion, error) { func (nodes ClientNodeInfo) GetNodeInfo(nodeID string) (*api.Node, error) {
return nodes.Minions().Get(nodeID) return nodes.Minions().Get(nodeID)
} }

View File

@ -25,10 +25,10 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/util"
) )
type FakeNodeInfo api.Minion type FakeNodeInfo api.Node
func (n FakeNodeInfo) GetNodeInfo(nodeName string) (*api.Minion, error) { func (n FakeNodeInfo) GetNodeInfo(nodeName string) (*api.Node, error) {
node := api.Minion(n) node := api.Node(n)
return &node, nil return &node, nil
} }
@ -111,7 +111,7 @@ func TestPodFitsResources(t *testing.T) {
}, },
} }
for _, test := range tests { for _, test := range tests {
node := api.Minion{Spec: api.NodeSpec{Capacity: makeResources(10, 20).Capacity}} node := api.Node{Spec: api.NodeSpec{Capacity: makeResources(10, 20).Capacity}}
fit := ResourceFit{FakeNodeInfo(node)} fit := ResourceFit{FakeNodeInfo(node)}
fits, err := fit.PodFitsResources(test.pod, test.existingPods, "machine") fits, err := fit.PodFitsResources(test.pod, test.existingPods, "machine")
@ -335,7 +335,7 @@ func TestPodFitsSelector(t *testing.T) {
}, },
} }
for _, test := range tests { for _, test := range tests {
node := api.Minion{ObjectMeta: api.ObjectMeta{Labels: test.labels}} node := api.Node{ObjectMeta: api.ObjectMeta{Labels: test.labels}}
fit := NodeSelector{FakeNodeInfo(node)} fit := NodeSelector{FakeNodeInfo(node)}
fits, err := fit.PodSelectorMatches(test.pod, []api.Pod{}, "machine") fits, err := fit.PodSelectorMatches(test.pod, []api.Pod{}, "machine")

View File

@ -37,7 +37,7 @@ func calculateScore(requested, capacity int, node string) int {
// Calculate the occupancy on a node. 'node' has information about the resources on the node. // Calculate the occupancy on a node. 'node' has information about the resources on the node.
// 'pods' is a list of pods currently scheduled on the node. // 'pods' is a list of pods currently scheduled on the node.
func calculateOccupancy(pod api.Pod, node api.Minion, pods []api.Pod) HostPriority { func calculateOccupancy(pod api.Pod, node api.Node, pods []api.Pod) HostPriority {
totalCPU := 0 totalCPU := 0
totalMemory := 0 totalMemory := 0
for _, existingPod := range pods { for _, existingPod := range pods {

View File

@ -25,8 +25,8 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/util"
) )
func makeMinion(node string, cpu, memory int) api.Minion { func makeMinion(node string, cpu, memory int) api.Node {
return api.Minion{ return api.Node{
ObjectMeta: api.ObjectMeta{Name: node}, ObjectMeta: api.ObjectMeta{Name: node},
Spec: api.NodeSpec{ Spec: api.NodeSpec{
Capacity: api.ResourceList{ Capacity: api.ResourceList{
@ -70,7 +70,7 @@ func TestLeastRequested(t *testing.T) {
tests := []struct { tests := []struct {
pod api.Pod pod api.Pod
pods []api.Pod pods []api.Pod
nodes []api.Minion nodes []api.Node
expectedList HostPriorityList expectedList HostPriorityList
test string test string
}{ }{
@ -87,7 +87,7 @@ func TestLeastRequested(t *testing.T) {
Minion2 Score: (10 + 10) / 2 = 10 Minion2 Score: (10 + 10) / 2 = 10
*/ */
pod: api.Pod{Spec: noResources}, pod: api.Pod{Spec: noResources},
nodes: []api.Minion{makeMinion("machine1", 4000, 10000), makeMinion("machine2", 4000, 10000)}, nodes: []api.Node{makeMinion("machine1", 4000, 10000), makeMinion("machine2", 4000, 10000)},
expectedList: []HostPriority{{"machine1", 10}, {"machine2", 10}}, expectedList: []HostPriority{{"machine1", 10}, {"machine2", 10}},
test: "nothing scheduled, nothing requested", test: "nothing scheduled, nothing requested",
}, },
@ -104,7 +104,7 @@ func TestLeastRequested(t *testing.T) {
Minion2 Score: (5 + 5) / 2 = 5 Minion2 Score: (5 + 5) / 2 = 5
*/ */
pod: api.Pod{Spec: cpuAndMemory}, pod: api.Pod{Spec: cpuAndMemory},
nodes: []api.Minion{makeMinion("machine1", 4000, 10000), makeMinion("machine2", 6000, 10000)}, nodes: []api.Node{makeMinion("machine1", 4000, 10000), makeMinion("machine2", 6000, 10000)},
expectedList: []HostPriority{{"machine1", 3}, {"machine2", 5}}, expectedList: []HostPriority{{"machine1", 3}, {"machine2", 5}},
test: "nothing scheduled, resources requested, differently sized machines", test: "nothing scheduled, resources requested, differently sized machines",
}, },
@ -121,7 +121,7 @@ func TestLeastRequested(t *testing.T) {
Minion2 Score: (10 + 10) / 2 = 10 Minion2 Score: (10 + 10) / 2 = 10
*/ */
pod: api.Pod{Spec: noResources}, pod: api.Pod{Spec: noResources},
nodes: []api.Minion{makeMinion("machine1", 4000, 10000), makeMinion("machine2", 4000, 10000)}, nodes: []api.Node{makeMinion("machine1", 4000, 10000), makeMinion("machine2", 4000, 10000)},
expectedList: []HostPriority{{"machine1", 10}, {"machine2", 10}}, expectedList: []HostPriority{{"machine1", 10}, {"machine2", 10}},
test: "no resources requested, pods scheduled", test: "no resources requested, pods scheduled",
pods: []api.Pod{ pods: []api.Pod{
@ -144,7 +144,7 @@ func TestLeastRequested(t *testing.T) {
Minion2 Score: (4 + 7.5) / 2 = 5 Minion2 Score: (4 + 7.5) / 2 = 5
*/ */
pod: api.Pod{Spec: noResources}, pod: api.Pod{Spec: noResources},
nodes: []api.Minion{makeMinion("machine1", 10000, 20000), makeMinion("machine2", 10000, 20000)}, nodes: []api.Node{makeMinion("machine1", 10000, 20000), makeMinion("machine2", 10000, 20000)},
expectedList: []HostPriority{{"machine1", 7}, {"machine2", 5}}, expectedList: []HostPriority{{"machine1", 7}, {"machine2", 5}},
test: "no resources requested, pods scheduled with resources", test: "no resources requested, pods scheduled with resources",
pods: []api.Pod{ pods: []api.Pod{
@ -167,7 +167,7 @@ func TestLeastRequested(t *testing.T) {
Minion2 Score: (4 + 5) / 2 = 4 Minion2 Score: (4 + 5) / 2 = 4
*/ */
pod: api.Pod{Spec: cpuAndMemory}, pod: api.Pod{Spec: cpuAndMemory},
nodes: []api.Minion{makeMinion("machine1", 10000, 20000), makeMinion("machine2", 10000, 20000)}, nodes: []api.Node{makeMinion("machine1", 10000, 20000), makeMinion("machine2", 10000, 20000)},
expectedList: []HostPriority{{"machine1", 5}, {"machine2", 4}}, expectedList: []HostPriority{{"machine1", 5}, {"machine2", 4}},
test: "resources requested, pods scheduled with resources", test: "resources requested, pods scheduled with resources",
pods: []api.Pod{ pods: []api.Pod{
@ -188,7 +188,7 @@ func TestLeastRequested(t *testing.T) {
Minion2 Score: (4 + 8) / 2 = 6 Minion2 Score: (4 + 8) / 2 = 6
*/ */
pod: api.Pod{Spec: cpuAndMemory}, pod: api.Pod{Spec: cpuAndMemory},
nodes: []api.Minion{makeMinion("machine1", 10000, 20000), makeMinion("machine2", 10000, 50000)}, nodes: []api.Node{makeMinion("machine1", 10000, 20000), makeMinion("machine2", 10000, 50000)},
expectedList: []HostPriority{{"machine1", 5}, {"machine2", 6}}, expectedList: []HostPriority{{"machine1", 5}, {"machine2", 6}},
test: "resources requested, pods scheduled with resources, differently sized machines", test: "resources requested, pods scheduled with resources, differently sized machines",
pods: []api.Pod{ pods: []api.Pod{
@ -209,7 +209,7 @@ func TestLeastRequested(t *testing.T) {
Minion2 Score: (0 + 5) / 2 = 2 Minion2 Score: (0 + 5) / 2 = 2
*/ */
pod: api.Pod{Spec: cpuOnly}, pod: api.Pod{Spec: cpuOnly},
nodes: []api.Minion{makeMinion("machine1", 4000, 10000), makeMinion("machine2", 4000, 10000)}, nodes: []api.Node{makeMinion("machine1", 4000, 10000), makeMinion("machine2", 4000, 10000)},
expectedList: []HostPriority{{"machine1", 5}, {"machine2", 2}}, expectedList: []HostPriority{{"machine1", 5}, {"machine2", 2}},
test: "requested resources exceed minion capacity", test: "requested resources exceed minion capacity",
pods: []api.Pod{ pods: []api.Pod{
@ -219,7 +219,7 @@ func TestLeastRequested(t *testing.T) {
}, },
{ {
pod: api.Pod{Spec: noResources}, pod: api.Pod{Spec: noResources},
nodes: []api.Minion{makeMinion("machine1", 0, 0), makeMinion("machine2", 0, 0)}, nodes: []api.Node{makeMinion("machine1", 0, 0), makeMinion("machine2", 0, 0)},
expectedList: []HostPriority{{"machine1", 0}, {"machine2", 0}}, expectedList: []HostPriority{{"machine1", 0}, {"machine2", 0}},
test: "zero minion resources, pods scheduled with resources", test: "zero minion resources, pods scheduled with resources",
pods: []api.Pod{ pods: []api.Pod{
@ -230,7 +230,7 @@ func TestLeastRequested(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
list, err := LeastRequestedPriority(test.pod, FakePodLister(test.pods), FakeMinionLister(api.MinionList{Items: test.nodes})) list, err := LeastRequestedPriority(test.pod, FakePodLister(test.pods), FakeMinionLister(api.NodeList{Items: test.nodes}))
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }

View File

@ -45,7 +45,7 @@ type ConfigFactory struct {
// a means to list all scheduled pods // a means to list all scheduled pods
PodLister *storeToPodLister PodLister *storeToPodLister
// a means to list all minions // a means to list all minions
MinionLister *storeToMinionLister MinionLister *storeToNodeLister
// map of strings to predicate functions to be used // map of strings to predicate functions to be used
// to filter the minions for scheduling pods // to filter the minions for scheduling pods
PredicateMap map[string]algorithm.FitPredicate PredicateMap map[string]algorithm.FitPredicate
@ -61,7 +61,7 @@ func NewConfigFactory(client *client.Client) *ConfigFactory {
Client: client, Client: client,
PodQueue: cache.NewFIFO(), PodQueue: cache.NewFIFO(),
PodLister: &storeToPodLister{cache.NewStore()}, PodLister: &storeToPodLister{cache.NewStore()},
MinionLister: &storeToMinionLister{cache.NewStore()}, MinionLister: &storeToNodeLister{cache.NewStore()},
PredicateMap: make(map[string]algorithm.FitPredicate), PredicateMap: make(map[string]algorithm.FitPredicate),
PriorityMap: make(map[string]algorithm.PriorityConfig), PriorityMap: make(map[string]algorithm.PriorityConfig),
} }
@ -103,7 +103,7 @@ func (factory *ConfigFactory) Create(predicateKeys, priorityKeys []string) (*sch
// Minions may be listed frequently, so provide a local up-to-date cache. // Minions may be listed frequently, so provide a local up-to-date cache.
if false { if false {
// Disable this code until minions support watches. // Disable this code until minions support watches.
cache.NewReflector(factory.createMinionLW(), &api.Minion{}, factory.MinionLister.Store).Run() cache.NewReflector(factory.createMinionLW(), &api.Node{}, factory.MinionLister.Store).Run()
} else { } else {
cache.NewPoller(factory.pollMinions, 10*time.Second, factory.MinionLister.Store).Run() cache.NewPoller(factory.pollMinions, 10*time.Second, factory.MinionLister.Store).Run()
} }
@ -255,12 +255,12 @@ func (factory *ConfigFactory) createMinionLW() *listWatch {
// pollMinions lists all minions and returns an enumerator for cache.Poller. // pollMinions lists all minions and returns an enumerator for cache.Poller.
func (factory *ConfigFactory) pollMinions() (cache.Enumerator, error) { func (factory *ConfigFactory) pollMinions() (cache.Enumerator, error) {
list := &api.MinionList{} list := &api.NodeList{}
err := factory.Client.Get().Path("minions").Do().Into(list) err := factory.Client.Get().Path("minions").Do().Into(list)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &minionEnumerator{list}, nil return &nodeEnumerator{list}, nil
} }
func (factory *ConfigFactory) makeDefaultErrorFunc(backoff *podBackoff, podQueue *cache.FIFO) func(pod *api.Pod, err error) { func (factory *ConfigFactory) makeDefaultErrorFunc(backoff *podBackoff, podQueue *cache.FIFO) func(pod *api.Pod, err error) {
@ -288,22 +288,22 @@ func (factory *ConfigFactory) makeDefaultErrorFunc(backoff *podBackoff, podQueue
} }
} }
// storeToMinionLister turns a store into a minion lister. The store must contain (only) minions. // storeToNodeLister turns a store into a minion lister. The store must contain (only) minions.
type storeToMinionLister struct { type storeToNodeLister struct {
cache.Store cache.Store
} }
func (s *storeToMinionLister) List() (machines api.MinionList, err error) { func (s *storeToNodeLister) List() (machines api.NodeList, err error) {
for _, m := range s.Store.List() { for _, m := range s.Store.List() {
machines.Items = append(machines.Items, *(m.(*api.Minion))) machines.Items = append(machines.Items, *(m.(*api.Node)))
} }
return machines, nil return machines, nil
} }
// GetNodeInfo returns cached data for the minion 'id'. // GetNodeInfo returns cached data for the minion 'id'.
func (s *storeToMinionLister) GetNodeInfo(id string) (*api.Minion, error) { func (s *storeToNodeLister) GetNodeInfo(id string) (*api.Node, error) {
if minion, ok := s.Get(id); ok { if minion, ok := s.Get(id); ok {
return minion.(*api.Minion), nil return minion.(*api.Node), nil
} }
return nil, fmt.Errorf("minion '%v' is not in cache", id) return nil, fmt.Errorf("minion '%v' is not in cache", id)
} }
@ -323,22 +323,22 @@ func (s *storeToPodLister) ListPods(selector labels.Selector) (pods []api.Pod, e
return pods, nil return pods, nil
} }
// minionEnumerator allows a cache.Poller to enumerate items in an api.PodList // nodeEnumerator allows a cache.Poller to enumerate items in an api.NodeList
type minionEnumerator struct { type nodeEnumerator struct {
*api.MinionList *api.NodeList
} }
// Len returns the number of items in the pod list. // Len returns the number of items in the node list.
func (me *minionEnumerator) Len() int { func (ne *nodeEnumerator) Len() int {
if me.MinionList == nil { if ne.NodeList == nil {
return 0 return 0
} }
return len(me.Items) return len(ne.Items)
} }
// Get returns the item (and ID) with the particular index. // Get returns the item (and ID) with the particular index.
func (me *minionEnumerator) Get(index int) (string, interface{}) { func (ne *nodeEnumerator) Get(index int) (string, interface{}) {
return me.Items[index].Name, &me.Items[index] return ne.Items[index].Name, &ne.Items[index]
} }
type binder struct { type binder struct {

View File

@ -145,10 +145,10 @@ func TestCreateWatches(t *testing.T) {
func TestPollMinions(t *testing.T) { func TestPollMinions(t *testing.T) {
table := []struct { table := []struct {
minions []api.Minion minions []api.Node
}{ }{
{ {
minions: []api.Minion{ minions: []api.Node{
{ObjectMeta: api.ObjectMeta{Name: "foo"}}, {ObjectMeta: api.ObjectMeta{Name: "foo"}},
{ObjectMeta: api.ObjectMeta{Name: "bar"}}, {ObjectMeta: api.ObjectMeta{Name: "bar"}},
}, },
@ -156,7 +156,7 @@ func TestPollMinions(t *testing.T) {
} }
for _, item := range table { for _, item := range table {
ml := &api.MinionList{Items: item.minions} ml := &api.NodeList{Items: item.minions}
handler := util.FakeHandler{ handler := util.FakeHandler{
StatusCode: 200, StatusCode: 200,
ResponseBody: runtime.EncodeOrDie(latest.Codec, ml), ResponseBody: runtime.EncodeOrDie(latest.Codec, ml),
@ -225,9 +225,9 @@ func TestStoreToMinionLister(t *testing.T) {
store := cache.NewStore() store := cache.NewStore()
ids := util.NewStringSet("foo", "bar", "baz") ids := util.NewStringSet("foo", "bar", "baz")
for id := range ids { for id := range ids {
store.Add(id, &api.Minion{ObjectMeta: api.ObjectMeta{Name: id}}) store.Add(id, &api.Node{ObjectMeta: api.ObjectMeta{Name: id}})
} }
sml := storeToMinionLister{store} sml := storeToNodeLister{store}
gotNodes, err := sml.List() gotNodes, err := sml.List()
if err != nil { if err != nil {
@ -273,14 +273,14 @@ func TestStoreToPodLister(t *testing.T) {
} }
func TestMinionEnumerator(t *testing.T) { func TestMinionEnumerator(t *testing.T) {
testList := &api.MinionList{ testList := &api.NodeList{
Items: []api.Minion{ Items: []api.Node{
{ObjectMeta: api.ObjectMeta{Name: "foo"}}, {ObjectMeta: api.ObjectMeta{Name: "foo"}},
{ObjectMeta: api.ObjectMeta{Name: "bar"}}, {ObjectMeta: api.ObjectMeta{Name: "bar"}},
{ObjectMeta: api.ObjectMeta{Name: "baz"}}, {ObjectMeta: api.ObjectMeta{Name: "baz"}},
}, },
} }
me := minionEnumerator{testList} me := nodeEnumerator{testList}
if e, a := 3, me.Len(); e != a { if e, a := 3, me.Len(); e != a {
t.Fatalf("expected %v, got %v", e, a) t.Fatalf("expected %v, got %v", e, a)

View File

@ -88,7 +88,7 @@ func TestScheduler(t *testing.T) {
var gotBinding *api.Binding var gotBinding *api.Binding
c := &Config{ c := &Config{
MinionLister: scheduler.FakeMinionLister( MinionLister: scheduler.FakeMinionLister(
api.MinionList{Items: []api.Minion{{ObjectMeta: api.ObjectMeta{Name: "machine1"}}}}, api.NodeList{Items: []api.Node{{ObjectMeta: api.ObjectMeta{Name: "machine1"}}}},
), ),
Algorithm: item.algo, Algorithm: item.algo,
Binder: fakeBinder{func(b *api.Binding) error { Binder: fakeBinder{func(b *api.Binding) error {