mirror of https://github.com/k3s-io/k3s
Merge pull request #17 from brendandburns/ux
Populate 'Kind' fields for all JSON requests. This will facilitate better client side UX.pull/6/head
commit
0a6a9e4011
|
@ -130,6 +130,7 @@ type TaskTemplate struct {
|
|||
|
||||
// ServiceList holds a list of services
|
||||
type ServiceList struct {
|
||||
JSONBase
|
||||
Items []Service `json:"items" yaml:"items"`
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Package apiserver is ...
|
||||
// Package apiserver contains the code that provides a RESTful api service
|
||||
package apiserver
|
||||
|
||||
import (
|
||||
|
|
|
@ -35,18 +35,21 @@ func MakeControllerRegistryStorage(registry ControllerRegistry) apiserver.RESTSt
|
|||
}
|
||||
|
||||
func (storage *ControllerRegistryStorage) List(*url.URL) (interface{}, error) {
|
||||
var result ReplicationControllerList
|
||||
result := ReplicationControllerList{JSONBase: JSONBase{Kind: "cluster#replicationControllerList"}}
|
||||
controllers, err := storage.registry.ListControllers()
|
||||
if err == nil {
|
||||
result = ReplicationControllerList{
|
||||
Items: controllers,
|
||||
JSONBase: JSONBase{Kind: "cluster#replicationControllerList"},
|
||||
Items: controllers,
|
||||
}
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (storage *ControllerRegistryStorage) Get(id string) (interface{}, error) {
|
||||
return storage.registry.GetController(id)
|
||||
controller, err := storage.registry.GetController(id)
|
||||
controller.Kind = "cluster#replicationController"
|
||||
return controller, err
|
||||
}
|
||||
|
||||
func (storage *ControllerRegistryStorage) Delete(id string) error {
|
||||
|
|
|
@ -60,11 +60,15 @@ func GetServiceEnvironmentVariables(registry ServiceRegistry, machine string) ([
|
|||
}
|
||||
|
||||
func (sr *ServiceRegistryStorage) List(*url.URL) (interface{}, error) {
|
||||
return sr.registry.ListServices()
|
||||
list, err := sr.registry.ListServices()
|
||||
list.Kind = "cluster#serviceList"
|
||||
return list, err
|
||||
}
|
||||
|
||||
func (sr *ServiceRegistryStorage) Get(id string) (interface{}, error) {
|
||||
return sr.registry.GetService(id)
|
||||
service, err := sr.registry.GetService(id)
|
||||
service.Kind = "cluster#service"
|
||||
return service, err
|
||||
}
|
||||
|
||||
func (sr *ServiceRegistryStorage) Delete(id string) error {
|
||||
|
|
|
@ -76,6 +76,7 @@ func (storage *TaskRegistryStorage) List(url *url.URL) (interface{}, error) {
|
|||
Items: tasks,
|
||||
}
|
||||
}
|
||||
result.Kind = "cluster#taskList"
|
||||
return result, err
|
||||
}
|
||||
|
||||
|
@ -89,6 +90,7 @@ func (storage *TaskRegistryStorage) Get(id string) (interface{}, error) {
|
|||
return task, err
|
||||
}
|
||||
task.CurrentState.Info = info
|
||||
task.Kind = "cluster#task"
|
||||
return task, err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue