mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 13:45:06 +00:00
Split RESTStorage into separate interfaces
Omit unimplemented interfaces from Swagger
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
|
||||
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
@@ -94,7 +95,7 @@ func (m *Master) createMasterServiceIfNeeded(serviceName string, port int) error
|
||||
}
|
||||
// Kids, don't do this at home: this is a hack. There's no good way to call the business
|
||||
// logic which lives in the REST object from here.
|
||||
c, err := m.storage["services"].Create(ctx, svc)
|
||||
c, err := m.storage["services"].(apiserver.RESTCreater).Create(ctx, svc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -33,6 +33,9 @@ import (
|
||||
// TODO: considering that the only difference between the various client types
|
||||
// and RESTStorage type is the type of the arguments, maybe use "go generate" to
|
||||
// write a specialized adaptor for every client type?
|
||||
//
|
||||
// TODO: this also means that pod and node API endpoints have to be colocated in the same
|
||||
// process
|
||||
func RESTStorageToNodes(storage apiserver.RESTStorage) client.NodesInterface {
|
||||
return &nodeAdaptor{storage}
|
||||
}
|
||||
@@ -61,7 +64,7 @@ func (n *nodeAdaptor) Create(minion *api.Node) (*api.Node, error) {
|
||||
// List lists all the nodes in the cluster.
|
||||
func (n *nodeAdaptor) List() (*api.NodeList, error) {
|
||||
ctx := api.NewContext()
|
||||
obj, err := n.storage.List(ctx, labels.Everything(), labels.Everything())
|
||||
obj, err := n.storage.(apiserver.RESTLister).List(ctx, labels.Everything(), labels.Everything())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -71,7 +74,7 @@ func (n *nodeAdaptor) List() (*api.NodeList, error) {
|
||||
// Get gets an existing minion
|
||||
func (n *nodeAdaptor) Get(name string) (*api.Node, error) {
|
||||
ctx := api.NewContext()
|
||||
obj, err := n.storage.Get(ctx, name)
|
||||
obj, err := n.storage.(apiserver.RESTGetter).Get(ctx, name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user