Merge pull request #17 from brendandburns/ux

Populate 'Kind' fields for all JSON requests.  This will facilitate better client side UX.
pull/6/head
brendandburns 2014-06-07 22:04:04 -07:00
commit 0a6a9e4011
5 changed files with 16 additions and 6 deletions

View File

@ -130,6 +130,7 @@ type TaskTemplate struct {
// ServiceList holds a list of services
type ServiceList struct {
JSONBase
Items []Service `json:"items" yaml:"items"`
}

View File

@ -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 (

View File

@ -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 {

View File

@ -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 {

View File

@ -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
}