From adda30aee54856243e925526cf5e3ac0873c55ec Mon Sep 17 00:00:00 2001 From: Jason Collins Date: Tue, 26 Sep 2023 09:49:15 -0700 Subject: [PATCH] code review comments --- client/pkg/apigee/proxy.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/pkg/apigee/proxy.go b/client/pkg/apigee/proxy.go index 7c323e0..36a8008 100644 --- a/client/pkg/apigee/proxy.go +++ b/client/pkg/apigee/proxy.go @@ -82,7 +82,7 @@ func (a *ApigeeClient) GetRevision(proxyName, revision string) (*models.ApiProxy return proxyRevision, nil } -// GetRevisionBundle - get a revision bundle of a proxy with a name +// GetRevisionConnectionType - get a revision bundle and open the proxy config file func (a *ApigeeClient) GetRevisionConnectionType(proxyName, revision string) (*HTTPProxyConnection, error) { response, err := a.newRequest(http.MethodGet, fmt.Sprintf("%s/apis/%s/revisions/%s", a.orgURL, proxyName, revision), WithDefaultHeaders(), @@ -92,7 +92,7 @@ func (a *ApigeeClient) GetRevisionConnectionType(proxyName, revision string) (*H return nil, err } - // response is a zip file, lets + // response is a zip file, lets open it and find the proxy config file zipReader, err := zip.NewReader(bytes.NewReader(response.Body), int64(len(response.Body))) if err != nil { return nil, err @@ -111,6 +111,10 @@ func (a *ApigeeClient) GetRevisionConnectionType(proxyName, revision string) (*H break } + if len(fileBytes) == 0 { + return nil, fmt.Errorf("could not find the proxy configuration file in the api revision bundle") + } + data := &proxyXML{} xml.Unmarshal(fileBytes, data)