mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-16 06:32:32 +00:00
Internal rename api.Minion -> api.Node
This commit is contained in:
@@ -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: "",
|
||||
|
Reference in New Issue
Block a user