pcm-kubernetes/internal/cron/applycron.go

40 lines
1.3 KiB
Go

package cron
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/client/participantservice"
"gitlink.org.cn/jcce-pcm/pcm-participant-kubernetes/internal/pkg"
"gitlink.org.cn/jcce-pcm/pcm-participant-kubernetes/internal/svc"
)
func ApplyList(svc *svc.ServiceContext) {
listResp, err := svc.ParticipantRpc.ApplyList(context.Background(), &participantservice.ApplyListReq{})
if err != nil {
return
}
for _, info := range listResp.InfoList {
pkg.Apply(info.YamlString, pkg.KClients[info.ParticipantName].ClientSet, pkg.KClients[info.ParticipantName].DynamicClient)
}
}
func DeleteList(svc *svc.ServiceContext) {
listResp, err := svc.ParticipantRpc.DeleteList(context.Background(), &participantservice.ApplyListReq{})
if err != nil {
return
}
for _, info := range listResp.InfoList {
pkg.Delete(info.YamlString, pkg.KClients[info.ParticipantName].ClientSet, pkg.KClients[info.ParticipantName].DynamicClient)
}
}
func RestartList(svc *svc.ServiceContext) {
listResp, err := svc.ParticipantRpc.RestartList(context.Background(), &participantservice.ApplyListReq{})
if err != nil {
return
}
for _, info := range listResp.InfoList {
pkg.Restart(info.Name, info.Namespace, info.Kind, pkg.KClients[info.ParticipantName].ClientSet, pkg.KClients[info.ParticipantName].DynamicClient)
}
}