From 44223254ae8e85bd0339a907e0cb6640987285d3 Mon Sep 17 00:00:00 2001 From: nikolay-spectro Date: Tue, 1 Aug 2023 11:21:09 -0700 Subject: [PATCH] PLT-595: Improve error handling when checking PCG status. --- client/private_cloud_gateway.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client/private_cloud_gateway.go b/client/private_cloud_gateway.go index 4e5523e4..e197fa8d 100644 --- a/client/private_cloud_gateway.go +++ b/client/private_cloud_gateway.go @@ -87,10 +87,15 @@ func (h *V1Client) CheckPCG(PcgId string) error { } if pcg == nil { return fmt.Errorf("Private Cloud Gateway not found: %s", PcgId) - } else if pcg.Status.State != "Running" { + } + if pcg.Status == nil { + return fmt.Errorf("Private Cloud Gateway status not found: %s", PcgId) + } + if pcg.Status.State != "Running" { return fmt.Errorf("Private Cloud Gateway is not running: %s", PcgId) + } else { + return nil // pcg is running } - return nil } // PCG - vSphere