Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
fix #16: bundle rev not always incl in zip
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Dec 22, 2021
1 parent 40599ad commit 4d2bb3b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
14 changes: 10 additions & 4 deletions apiclient/bundles.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions client/apis/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
}
Expand Down
4 changes: 2 additions & 2 deletions client/sharedflows/sharedflows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/apis/crtapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand Down

0 comments on commit 4d2bb3b

Please sign in to comment.