add workflow status webhook

This commit is contained in:
rushtehrani
2020-05-19 17:33:02 -07:00
parent 227d9c0d4e
commit 2df35cb27e
7 changed files with 544 additions and 49 deletions

View File

@@ -3,11 +3,12 @@ package server
import (
"context"
"github.com/argoproj/argo/pkg/apis/workflow/v1alpha1"
wfv1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1"
"github.com/onepanelio/core/pkg/util"
"github.com/onepanelio/core/pkg/util/pagination"
"github.com/onepanelio/core/server/converter"
"google.golang.org/grpc/codes"
argov1 "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sort"
"strings"
"time"
@@ -113,7 +114,8 @@ func (s *WorkflowServer) AddWorkflowExecutionStatistics(ctx context.Context, req
phase = v1alpha1.NodeSucceeded
}
workflow, err := client.ArgoprojV1alpha1().Workflows(req.Namespace).Get(req.Uid, argov1.GetOptions{})
// TODO: This needs to be moved to pkg
workflow, err := client.ArgoprojV1alpha1().Workflows(req.Namespace).Get(req.Uid, metav1.GetOptions{})
if err != nil {
return &empty.Empty{}, err
}
@@ -378,3 +380,18 @@ func (s *WorkflowServer) ListFiles(ctx context.Context, req *api.ListFilesReques
ParentPath: parentPath,
}, nil
}
func (s *WorkflowServer) UpdateWorkflowExecutionStatus(ctx context.Context, req *api.UpdateWorkflowExecutionStatusRequest) (*empty.Empty, error) {
client := ctx.Value("kubeClient").(*v1.Client)
allowed, err := auth.IsAuthorized(client, req.Namespace, "update", "argoproj.io", "workflows", req.Uid)
if err != nil || !allowed {
return &empty.Empty{}, err
}
status := &v1.WorkflowExecutionStatus{
Phase: wfv1.NodePhase(req.Status.Phase),
}
err = client.UpdateWorkflowExecutionStatus(req.Namespace, req.Uid, status)
return &empty.Empty{}, err
}