code push api modifications#14
Merged
Merged
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
ankitpunchh
approved these changes
May 13, 2026
There was a problem hiding this comment.
Pull request overview
This PR modifies the CodePush server API to expand bundle/deployment management functionality and to improve bundle upload responses and validation.
Changes:
- Add
/lsBundleendpoint to list recent deployment versions (with current package details when present). - Enhance
/uploadBundlewith size limiting and returningfileName+ a deriveddownloadUrl. - Allow optional caller-supplied deployment keys in
/createDeployment, and adjust/lsAppresponse shape.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| request/app.go | Adds bundle listing endpoint, changes upload bundle behavior/response, allows optional deployment key, adjusts app listing payload |
| model/deploymentVersion.go | Adds query helper to list latest deployment versions |
| main.go | Registers new authenticated route /lsBundle |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+242
to
244
| if err := os.WriteFile(path.Clean(cfg.CodePush.Local.SavePath+"/"+key), data, 0777); err != nil { | ||
| log.Panic(err.Error()) | ||
| } |
Comment on lines
+289
to
+301
| downloadURL := "" | ||
| if ru := strings.TrimSpace(cfg.ResourceUrl); ru != "" { | ||
| downloadURL = strings.TrimSuffix(ru, "/") + "/" + url.PathEscape(fileName) | ||
| } else { | ||
| switch cfg.CodePush.FileLocal { | ||
| case "aws": | ||
| a := cfg.CodePush.Aws | ||
| ep := strings.TrimSuffix(strings.TrimSpace(a.Endpoint), "/") | ||
| if a.S3ForcePathStyle || strings.HasPrefix(ep, "http://") || strings.HasPrefix(ep, "https://") { | ||
| downloadURL = fmt.Sprintf("%s/%s/%s", ep, a.Bucket, url.PathEscape(fileName)) | ||
| } else { | ||
| downloadURL = fmt.Sprintf("https://%s.s3.%s.amazonaws.com/%s", a.Bucket, a.Region, url.PathEscape(fileName)) | ||
| } |
Comment on lines
+170
to
+178
| if createDeploymentInfo.Key == nil || *createDeploymentInfo.Key == "" { | ||
| uuid, _ := uuid.NewUUID() | ||
| uuidStr := uuid.String() | ||
| createDeploymentInfo.Key = &uuidStr | ||
| } | ||
| newDeployment := model.Deployment{ | ||
| AppId: app.Id, | ||
| Name: createDeploymentInfo.DeploymentName, | ||
| Key: &key, | ||
| Key: createDeploymentInfo.Key, |
| Limit(limit). | ||
| Find(&rows).Error | ||
| if err != nil { | ||
| return []DeploymentVersion{} |
Comment on lines
+83
to
+86
| mandatory := false | ||
| if createBundleReq.Mandatory != nil { | ||
| mandatory = *createBundleReq.Mandatory | ||
| } |
Comment on lines
194
to
195
| _, headers, err := ctx.Request.FormFile("file") | ||
| if err != nil { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several important improvements to the bundle management and deployment APIs, focusing on enhanced bundle upload validation, new endpoints for listing bundles, and improved API responses. The most significant changes are grouped below by theme:
Bundle Upload Improvements:
UploadBundlehandler, with appropriate error responses for oversized files. The upload logic now reads only up to the allowed limit and responds with clear messages if exceeded. (request/app.go) [1] [2]request/app.go)API Enhancements:
lsBundleendpoint (and corresponding handler) to list the three most recent deployment versions (bundles) for a given app and deployment, including their metadata and current package details. (main.go,request/app.go,model/deploymentVersion.go) [1] [2] [3]CreateBundleAPI now accepts an optionalmandatoryfield and returns it in the response, allowing clients to specify and receive information about mandatory updates. (request/app.go) [1] [2]General API Response Improvements:
LsAppendpoint now returns structured app information (includingAppNameandOS) instead of just app names. (request/app.go)CreateDeploymentAPI now allows an optional custom deployment key and returns the actual key used, improving flexibility and clarity for clients. (request/app.go) [1] [2] [3]These changes collectively enhance the robustness, usability, and clarity of the codepush server's bundle and deployment management APIs.