From 9770ff9082c221436c7e4b233c6f96f356f715a5 Mon Sep 17 00:00:00 2001 From: yanxuean Date: Thu, 16 Aug 2018 08:56:30 +0800 Subject: [PATCH] improve GetExistingContainerStatus remove duplicate Signed-off-by: yanxuean --- pkg/api/v1/pod/util.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pkg/api/v1/pod/util.go b/pkg/api/v1/pod/util.go index 67fc6e5ed0b..6c0d2438154 100644 --- a/pkg/api/v1/pod/util.go +++ b/pkg/api/v1/pod/util.go @@ -205,14 +205,10 @@ func GetContainerStatus(statuses []v1.ContainerStatus, name string) (v1.Containe } // GetExistingContainerStatus extracts the status of container "name" from "statuses", -// and returns empty status if "name" does not exist. +// It also returns if "name" exists. func GetExistingContainerStatus(statuses []v1.ContainerStatus, name string) v1.ContainerStatus { - for i := range statuses { - if statuses[i].Name == name { - return statuses[i] - } - } - return v1.ContainerStatus{} + status, _ := GetContainerStatus(statuses, name) + return status } // IsPodAvailable returns true if a pod is available; false otherwise.