-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat: Ignore application upgrades to bypass all subsequent versions #8418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| package v2 | ||
|
|
||
| import ( | ||
| "github.com/1Panel-dev/1Panel/agent/app/api/v2/helper" | ||
| "github.com/1Panel-dev/1Panel/agent/app/dto/request" | ||
| "github.com/gin-gonic/gin" | ||
| ) | ||
|
|
||
| // @Tags App | ||
| // @Summary List Upgrade Ignored App | ||
| // @Accept json | ||
| // @Success 200 {array} model.AppIgnoreUpgrade | ||
| // @Security ApiKeyAuth | ||
| // @Security Timestamp | ||
| // @Router /apps/ignored/detail [get] | ||
| func (b *BaseApi) ListAppIgnored(c *gin.Context) { | ||
| res, err := appIgnoreUpgradeService.List() | ||
| if err != nil { | ||
| helper.InternalServer(c, err) | ||
| return | ||
| } | ||
| helper.SuccessWithData(c, res) | ||
| } | ||
|
|
||
| // @Tags App | ||
| // @Summary Ignore Upgrade App | ||
| // @Accept json | ||
| // @Param request body request.AppIgnoreUpgradeReq true "request" | ||
| // @Success 200 | ||
| // @Security ApiKeyAuth | ||
| // @Security Timestamp | ||
| // @Router /apps/installed/ignore [post] | ||
| // @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"忽略应用升级","formatEN":"Ignore application upgrade"} | ||
| func (b *BaseApi) IgnoreAppUpgrade(c *gin.Context) { | ||
| var req request.AppIgnoreUpgradeReq | ||
| if err := helper.CheckBindAndValidate(&req, c); err != nil { | ||
| return | ||
| } | ||
| if err := appIgnoreUpgradeService.CreateAppIgnore(req); err != nil { | ||
| helper.InternalServer(c, err) | ||
| return | ||
| } | ||
| helper.Success(c) | ||
| } | ||
|
|
||
| // 写一个去掉忽略的接口 | ||
| // @Tags App | ||
| // @Summary Cancel Ignore Upgrade App | ||
| // @Accept json | ||
| // @Param request body request.ReqWithID true "request" | ||
| // @Success 200 | ||
| // @Security ApiKeyAuth | ||
| // @Security Timestamp | ||
| // @Router /apps/ignored/cancel [post] | ||
| // @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"取消忽略应用升级","formatEN":"Cancel ignore application upgrade"} | ||
| func (b *BaseApi) CancelIgnoreAppUpgrade(c *gin.Context) { | ||
| var req request.ReqWithID | ||
| if err := helper.CheckBindAndValidate(&req, c); err != nil { | ||
| return | ||
| } | ||
| if err := appIgnoreUpgradeService.Delete(req); err != nil { | ||
| helper.InternalServer(c, err) | ||
| return | ||
| } | ||
| helper.Success(c) | ||
| } | ||
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code looks mostly correct with minor improvements. Here are some observations and suggestions:
Improvements
Package Naming: The package name
v2is reasonable, but it's worth checking if this versioning system aligns with the rest of the project.Import Statements: All necessary imports seem to be correctly placed at the beginning (
goimports) so that they don't have syntax errors.Endpoints:
/apps/ignored/detail: This endpoint lists all ignored apps without an ID filter./apps/installed/ignore: This endpoint ignores a specific app upgrade./apps/ignored/cancel: This endpoint cancels the ignore of a specific app upgrade.Ensure these endpoints meet intended functionality:
/apps/ignored/detailshould not require an ID parameter unless there's a clear business requirement for such filtering.req.IDinstead of justrequest.Error Handling:
helper.InternalServer(), which needs careful review for its implementation.Comments: Comments like
@Descriptioncould provide more context about what the endpoints do. For example, you can explain why certain fields or filters are used.API Logging:
Security:
ApiKeyAuthandTimestampsecurity tags suggest that your authentication mechanism includes API keys or timestamps. Ensure proper validation occurs on client side too to prevent unauthorized access.Optimization Suggestions
Avoid Redundant Calls to Helper Functions:
In many cases, helper functions can handle multiple types of inputs. If
CheckBindAndValidate()works fine alone without needing to separate it out into different helpers based on parameter type, consider combining logic where feasible.Code Reusability:
Review how various helper functions (e.g., binding validation) relate between individual controllers within the same base API class or structure.
Performance Considerations:
ListAppIgnored, etc.) optimize query performance.Overall, this code is well-structured and follows basic coding conventions. With additional testing specifically targeting scenarios involving ignoring / cancelling upgrades, further optimizations can be made tailored to the specifics of your application’s environment.