-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix: Fix the problem of unfiltered types in the backup database of cr… #8896
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
Conversation
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
| Database: mysql.Name, | ||
| Name: mysql.Name, | ||
| }) | ||
| } |
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.
The provided code snippet seems to be attempting to load database information based on certain criteria from an interface-based repository (MySQLRepo), but it makes two mistakes that need correction:
-
Misuse of Database Helper Method: The line
dbs = append(dbs, DatabaseHelper{...})implies that there is a method calledLoadItemsavailable within thedatabaseService. However, this method doesn't exist in the given code context. -
Improper Naming Convention: The variable name
databaseServiceshould likely refer to a service or factory type related to loading databases instead of directly accessing its methods.
To correct these issues without modifying other parts of the function unnecessarily, you can refactor the code as follows:
func loadDbsForJob(cronjob model.Cronjob) []DatabaseHelper {
var dbs []DatabaseHelper
if cronjob.DBName == "all" {
if cronjob.DBType == "mysql" || cronjob.DBType == "mariadb" {
// Assuming MySQLRepo has LoadAll() instead of List()
mysqlItems, _ := mysqlRepo.LoadAll()
// Alternatively, create a separate service for MySQL operations:
dbService := NewDBServiceInterface() // Replace with actual implementation
items, err := dbService.ListMysql()
if err != nil {
log.Println("Error fetching MySQL data:", err)
} else {
for _, item := range items {
dbs = append(dbs, DatabaseHelper{
ID: item.ID,
DBType: cronjob.DBType,
Database: item.Name, // Adjust field according to your DB struct definition
Name: item.Name,
})
}
}
} else { ... }
} else { ... }
}Key Points:
- If
mysqlRepohas a more convenient method likeLoadAll()which returns all databases, then use that. - Ensure naming conventions align appropriately (e.g., using
NewIDatabaseService, creatingdbServicefor clarity). - Properly handle errors when fetching data from services or repositories.
|
wanghe-fit2cloud
left a comment
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.
/lgtm
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: wanghe-fit2cloud The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |



…onjob