mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #2910 from smarterclayton/small_v1beta3_refactors
Fix internal -> v1beta3 round trip issues
This commit is contained in:
commit
9b40c52c24
@ -35,8 +35,8 @@ func init() {
|
|||||||
&NodeList{},
|
&NodeList{},
|
||||||
&Node{},
|
&Node{},
|
||||||
&Status{},
|
&Status{},
|
||||||
&ServerOpList{},
|
&OperationList{},
|
||||||
&ServerOp{},
|
&Operation{},
|
||||||
&Endpoints{},
|
&Endpoints{},
|
||||||
&EndpointsList{},
|
&EndpointsList{},
|
||||||
&Binding{},
|
&Binding{},
|
||||||
@ -51,6 +51,8 @@ func init() {
|
|||||||
// Legacy names are supported
|
// Legacy names are supported
|
||||||
Scheme.AddKnownTypeWithName("", "Minion", &Node{})
|
Scheme.AddKnownTypeWithName("", "Minion", &Node{})
|
||||||
Scheme.AddKnownTypeWithName("", "MinionList", &NodeList{})
|
Scheme.AddKnownTypeWithName("", "MinionList", &NodeList{})
|
||||||
|
Scheme.AddKnownTypeWithName("", "ServerOp", &Operation{})
|
||||||
|
Scheme.AddKnownTypeWithName("", "ServerOpList", &OperationList{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*PodContainerInfo) IsAnAPIObject() {}
|
func (*PodContainerInfo) IsAnAPIObject() {}
|
||||||
@ -66,8 +68,8 @@ func (*Node) IsAnAPIObject() {}
|
|||||||
func (*NodeList) IsAnAPIObject() {}
|
func (*NodeList) IsAnAPIObject() {}
|
||||||
func (*Binding) IsAnAPIObject() {}
|
func (*Binding) IsAnAPIObject() {}
|
||||||
func (*Status) IsAnAPIObject() {}
|
func (*Status) IsAnAPIObject() {}
|
||||||
func (*ServerOp) IsAnAPIObject() {}
|
func (*Operation) IsAnAPIObject() {}
|
||||||
func (*ServerOpList) IsAnAPIObject() {}
|
func (*OperationList) IsAnAPIObject() {}
|
||||||
func (*Event) IsAnAPIObject() {}
|
func (*Event) IsAnAPIObject() {}
|
||||||
func (*EventList) IsAnAPIObject() {}
|
func (*EventList) IsAnAPIObject() {}
|
||||||
func (*ContainerManifest) IsAnAPIObject() {}
|
func (*ContainerManifest) IsAnAPIObject() {}
|
||||||
|
@ -476,6 +476,9 @@ type PodSpec struct {
|
|||||||
type PodStatus struct {
|
type PodStatus struct {
|
||||||
Phase PodPhase `json:"phase,omitempty"`
|
Phase PodPhase `json:"phase,omitempty"`
|
||||||
|
|
||||||
|
// A human readable message indicating details about why the pod is in this state.
|
||||||
|
Message string `json:"message,omitempty"`
|
||||||
|
|
||||||
// Host is the name of the node that this Pod is currently bound to, or empty if no
|
// Host is the name of the node that this Pod is currently bound to, or empty if no
|
||||||
// assignment has been done.
|
// assignment has been done.
|
||||||
Host string `json:"host,omitempty"`
|
Host string `json:"host,omitempty"`
|
||||||
@ -761,8 +764,8 @@ type Binding struct {
|
|||||||
// TODO: this could go in apiserver, but I'm including it here so clients needn't
|
// TODO: this could go in apiserver, but I'm including it here so clients needn't
|
||||||
// import both.
|
// import both.
|
||||||
type Status struct {
|
type Status struct {
|
||||||
TypeMeta `json:",inline"`
|
TypeMeta `json:",inline"`
|
||||||
ObjectMeta `json:"metadata,omitempty"`
|
ListMeta `json:"metadata,omitempty"`
|
||||||
|
|
||||||
// One of: "Success", "Failure", "Working" (for operations not yet completed)
|
// One of: "Success", "Failure", "Working" (for operations not yet completed)
|
||||||
Status string `json:"status,omitempty"`
|
Status string `json:"status,omitempty"`
|
||||||
@ -927,18 +930,18 @@ const (
|
|||||||
CauseTypeFieldValueNotSupported CauseType = "FieldValueNotSupported"
|
CauseTypeFieldValueNotSupported CauseType = "FieldValueNotSupported"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ServerOp is an operation delivered to API clients.
|
// Operation is an operation delivered to API clients.
|
||||||
type ServerOp struct {
|
type Operation struct {
|
||||||
TypeMeta `json:",inline"`
|
TypeMeta `json:",inline"`
|
||||||
ObjectMeta `json:"metadata,omitempty"`
|
ObjectMeta `json:"metadata,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServerOpList is a list of operations, as delivered to API clients.
|
// OperationList is a list of operations, as delivered to API clients.
|
||||||
type ServerOpList struct {
|
type OperationList struct {
|
||||||
TypeMeta `json:",inline"`
|
TypeMeta `json:",inline"`
|
||||||
ListMeta `json:"metadata,omitempty"`
|
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.
|
// ObjectReference contains enough information to let you inspect or modify the referred object.
|
||||||
|
@ -176,6 +176,7 @@ func init() {
|
|||||||
if err := s.Convert(&in.Info, &out.Info, 0); err != nil {
|
if err := s.Convert(&in.Info, &out.Info, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
out.Message = in.Message
|
||||||
out.Host = in.Host
|
out.Host = in.Host
|
||||||
out.HostIP = in.HostIP
|
out.HostIP = in.HostIP
|
||||||
out.PodIP = in.PodIP
|
out.PodIP = in.PodIP
|
||||||
@ -189,6 +190,7 @@ func init() {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out.Message = in.Message
|
||||||
out.Host = in.Host
|
out.Host = in.Host
|
||||||
out.HostIP = in.HostIP
|
out.HostIP = in.HostIP
|
||||||
out.PodIP = in.PodIP
|
out.PodIP = in.PodIP
|
||||||
|
@ -28,6 +28,8 @@ func init() {
|
|||||||
// Future names are supported, and declared first so they take precedence
|
// Future names are supported, and declared first so they take precedence
|
||||||
api.Scheme.AddKnownTypeWithName("v1beta1", "Node", &Minion{})
|
api.Scheme.AddKnownTypeWithName("v1beta1", "Node", &Minion{})
|
||||||
api.Scheme.AddKnownTypeWithName("v1beta1", "NodeList", &MinionList{})
|
api.Scheme.AddKnownTypeWithName("v1beta1", "NodeList", &MinionList{})
|
||||||
|
api.Scheme.AddKnownTypeWithName("v1beta1", "Operation", &ServerOp{})
|
||||||
|
api.Scheme.AddKnownTypeWithName("v1beta1", "OperationList", &ServerOpList{})
|
||||||
|
|
||||||
api.Scheme.AddKnownTypes("v1beta1",
|
api.Scheme.AddKnownTypes("v1beta1",
|
||||||
&Pod{},
|
&Pod{},
|
||||||
|
@ -295,6 +295,7 @@ func init() {
|
|||||||
if err := s.Convert(&in.Info, &out.Info, 0); err != nil {
|
if err := s.Convert(&in.Info, &out.Info, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
out.Message = in.Message
|
||||||
out.Host = in.Host
|
out.Host = in.Host
|
||||||
out.HostIP = in.HostIP
|
out.HostIP = in.HostIP
|
||||||
out.PodIP = in.PodIP
|
out.PodIP = in.PodIP
|
||||||
@ -307,6 +308,7 @@ func init() {
|
|||||||
if err := s.Convert(&in.Info, &out.Info, 0); err != nil {
|
if err := s.Convert(&in.Info, &out.Info, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
out.Message = in.Message
|
||||||
out.Host = in.Host
|
out.Host = in.Host
|
||||||
out.HostIP = in.HostIP
|
out.HostIP = in.HostIP
|
||||||
out.PodIP = in.PodIP
|
out.PodIP = in.PodIP
|
||||||
|
@ -28,6 +28,8 @@ func init() {
|
|||||||
// Future names are supported, and declared first so they take precedence
|
// Future names are supported, and declared first so they take precedence
|
||||||
api.Scheme.AddKnownTypeWithName("v1beta2", "Node", &Minion{})
|
api.Scheme.AddKnownTypeWithName("v1beta2", "Node", &Minion{})
|
||||||
api.Scheme.AddKnownTypeWithName("v1beta2", "NodeList", &MinionList{})
|
api.Scheme.AddKnownTypeWithName("v1beta2", "NodeList", &MinionList{})
|
||||||
|
api.Scheme.AddKnownTypeWithName("v1beta2", "Operation", &ServerOp{})
|
||||||
|
api.Scheme.AddKnownTypeWithName("v1beta2", "OperationList", &ServerOpList{})
|
||||||
|
|
||||||
api.Scheme.AddKnownTypes("v1beta2",
|
api.Scheme.AddKnownTypes("v1beta2",
|
||||||
&Pod{},
|
&Pod{},
|
||||||
|
@ -52,6 +52,8 @@ func init() {
|
|||||||
// Legacy names are supported
|
// Legacy names are supported
|
||||||
api.Scheme.AddKnownTypeWithName("v1beta3", "Minion", &Node{})
|
api.Scheme.AddKnownTypeWithName("v1beta3", "Minion", &Node{})
|
||||||
api.Scheme.AddKnownTypeWithName("v1beta3", "MinionList", &NodeList{})
|
api.Scheme.AddKnownTypeWithName("v1beta3", "MinionList", &NodeList{})
|
||||||
|
api.Scheme.AddKnownTypeWithName("v1beta3", "ServerOp", &Operation{})
|
||||||
|
api.Scheme.AddKnownTypeWithName("v1beta3", "ServerOpList", &OperationList{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*PodContainerInfo) IsAnAPIObject() {}
|
func (*PodContainerInfo) IsAnAPIObject() {}
|
||||||
|
@ -70,15 +70,15 @@ func interfacesFor(version string) (*meta.VersionInterfaces, error) {
|
|||||||
func init() {
|
func init() {
|
||||||
// Certain API objects are returned regardless of the contents of storage:
|
// Certain API objects are returned regardless of the contents of storage:
|
||||||
// api.Status is returned in errors
|
// api.Status is returned in errors
|
||||||
// api.ServerOp/api.ServerOpList are returned by /operations
|
// api.Operation/api.OperationList are returned by /operations
|
||||||
|
|
||||||
// "internal" version
|
// "internal" version
|
||||||
api.Scheme.AddKnownTypes("", &Simple{}, &SimpleList{},
|
api.Scheme.AddKnownTypes("", &Simple{}, &SimpleList{},
|
||||||
&api.Status{}, &api.ServerOp{}, &api.ServerOpList{})
|
&api.Status{}, &api.Operation{}, &api.OperationList{})
|
||||||
// "version" version
|
// "version" version
|
||||||
// TODO: Use versioned api objects?
|
// TODO: Use versioned api objects?
|
||||||
api.Scheme.AddKnownTypes(testVersion, &Simple{}, &SimpleList{},
|
api.Scheme.AddKnownTypes(testVersion, &Simple{}, &SimpleList{},
|
||||||
&api.Status{}, &api.ServerOp{}, &api.ServerOpList{})
|
&api.Status{}, &api.Operation{}, &api.OperationList{})
|
||||||
|
|
||||||
defMapper := meta.NewDefaultRESTMapper(
|
defMapper := meta.NewDefaultRESTMapper(
|
||||||
versions,
|
versions,
|
||||||
|
@ -115,7 +115,7 @@ func (ops *Operations) insert(op *Operation) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List lists operations for an API client.
|
// List lists operations for an API client.
|
||||||
func (ops *Operations) List() *api.ServerOpList {
|
func (ops *Operations) List() *api.OperationList {
|
||||||
ops.lock.Lock()
|
ops.lock.Lock()
|
||||||
defer ops.lock.Unlock()
|
defer ops.lock.Unlock()
|
||||||
|
|
||||||
@ -124,9 +124,9 @@ func (ops *Operations) List() *api.ServerOpList {
|
|||||||
ids = append(ids, id)
|
ids = append(ids, id)
|
||||||
}
|
}
|
||||||
sort.StringSlice(ids).Sort()
|
sort.StringSlice(ids).Sort()
|
||||||
ol := &api.ServerOpList{}
|
ol := &api.OperationList{}
|
||||||
for _, id := range ids {
|
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
|
return ol
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ func TestOperationsList(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
oplist, ok := obj.(*api.ServerOpList)
|
oplist, ok := obj.(*api.OperationList)
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("expected ServerOpList, got %#v", obj)
|
t.Fatalf("expected ServerOpList, got %#v", obj)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user