mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-10-22 05:00:07 +08:00
refactor: clean up client code
This commit is contained in:
@@ -56,7 +56,7 @@ func apiWorkflowTemplate(wft *v1.WorkflowTemplate) *api.WorkflowTemplate {
|
||||
}
|
||||
|
||||
func (s *WorkflowTemplateServer) CreateWorkflowTemplate(ctx context.Context, req *api.CreateWorkflowTemplateRequest) (*api.WorkflowTemplate, error) {
|
||||
client := ctx.Value("kubeClient").(*v1.Client)
|
||||
client := getClient(ctx)
|
||||
allowed, err := auth.IsAuthorized(client, req.Namespace, "create", "argoproj.io", "workflowtemplates", "")
|
||||
if err != nil || !allowed {
|
||||
return nil, err
|
||||
@@ -77,7 +77,7 @@ func (s *WorkflowTemplateServer) CreateWorkflowTemplate(ctx context.Context, req
|
||||
}
|
||||
|
||||
func (s *WorkflowTemplateServer) CreateWorkflowTemplateVersion(ctx context.Context, req *api.CreateWorkflowTemplateRequest) (*api.WorkflowTemplate, error) {
|
||||
client := ctx.Value("kubeClient").(*v1.Client)
|
||||
client := getClient(ctx)
|
||||
allowed, err := auth.IsAuthorized(client, req.Namespace, "create", "argoproj.io", "workflowtemplates", req.WorkflowTemplate.Name)
|
||||
if err != nil || !allowed {
|
||||
return nil, err
|
||||
@@ -107,7 +107,7 @@ func (s *WorkflowTemplateServer) CreateWorkflowTemplateVersion(ctx context.Conte
|
||||
}
|
||||
|
||||
func (s *WorkflowTemplateServer) UpdateWorkflowTemplateVersion(ctx context.Context, req *api.UpdateWorkflowTemplateVersionRequest) (*api.WorkflowTemplate, error) {
|
||||
client := ctx.Value("kubeClient").(*v1.Client)
|
||||
client := getClient(ctx)
|
||||
allowed, err := auth.IsAuthorized(client, req.Namespace, "update", "argoproj.io", "workflowtemplates", req.WorkflowTemplate.Name)
|
||||
if err != nil || !allowed {
|
||||
return nil, err
|
||||
@@ -128,7 +128,7 @@ func (s *WorkflowTemplateServer) UpdateWorkflowTemplateVersion(ctx context.Conte
|
||||
}
|
||||
|
||||
func (s *WorkflowTemplateServer) GetWorkflowTemplate(ctx context.Context, req *api.GetWorkflowTemplateRequest) (*api.WorkflowTemplate, error) {
|
||||
client := ctx.Value("kubeClient").(*v1.Client)
|
||||
client := getClient(ctx)
|
||||
allowed, err := auth.IsAuthorized(client, req.Namespace, "get", "argoproj.io", "workflowtemplates", "")
|
||||
if err != nil || !allowed {
|
||||
return nil, err
|
||||
@@ -149,7 +149,7 @@ func (s *WorkflowTemplateServer) GetWorkflowTemplate(ctx context.Context, req *a
|
||||
}
|
||||
|
||||
func (s *WorkflowTemplateServer) CloneWorkflowTemplate(ctx context.Context, req *api.CloneWorkflowTemplateRequest) (*api.WorkflowTemplate, error) {
|
||||
client := ctx.Value("kubeClient").(*v1.Client)
|
||||
client := getClient(ctx)
|
||||
|
||||
allowed, err := auth.IsAuthorized(client, req.Namespace, "create", "argoproj.io", "workflowtemplates", "")
|
||||
if err != nil || !allowed {
|
||||
@@ -187,7 +187,7 @@ func (s *WorkflowTemplateServer) CloneWorkflowTemplate(ctx context.Context, req
|
||||
}
|
||||
|
||||
func (s *WorkflowTemplateServer) ListWorkflowTemplateVersions(ctx context.Context, req *api.ListWorkflowTemplateVersionsRequest) (*api.ListWorkflowTemplateVersionsResponse, error) {
|
||||
client := ctx.Value("kubeClient").(*v1.Client)
|
||||
client := getClient(ctx)
|
||||
allowed, err := auth.IsAuthorized(client, req.Namespace, "list", "argoproj.io", "workflowtemplates", "")
|
||||
if err != nil || !allowed {
|
||||
return nil, err
|
||||
@@ -210,7 +210,7 @@ func (s *WorkflowTemplateServer) ListWorkflowTemplateVersions(ctx context.Contex
|
||||
}
|
||||
|
||||
func (s *WorkflowTemplateServer) ListWorkflowTemplates(ctx context.Context, req *api.ListWorkflowTemplatesRequest) (*api.ListWorkflowTemplatesResponse, error) {
|
||||
client := ctx.Value("kubeClient").(*v1.Client)
|
||||
client := getClient(ctx)
|
||||
allowed, err := auth.IsAuthorized(client, req.Namespace, "list", "argoproj.io", "workflowtemplates", "")
|
||||
if err != nil || !allowed {
|
||||
return nil, err
|
||||
@@ -242,7 +242,7 @@ func (s *WorkflowTemplateServer) ListWorkflowTemplates(ctx context.Context, req
|
||||
}
|
||||
|
||||
func (s *WorkflowTemplateServer) ArchiveWorkflowTemplate(ctx context.Context, req *api.ArchiveWorkflowTemplateRequest) (*api.ArchiveWorkflowTemplateResponse, error) {
|
||||
client := ctx.Value("kubeClient").(*v1.Client)
|
||||
client := getClient(ctx)
|
||||
allowed, err := auth.IsAuthorized(client, req.Namespace, "delete", "argoproj.io", "workflowtemplates", "")
|
||||
if err != nil || !allowed {
|
||||
return nil, err
|
||||
|
Reference in New Issue
Block a user