提交 459221d2 编写于 作者: L Luiz Felipe G. Pereira

Adding events to deployment details

上级 49d8ea82
......@@ -37,11 +37,11 @@ type DeploymentDetail struct {
// OldReplicaSets
OldReplicaSets []extensions.ReplicaSet `json:"oldReplicaSets"`
// NewReplicaSet
// New replica set used by this deployment
NewReplicaSet extensions.ReplicaSet `json:"newReplicaSet"`
// Events
// TODO
// List of events related to this Deployment
EventList common.EventList `json:"eventList"`
}
func GetDeploymentDetail(client client.Interface, namespace string, name string) (*DeploymentDetail, error) {
......@@ -78,10 +78,15 @@ func GetDeploymentDetail(client client.Interface, namespace string, name string)
return nil, err
}
return getDeploymentDetail(deploymentData, oldReplicaSets, newReplicaSet), nil
events, err := GetDeploymentEvents(client, namespace, name)
if err != nil {
return nil, err
}
return getDeploymentDetail(deploymentData, oldReplicaSets, newReplicaSet, events), nil
}
func getDeploymentDetail(deployment *extensions.Deployment, old []*extensions.ReplicaSet, newReplicaSet *extensions.ReplicaSet) *DeploymentDetail {
func getDeploymentDetail(deployment *extensions.Deployment, old []*extensions.ReplicaSet, newReplicaSet *extensions.ReplicaSet, events *common.EventList) *DeploymentDetail {
oldReplicaSets := make([]extensions.ReplicaSet, len(old))
for i, replicaSet := range old {
......@@ -101,5 +106,6 @@ func getDeploymentDetail(deployment *extensions.Deployment, old []*extensions.Re
},
OldReplicaSets: oldReplicaSets,
NewReplicaSet: *newReplicaSet,
EventList: *events,
}
}
......@@ -16,6 +16,7 @@ import (
func TestGetDeploymentDetail(t *testing.T) {
podList := &api.PodList{}
eventList := &api.EventList{}
deployment := &extensions.Deployment{
ObjectMeta: api.ObjectMeta{
......@@ -74,7 +75,7 @@ func TestGetDeploymentDetail(t *testing.T) {
}{
{
"test-namespace", "test-name",
[]string{"get", "list", "list"},
[]string{"get", "list", "list", "list"},
deployment,
&DeploymentDetail{
ObjectMeta: common.ObjectMeta{
......@@ -97,13 +98,17 @@ func TestGetDeploymentDetail(t *testing.T) {
},
OldReplicaSets: []extensions.ReplicaSet{},
NewReplicaSet: newReplicaSet,
EventList: common.EventList{
Namespace: "test-namespace",
Events: []common.Event{},
},
},
},
}
for _, c := range cases {
fakeClient := testclient.NewSimpleFake(c.deployment, replicaSetList, podList)
fakeClient := testclient.NewSimpleFake(c.deployment, replicaSetList, podList, eventList)
actual, _ := GetDeploymentDetail(fakeClient, c.namespace, c.name)
......@@ -123,7 +128,7 @@ func TestGetDeploymentDetail(t *testing.T) {
if !reflect.DeepEqual(actual, c.expected) {
t.Errorf("GetDeploymentDetail(client, namespace, name) == \ngot: %#v, \nexpected %#v",
c.namespace, c.name, actual, c.expected)
actual, c.expected)
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册