Rename ServerOp to Operation in v1beta3 and internal

Add the appropriate rename logic internally.
This commit is contained in:
Clayton Coleman 2014-12-12 16:22:32 -05:00
parent 771c538932
commit 904d0d46c3
8 changed files with 24 additions and 16 deletions

View File

@ -34,8 +34,8 @@ func init() {
&NodeList{},
&Node{},
&Status{},
&ServerOpList{},
&ServerOp{},
&OperationList{},
&Operation{},
&Endpoints{},
&EndpointsList{},
&Binding{},
@ -50,6 +50,8 @@ func init() {
// Legacy names are supported
Scheme.AddKnownTypeWithName("", "Minion", &Node{})
Scheme.AddKnownTypeWithName("", "MinionList", &NodeList{})
Scheme.AddKnownTypeWithName("", "ServerOp", &Operation{})
Scheme.AddKnownTypeWithName("", "ServerOpList", &OperationList{})
}
func (*Pod) IsAnAPIObject() {}
@ -64,8 +66,8 @@ func (*Node) IsAnAPIObject() {}
func (*NodeList) IsAnAPIObject() {}
func (*Binding) IsAnAPIObject() {}
func (*Status) IsAnAPIObject() {}
func (*ServerOp) IsAnAPIObject() {}
func (*ServerOpList) IsAnAPIObject() {}
func (*Operation) IsAnAPIObject() {}
func (*OperationList) IsAnAPIObject() {}
func (*Event) IsAnAPIObject() {}
func (*EventList) IsAnAPIObject() {}
func (*ContainerManifest) IsAnAPIObject() {}

View File

@ -920,18 +920,18 @@ const (
CauseTypeFieldValueNotSupported CauseType = "FieldValueNotSupported"
)
// ServerOp is an operation delivered to API clients.
type ServerOp struct {
// Operation is an operation delivered to API clients.
type Operation struct {
TypeMeta `json:",inline"`
ObjectMeta `json:"metadata,omitempty"`
}
// ServerOpList is a list of operations, as delivered to API clients.
type ServerOpList struct {
// OperationList is a list of operations, as delivered to API clients.
type OperationList struct {
TypeMeta `json:",inline"`
ListMeta `json:"metadata,omitempty"`
Items []ServerOp `json:"items"`
Items []Operation `json:"items"`
}
// ObjectReference contains enough information to let you inspect or modify the referred object.

View File

@ -28,6 +28,8 @@ func init() {
// Future names are supported, and declared first so they take precedence
api.Scheme.AddKnownTypeWithName("v1beta1", "Node", &Minion{})
api.Scheme.AddKnownTypeWithName("v1beta1", "NodeList", &MinionList{})
api.Scheme.AddKnownTypeWithName("v1beta1", "Operation", &ServerOp{})
api.Scheme.AddKnownTypeWithName("v1beta1", "OperationList", &ServerOpList{})
api.Scheme.AddKnownTypes("v1beta1",
&Pod{},

View File

@ -28,6 +28,8 @@ func init() {
// Future names are supported, and declared first so they take precedence
api.Scheme.AddKnownTypeWithName("v1beta2", "Node", &Minion{})
api.Scheme.AddKnownTypeWithName("v1beta2", "NodeList", &MinionList{})
api.Scheme.AddKnownTypeWithName("v1beta2", "Operation", &ServerOp{})
api.Scheme.AddKnownTypeWithName("v1beta2", "OperationList", &ServerOpList{})
api.Scheme.AddKnownTypes("v1beta2",
&Pod{},

View File

@ -51,6 +51,8 @@ func init() {
// Legacy names are supported
api.Scheme.AddKnownTypeWithName("v1beta3", "Minion", &Node{})
api.Scheme.AddKnownTypeWithName("v1beta3", "MinionList", &NodeList{})
api.Scheme.AddKnownTypeWithName("v1beta3", "ServerOp", &Operation{})
api.Scheme.AddKnownTypeWithName("v1beta3", "ServerOpList", &OperationList{})
}
func (*Pod) IsAnAPIObject() {}

View File

@ -70,15 +70,15 @@ func interfacesFor(version string) (*meta.VersionInterfaces, error) {
func init() {
// Certain API objects are returned regardless of the contents of storage:
// api.Status is returned in errors
// api.ServerOp/api.ServerOpList are returned by /operations
// api.Operation/api.OperationList are returned by /operations
// "internal" version
api.Scheme.AddKnownTypes("", &Simple{}, &SimpleList{},
&api.Status{}, &api.ServerOp{}, &api.ServerOpList{})
&api.Status{}, &api.Operation{}, &api.OperationList{})
// "version" version
// TODO: Use versioned api objects?
api.Scheme.AddKnownTypes(testVersion, &Simple{}, &SimpleList{},
&api.Status{}, &api.ServerOp{}, &api.ServerOpList{})
&api.Status{}, &api.Operation{}, &api.OperationList{})
defMapper := meta.NewDefaultRESTMapper(
versions,

View File

@ -115,7 +115,7 @@ func (ops *Operations) insert(op *Operation) {
}
// List lists operations for an API client.
func (ops *Operations) List() *api.ServerOpList {
func (ops *Operations) List() *api.OperationList {
ops.lock.Lock()
defer ops.lock.Unlock()
@ -124,9 +124,9 @@ func (ops *Operations) List() *api.ServerOpList {
ids = append(ids, id)
}
sort.StringSlice(ids).Sort()
ol := &api.ServerOpList{}
ol := &api.OperationList{}
for _, id := range ids {
ol.Items = append(ol.Items, api.ServerOp{ObjectMeta: api.ObjectMeta{Name: id}})
ol.Items = append(ol.Items, api.Operation{ObjectMeta: api.ObjectMeta{Name: id}})
}
return ol
}

View File

@ -149,7 +149,7 @@ func TestOperationsList(t *testing.T) {
if err != nil {
t.Errorf("unexpected error: %v", err)
}
oplist, ok := obj.(*api.ServerOpList)
oplist, ok := obj.(*api.OperationList)
if !ok {
t.Fatalf("expected ServerOpList, got %#v", obj)
}