mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-17 15:13:08 +00:00
Internal rename api.Minion -> api.Node
This commit is contained in:
@@ -559,26 +559,26 @@ func makeMinionKey(minionID string) string {
|
||||
return "/registry/minions/" + minionID
|
||||
}
|
||||
|
||||
func (r *Registry) ListMinions(ctx api.Context) (*api.MinionList, error) {
|
||||
minions := &api.MinionList{}
|
||||
func (r *Registry) ListMinions(ctx api.Context) (*api.NodeList, error) {
|
||||
minions := &api.NodeList{}
|
||||
err := r.ExtractToList("/registry/minions", minions)
|
||||
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.
|
||||
err := r.CreateObj(makeMinionKey(minion.Name), minion, 0)
|
||||
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.
|
||||
err := r.SetObj(makeMinionKey(minion.Name), minion)
|
||||
return etcderr.InterpretUpdateError(err, "minion", minion.Name)
|
||||
}
|
||||
|
||||
func (r *Registry) GetMinion(ctx api.Context, minionID string) (*api.Minion, error) {
|
||||
var minion api.Minion
|
||||
func (r *Registry) GetMinion(ctx api.Context, minionID string) (*api.Node, error) {
|
||||
var minion api.Node
|
||||
key := makeMinionKey(minionID)
|
||||
err := r.ExtractObj(key, &minion, false)
|
||||
if err != nil {
|
||||
|
@@ -1364,12 +1364,12 @@ func TestEtcdListMinions(t *testing.T) {
|
||||
Node: &etcd.Node{
|
||||
Nodes: []*etcd.Node{
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Minion{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Node{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}),
|
||||
},
|
||||
{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Minion{
|
||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Node{
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
}),
|
||||
},
|
||||
@@ -1393,7 +1393,7 @@ func TestEtcdCreateMinion(t *testing.T) {
|
||||
ctx := api.NewContext()
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreateMinion(ctx, &api.Minion{
|
||||
err := registry.CreateMinion(ctx, &api.Node{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
})
|
||||
if err != nil {
|
||||
@@ -1405,7 +1405,7 @@ func TestEtcdCreateMinion(t *testing.T) {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
var minion api.Minion
|
||||
var minion api.Node
|
||||
err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &minion)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
@@ -1419,7 +1419,7 @@ func TestEtcdCreateMinion(t *testing.T) {
|
||||
func TestEtcdGetMinion(t *testing.T) {
|
||||
ctx := api.NewContext()
|
||||
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)
|
||||
minion, err := registry.GetMinion(ctx, "foo")
|
||||
if err != nil {
|
||||
|
@@ -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)
|
||||
if minion == nil {
|
||||
return nil, ErrDoesNotExist
|
||||
@@ -58,16 +58,16 @@ func (r *HealthyRegistry) DeleteMinion(ctx api.Context, minionID string) error {
|
||||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
func (r *HealthyRegistry) ListMinions(ctx api.Context) (currentMinions *api.MinionList, err error) {
|
||||
result := &api.MinionList{}
|
||||
func (r *HealthyRegistry) ListMinions(ctx api.Context) (currentMinions *api.NodeList, err error) {
|
||||
result := &api.NodeList{}
|
||||
list, err := r.delegate.ListMinions(ctx)
|
||||
if err != nil {
|
||||
return result, err
|
||||
|
@@ -45,7 +45,7 @@ func TestBasicDelegation(t *testing.T) {
|
||||
if !reflect.DeepEqual(list, &mockMinionRegistry.Minions) {
|
||||
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"},
|
||||
})
|
||||
if err != nil {
|
||||
|
@@ -20,9 +20,9 @@ import "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
|
||||
// MinionRegistry is an interface for things that know how to store minions.
|
||||
type Registry interface {
|
||||
ListMinions(ctx api.Context) (*api.MinionList, error)
|
||||
CreateMinion(ctx api.Context, minion *api.Minion) error
|
||||
UpdateMinion(ctx api.Context, minion *api.Minion) error
|
||||
GetMinion(ctx api.Context, minionID string) (*api.Minion, error)
|
||||
ListMinions(ctx api.Context) (*api.NodeList, error)
|
||||
CreateMinion(ctx api.Context, minion *api.Node) error
|
||||
UpdateMinion(ctx api.Context, minion *api.Node) error
|
||||
GetMinion(ctx api.Context, minionID string) (*api.Node, error)
|
||||
DeleteMinion(ctx api.Context, minionID string) error
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ var ErrDoesNotExist = errors.New("The requested resource does not exist.")
|
||||
var ErrNotHealty = errors.New("The requested minion is not healthy.")
|
||||
|
||||
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 {
|
||||
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 {
|
||||
return &api.Minion{}
|
||||
return &api.Node{}
|
||||
}
|
||||
|
||||
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 {
|
||||
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
|
||||
}
|
||||
|
||||
func (rs *REST) toApiMinion(name string) *api.Minion {
|
||||
return &api.Minion{ObjectMeta: api.ObjectMeta{Name: name}}
|
||||
func (rs *REST) toApiMinion(name string) *api.Node {
|
||||
return &api.Node{ObjectMeta: api.ObjectMeta{Name: name}}
|
||||
}
|
||||
|
||||
// ResourceLocation returns a URL to which one can send traffic for the specified minion.
|
||||
|
@@ -28,28 +28,28 @@ import (
|
||||
func TestMinionREST(t *testing.T) {
|
||||
ms := NewREST(registrytest.NewMinionRegistry([]string{"foo", "bar"}, api.NodeResources{}))
|
||||
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")
|
||||
}
|
||||
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")
|
||||
}
|
||||
if _, err := ms.Get(ctx, "baz"); err != ErrDoesNotExist {
|
||||
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 {
|
||||
t.Errorf("insert failed")
|
||||
}
|
||||
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")
|
||||
}
|
||||
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)
|
||||
}
|
||||
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")
|
||||
}
|
||||
|
||||
@@ -74,14 +74,14 @@ func TestMinionREST(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("got error calling List")
|
||||
}
|
||||
expect := []api.Minion{
|
||||
expect := []api.Node{
|
||||
{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
}, {
|
||||
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") {
|
||||
t.Errorf("Unexpected list value: %#v", list)
|
||||
}
|
||||
@@ -97,12 +97,12 @@ func TestMinionStorageWithHealthCheck(t *testing.T) {
|
||||
ms := NewREST(&minionHealthRegistry)
|
||||
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 {
|
||||
t.Errorf("insert failed")
|
||||
}
|
||||
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)
|
||||
}
|
||||
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 {
|
||||
if node.Name == nodeID {
|
||||
return true
|
||||
@@ -126,7 +126,7 @@ func TestMinionStorageInvalidUpdate(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
minion, ok := obj.(*api.Minion)
|
||||
minion, ok := obj.(*api.Node)
|
||||
if !ok {
|
||||
t.Fatalf("Object is not a minion: %#v", obj)
|
||||
}
|
||||
@@ -143,7 +143,7 @@ func TestMinionStorageValidUpdate(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
minion, ok := obj.(*api.Minion)
|
||||
minion, ok := obj.(*api.Node)
|
||||
if !ok {
|
||||
t.Fatalf("Object is not a minion: %#v", obj)
|
||||
}
|
||||
@@ -161,7 +161,7 @@ func TestMinionStorageValidatesCreate(t *testing.T) {
|
||||
ctx := api.NewContext()
|
||||
validSelector := map[string]string{"a": "b"}
|
||||
invalidSelector := map[string]string{"NoUppercaseOrSpecialCharsLike=Equals": "b"}
|
||||
failureCases := map[string]api.Minion{
|
||||
failureCases := map[string]api.Node{
|
||||
"zero-length Name": {
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "",
|
||||
|
@@ -370,8 +370,8 @@ func TestGetPodCloud(t *testing.T) {
|
||||
|
||||
func TestMakePodStatus(t *testing.T) {
|
||||
fakeClient := client.Fake{
|
||||
MinionsList: api.MinionList{
|
||||
Items: []api.Minion{
|
||||
MinionsList: api.NodeList{
|
||||
Items: []api.Node{
|
||||
{
|
||||
ObjectMeta: api.ObjectMeta{Name: "machine"},
|
||||
},
|
||||
|
@@ -25,13 +25,13 @@ import (
|
||||
type MinionRegistry struct {
|
||||
Err error
|
||||
Minion string
|
||||
Minions api.MinionList
|
||||
Minions api.NodeList
|
||||
sync.Mutex
|
||||
}
|
||||
|
||||
func MakeMinionList(minions []string, nodeResources api.NodeResources) *api.MinionList {
|
||||
list := api.MinionList{
|
||||
Items: make([]api.Minion, len(minions)),
|
||||
func MakeMinionList(minions []string, nodeResources api.NodeResources) *api.NodeList {
|
||||
list := api.NodeList{
|
||||
Items: make([]api.Node, len(minions)),
|
||||
}
|
||||
for i := range minions {
|
||||
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()
|
||||
defer r.Unlock()
|
||||
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()
|
||||
defer r.Unlock()
|
||||
r.Minion = minion.Name
|
||||
@@ -60,7 +60,7 @@ func (r *MinionRegistry) CreateMinion(ctx api.Context, minion *api.Minion) error
|
||||
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()
|
||||
defer r.Unlock()
|
||||
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
|
||||
}
|
||||
|
||||
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()
|
||||
defer r.Unlock()
|
||||
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 {
|
||||
r.Lock()
|
||||
defer r.Unlock()
|
||||
var newList []api.Minion
|
||||
var newList []api.Node
|
||||
for _, node := range r.Minions.Items {
|
||||
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
|
||||
|
@@ -154,7 +154,7 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan apiserver.RE
|
||||
}), nil
|
||||
}
|
||||
|
||||
func hostsFromMinionList(list *api.MinionList) []string {
|
||||
func hostsFromMinionList(list *api.NodeList) []string {
|
||||
result := make([]string, len(list.Items))
|
||||
for ix := range list.Items {
|
||||
result[ix] = list.Items[ix].Name
|
||||
|
Reference in New Issue
Block a user