mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-10-30 00:11:45 +08:00
Added TerminateCronWorkflow endpoint.
- Also updated CronWorkflow message to include the name of the cron workflow. - Updated related function that parses and sets the struct values, to include the name attribute
This commit is contained in:
@@ -2,6 +2,7 @@ package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
"github.com/onepanelio/core/api"
|
||||
v1 "github.com/onepanelio/core/pkg"
|
||||
"github.com/onepanelio/core/pkg/util/ptr"
|
||||
@@ -17,6 +18,7 @@ func NewCronWorkflowServer() *CronWorkflowServer {
|
||||
|
||||
func apiCronWorkflow(cwf *v1.CronWorkflow) (cronWorkflow *api.CronWorkflow) {
|
||||
cronWorkflow = &api.CronWorkflow{
|
||||
Name: cwf.Name,
|
||||
Schedule: cwf.Schedule,
|
||||
Timezone: cwf.Timezone,
|
||||
Suspend: cwf.Suspend,
|
||||
@@ -139,3 +141,18 @@ func (c *CronWorkflowServer) ListCronWorkflows(ctx context.Context, req *api.Lis
|
||||
TotalCount: int32(len(apiCronWorkflows)),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *CronWorkflowServer) TerminateCronWorkflow(ctx context.Context, req *api.TerminateCronWorkflowRequest) (*empty.Empty, error) {
|
||||
client := ctx.Value("kubeClient").(*v1.Client)
|
||||
allowed, err := auth.IsAuthorized(client, req.Namespace, "delete", "argoproj.io", "cronworkflows", "")
|
||||
if err != nil || !allowed {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = client.TerminateWorkflowExecution(req.Namespace, req.Name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &empty.Empty{}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user