Skip to content
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

feat: 发布etcd配置添加MySQL记录 #436

Merged
merged 2 commits into from
Feb 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions internal/pkg/service/confgov2/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,8 @@ func PublishAllConfig() (err error) {
if query.Error != nil {
return
}
settings, err := system.System.Setting.GetAll()
clusterList := view.ClusterList{}
for _, item := range configuration {
var confHistory db.ConfigurationHistory
query = mysql.Where("configuration_id= ?", item.ID).Order("id desc").First(&confHistory)
Expand All @@ -782,6 +784,32 @@ func PublishAllConfig() (err error) {
}); err != nil {
continue
}
var cp db.ConfigurationPublish
cp.ConfigurationID = item.ID
cp.ConfigurationHistoryID = confHistory.ID
if err = mysql.Save(&cp).Error; err != nil {
continue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加下错误日志

}
_, cp.FilePath = genConfigurePath(appInfo.AppName, item.FileName())
if _, ok := settings["k8s_cluster"]; ok {
if err = json.Unmarshal([]byte(settings["k8s_cluster"]), &clusterList); err == nil {
for _, instance := range clusterList.List {
var cs db.ConfigurationClusterStatus
cs.ConfigurationID = item.ID
cs.ConfigurationPublishID = cp.ID
cs.ClusterName = instance.Name
cs.Used = 0
cs.Synced = 0
cs.TakeEffect = 0
cs.CreatedAt = time.Now()
cs.UpdateAt = time.Now()
if sErr := mysql.Save(&cs).Error; sErr != nil {
continue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

}
}

}
}
}
return
}
Expand Down