mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-10-05 13:46:51 +08:00
Adding GetCronWorkflow endpoint.
- Added supporting proto code - Added supporting server function and cron_workflow client function - Added extra checking for possible nil values
This commit is contained in:
@@ -16,19 +16,32 @@ func NewCronWorkflowServer() *CronWorkflowServer {
|
||||
|
||||
func apiCronWorkflow(cwf *v1.CronWorkflow) (cronWorkflow *api.CronWorkflow) {
|
||||
cronWorkflow = &api.CronWorkflow{
|
||||
Schedule: cwf.Schedule,
|
||||
Timezone: cwf.Timezone,
|
||||
Suspend: cwf.Suspend,
|
||||
ConcurrencyPolicy: cwf.ConcurrencyPolicy,
|
||||
StartingDeadlineSeconds: *cwf.StartingDeadlineSeconds,
|
||||
SuccessfulJobsHistoryLimit: *cwf.SuccessfulJobsHistoryLimit,
|
||||
FailedJobsHistoryLimit: *cwf.FailedJobsHistoryLimit,
|
||||
WorkflowExecution: GenApiWorkflowExecution(cwf.WorkflowExecution),
|
||||
Schedule: cwf.Schedule,
|
||||
Timezone: cwf.Timezone,
|
||||
Suspend: cwf.Suspend,
|
||||
ConcurrencyPolicy: cwf.ConcurrencyPolicy,
|
||||
}
|
||||
|
||||
if cwf.StartingDeadlineSeconds != nil {
|
||||
cronWorkflow.StartingDeadlineSeconds = *cwf.StartingDeadlineSeconds
|
||||
}
|
||||
|
||||
if cwf.SuccessfulJobsHistoryLimit != nil {
|
||||
cronWorkflow.SuccessfulJobsHistoryLimit = *cwf.SuccessfulJobsHistoryLimit
|
||||
}
|
||||
|
||||
if cwf.FailedJobsHistoryLimit != nil {
|
||||
cronWorkflow.FailedJobsHistoryLimit = *cwf.FailedJobsHistoryLimit
|
||||
}
|
||||
|
||||
if cwf.WorkflowExecution != nil {
|
||||
cronWorkflow.WorkflowExecution = GenApiWorkflowExecution(cwf.WorkflowExecution)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (c *CronWorkflowServer) CreateCronWorkflow(ctx context.Context, req *api.CreateWorkflowRequest) (*api.CronWorkflow, error) {
|
||||
func (c *CronWorkflowServer) CreateCronWorkflow(ctx context.Context, req *api.CreateCronWorkflowRequest) (*api.CronWorkflow, error) {
|
||||
client := ctx.Value("kubeClient").(*v1.Client)
|
||||
allowed, err := auth.IsAuthorized(client, req.Namespace, "create", "argoproj.io", "cronworkflows", "")
|
||||
if err != nil || !allowed {
|
||||
@@ -68,3 +81,16 @@ func (c *CronWorkflowServer) CreateCronWorkflow(ctx context.Context, req *api.Cr
|
||||
}
|
||||
return apiCronWorkflow(cwf), nil
|
||||
}
|
||||
|
||||
func (c *CronWorkflowServer) GetCronWorkflow(ctx context.Context, req *api.GetCronWorkflowRequest) (*api.CronWorkflow, error) {
|
||||
client := ctx.Value("kubeClient").(*v1.Client)
|
||||
allowed, err := auth.IsAuthorized(client, req.Namespace, "get", "argoproj.io", "cronworkflows", req.Name)
|
||||
if err != nil || !allowed {
|
||||
return nil, err
|
||||
}
|
||||
cwf, err := client.GetCronWorkflow(req.Namespace, req.Name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return apiCronWorkflow(cwf), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user