diff --git a/apiclient/bundles.go b/apiclient/bundles.go index 212b36c1..4995e37c 100644 --- a/apiclient/bundles.go +++ b/apiclient/bundles.go @@ -193,22 +193,28 @@ func ClearEntityPayloadList() { } //FetchAsyncBundle can download a shared flow or a proxy bundle -func FetchAsyncBundle(entityType string, folder string, name string, revision string, wg *sync.WaitGroup) { +func FetchAsyncBundle(entityType string, folder string, name string, revision string, allRevisions bool, wg *sync.WaitGroup) { //this method is meant to be called asynchronously defer wg.Done() - _ = FetchBundle(entityType, folder, name, revision) + _ = FetchBundle(entityType, folder, name, revision, allRevisions) } //FetchBundle can download a shared flow or proxy bundle -func FetchBundle(entityType string, folder string, name string, revision string) error { +func FetchBundle(entityType string, folder string, name string, revision string, allRevisions bool) error { + var proxyName string + u, _ := url.Parse(BaseURL) q := u.Query() q.Set("format", "bundle") u.RawQuery = q.Encode() u.Path = path.Join(u.Path, GetApigeeOrg(), entityType, name, "revisions", revision) - proxyName := name + "_" + revision + if allRevisions { + proxyName = name + "_" + revision + } else { + proxyName = name + } err := DownloadResource(u.String(), proxyName, ".zip") if err != nil { diff --git a/client/apis/apis.go b/client/apis/apis.go index 94b5200a..8cfba91d 100644 --- a/client/apis/apis.go +++ b/client/apis/apis.go @@ -90,7 +90,7 @@ func DeployProxy(name string, revision int, overrides bool, serviceAccountName s //FetchProxy func FetchProxy(name string, revision int) (err error) { - return apiclient.FetchBundle("apis", "", name, strconv.Itoa(revision)) + return apiclient.FetchBundle("apis", "", name, strconv.Itoa(revision), true) } //GetProxy @@ -410,13 +410,13 @@ func batchExport(entities []proxy, entityType string, folder string, allRevision //download only the last revision lastRevision := maxRevision(entity.Revision) clilog.Info.Printf("Downloading revision %s of proxy %s\n", lastRevision, entity.Name) - go apiclient.FetchAsyncBundle(entityType, folder, entity.Name, lastRevision, &bwg) + go apiclient.FetchAsyncBundle(entityType, folder, entity.Name, lastRevision, allRevisions, &bwg) } else { //download all revisions if len(entity.Revision) == 1 { lastRevision := maxRevision(entity.Revision) clilog.Info.Printf("Downloading revision %s of proxy %s\n", lastRevision, entity.Name) - apiclient.FetchAsyncBundle(entityType, folder, entity.Name, lastRevision, &bwg) + apiclient.FetchAsyncBundle(entityType, folder, entity.Name, lastRevision, allRevisions, &bwg) } else { numRevisions := len(entity.Revision) @@ -456,7 +456,7 @@ func batchExportRevisions(entityType string, folder string, name string, revisio for _, revision := range revisions { clilog.Info.Printf("Exporting proxy %s revision %s\n", name, revision) - go apiclient.FetchAsyncBundle(entityType, folder, name, revision, &brwg) + go apiclient.FetchAsyncBundle(entityType, folder, name, revision, true, &brwg) } brwg.Wait() } diff --git a/client/sharedflows/sharedflows.go b/client/sharedflows/sharedflows.go index 15925b7d..0f2a1c78 100644 --- a/client/sharedflows/sharedflows.go +++ b/client/sharedflows/sharedflows.go @@ -254,7 +254,7 @@ func Undeploy(name string, revision int) (respBody []byte, err error) { //Fetch func Fetch(name string, revision int) (err error) { - return apiclient.FetchBundle("sharedflows", "", name, strconv.Itoa(revision)) + return apiclient.FetchBundle("sharedflows", "", name, strconv.Itoa(revision), true) } //Export @@ -376,7 +376,7 @@ func batchExport(entities []sharedflow, entityType string, folder string, pwg *s //download only the last revision lastRevision := maxRevision(entity.Revision) clilog.Info.Printf("Downloading revision %s of sharedflow %s\n", lastRevision, entity.Name) - go apiclient.FetchAsyncBundle(entityType, folder, entity.Name, lastRevision, &bwg) + go apiclient.FetchAsyncBundle(entityType, folder, entity.Name, lastRevision, true, &bwg) } bwg.Wait() } diff --git a/cmd/apis/crtapi.go b/cmd/apis/crtapi.go index c5508a3e..d2e4ca3b 100644 --- a/cmd/apis/crtapi.go +++ b/cmd/apis/crtapi.go @@ -113,7 +113,7 @@ const bundleName = "apiproxy.zip" var proxy, oasFile, oasURI, gqlFile, gqlURI string var ghOwner, ghRepo, ghPath string -var importProxy, validateSpec, skipPolicy, addCORS, useGitHub bool +var importProxy, validateSpec, skipPolicy, addCORS, useGitHub, formatValidation bool func init() {