Rename client Minions->Nodes, select the correct path for v1beta3

Replaces the client public interface but leaves old references to "minions"
for a later refactor.  Selects the path "nodes" for v1beta3 and "minions"
for older versions.
This commit is contained in:
Clayton Coleman
2014-12-08 00:56:43 -05:00
parent d0087dfe62
commit d1d7505272
15 changed files with 103 additions and 62 deletions

View File

@@ -73,7 +73,7 @@ func (s *MinionController) SyncStatic(period time.Duration) error {
if registered.Has(minionID) {
continue
}
_, err := s.kubeClient.Minions().Create(&api.Node{
_, err := s.kubeClient.Nodes().Create(&api.Node{
ObjectMeta: api.ObjectMeta{Name: minionID},
Spec: api.NodeSpec{
Capacity: s.staticResources.Capacity,
@@ -97,7 +97,7 @@ func (s *MinionController) SyncCloud() error {
if err != nil {
return err
}
minions, err := s.kubeClient.Minions().List()
minions, err := s.kubeClient.Nodes().List()
if err != nil {
return err
}
@@ -110,7 +110,7 @@ func (s *MinionController) SyncCloud() error {
for _, minion := range matches.Items {
if _, ok := minionMap[minion.Name]; !ok {
glog.Infof("Create minion in registry: %s", minion.Name)
_, err = s.kubeClient.Minions().Create(&minion)
_, err = s.kubeClient.Nodes().Create(&minion)
if err != nil {
glog.Errorf("Create minion error: %s", minion.Name)
}
@@ -120,7 +120,7 @@ func (s *MinionController) SyncCloud() error {
for minionID := range minionMap {
glog.Infof("Delete minion from registry: %s", minionID)
err = s.kubeClient.Minions().Delete(minionID)
err = s.kubeClient.Nodes().Delete(minionID)
if err != nil {
glog.Errorf("Delete minion error: %s", minionID)
}

View File

@@ -26,13 +26,13 @@ import (
fake_cloud "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/fake"
)
func newMinion(name string) *api.Node {
func newNode(name string) *api.Node {
return &api.Node{ObjectMeta: api.ObjectMeta{Name: name}}
}
type FakeMinionHandler struct {
client.Fake
client.FakeMinions
client.FakeNodes
// Input: Hooks determine if request is valid or not
CreateHook func(*FakeMinionHandler, *api.Node) bool
@@ -44,7 +44,7 @@ type FakeMinionHandler struct {
RequestCount int
}
func (c *FakeMinionHandler) Minions() client.MinionInterface {
func (c *FakeMinionHandler) Nodes() client.NodeInterface {
return c
}
@@ -75,7 +75,7 @@ func (m *FakeMinionHandler) List() (*api.NodeList, error) {
}
func (m *FakeMinionHandler) Delete(id string) error {
m.DeletedMinions = append(m.DeletedMinions, newMinion(id))
m.DeletedMinions = append(m.DeletedMinions, newNode(id))
m.RequestCount++
return nil
}
@@ -129,7 +129,7 @@ func TestSyncStaticCreateMinionWithError(t *testing.T) {
func TestSyncCloudCreateMinion(t *testing.T) {
fakeMinionHandler := &FakeMinionHandler{
Existing: []*api.Node{newMinion("minion0")},
Existing: []*api.Node{newNode("minion0")},
}
instances := []string{"minion0", "minion1"}
fakeCloud := fake_cloud.FakeCloud{
@@ -153,7 +153,7 @@ func TestSyncCloudCreateMinion(t *testing.T) {
func TestSyncCloudDeleteMinion(t *testing.T) {
fakeMinionHandler := &FakeMinionHandler{
Existing: []*api.Node{newMinion("minion0"), newMinion("minion1")},
Existing: []*api.Node{newNode("minion0"), newNode("minion1")},
}
instances := []string{"minion0"}
fakeCloud := fake_cloud.FakeCloud{
@@ -177,7 +177,7 @@ func TestSyncCloudDeleteMinion(t *testing.T) {
func TestSyncCloudRegexp(t *testing.T) {
fakeMinionHandler := &FakeMinionHandler{
Existing: []*api.Node{newMinion("minion0")},
Existing: []*api.Node{newNode("minion0")},
}
instances := []string{"minion0", "minion1", "node0"}
fakeCloud := fake_cloud.FakeCloud{