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

Adding events to deployment details

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