Skip to content

Commit

Permalink
feat: label actor action when making change to workflow/template. Fixes
Browse files Browse the repository at this point in the history
#14102 (#14104)

Signed-off-by: Tianchu Zhao <[email protected]>
  • Loading branch information
tczhao authored Jan 23, 2025
1 parent 514ea37 commit 7305c18
Show file tree
Hide file tree
Showing 14 changed files with 145 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (cwts *ClusterWorkflowTemplateServer) CreateClusterWorkflowTemplate(ctx con
return nil, serverutils.ToStatusError(fmt.Errorf("cluster workflow template was not found in the request body"), codes.InvalidArgument)
}
cwts.instanceIDService.Label(req.Template)
creator.Label(ctx, req.Template)
creator.LabelCreator(ctx, req.Template)
cwftmplGetter := cwts.cwftmplStore.Getter(ctx)
err := validate.ValidateClusterWorkflowTemplate(nil, cwftmplGetter, req.Template, cwts.wfDefaults, validate.ValidateOpts{})
if err != nil {
Expand Down Expand Up @@ -104,7 +104,7 @@ func (cwts *ClusterWorkflowTemplateServer) DeleteClusterWorkflowTemplate(ctx con

func (cwts *ClusterWorkflowTemplateServer) LintClusterWorkflowTemplate(ctx context.Context, req *clusterwftmplpkg.ClusterWorkflowTemplateLintRequest) (*v1alpha1.ClusterWorkflowTemplate, error) {
cwts.instanceIDService.Label(req.Template)
creator.Label(ctx, req.Template)
creator.LabelCreator(ctx, req.Template)
cwftmplGetter := cwts.cwftmplStore.Getter(ctx)

err := validate.ValidateClusterWorkflowTemplate(nil, cwftmplGetter, req.Template, cwts.wfDefaults, validate.ValidateOpts{Lint: true})
Expand All @@ -119,6 +119,7 @@ func (cwts *ClusterWorkflowTemplateServer) UpdateClusterWorkflowTemplate(ctx con
if req.Template == nil {
return nil, serverutils.ToStatusError(fmt.Errorf("ClusterWorkflowTemplate is not found in Request body"), codes.InvalidArgument)
}
creator.LabelActor(ctx, req.Template, creator.ActionUpdate)
err := cwts.instanceIDService.Validate(req.Template)
if err != nil {
return nil, serverutils.ToStatusError(err, codes.InvalidArgument)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/argoproj/argo-workflows/v3/server/auth/types"
"github.com/argoproj/argo-workflows/v3/util/instanceid"
"github.com/argoproj/argo-workflows/v3/workflow/common"
"github.com/argoproj/argo-workflows/v3/workflow/creator"
)

var unlabelled, cwftObj2, cwftObj3 v1alpha1.ClusterWorkflowTemplate
Expand Down Expand Up @@ -263,6 +264,8 @@ func TestWorkflowTemplateServer_UpdateClusterWorkflowTemplate(t *testing.T) {
req.Template.Spec.Templates[0].Container.Image = "alpine:latest"
cwftRsp, err := server.UpdateClusterWorkflowTemplate(ctx, req)
require.NoError(t, err)
assert.Contains(t, cwftRsp.Labels, common.LabelKeyActor)
assert.Equal(t, string(creator.ActionUpdate), cwftRsp.Labels[common.LabelKeyAction])
assert.Equal(t, "alpine:latest", cwftRsp.Spec.Templates[0].Container.Image)
})
t.Run("Unlabelled", func(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions server/cronworkflow/cron_workflow_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (c *cronWorkflowServiceServer) LintCronWorkflow(ctx context.Context, req *c
wftmplGetter := c.wftmplStore.Getter(ctx, req.Namespace)
cwftmplGetter := c.cwftmplStore.Getter(ctx)
c.instanceIDService.Label(req.CronWorkflow)
creator.Label(ctx, req.CronWorkflow)
creator.LabelCreator(ctx, req.CronWorkflow)
err := validate.ValidateCronWorkflow(ctx, wftmplGetter, cwftmplGetter, req.CronWorkflow, c.wfDefaults)
if err != nil {
return nil, sutils.ToStatusError(err, codes.InvalidArgument)
Expand All @@ -63,7 +63,7 @@ func (c *cronWorkflowServiceServer) CreateCronWorkflow(ctx context.Context, req
return nil, sutils.ToStatusError(fmt.Errorf("cron workflow was not found in the request body"), codes.NotFound)
}
c.instanceIDService.Label(req.CronWorkflow)
creator.Label(ctx, req.CronWorkflow)
creator.LabelCreator(ctx, req.CronWorkflow)
wftmplGetter := c.wftmplStore.Getter(ctx, req.Namespace)
cwftmplGetter := c.cwftmplStore.Getter(ctx)
err := validate.ValidateCronWorkflow(ctx, wftmplGetter, cwftmplGetter, req.CronWorkflow, c.wfDefaults)
Expand All @@ -90,6 +90,7 @@ func (c *cronWorkflowServiceServer) UpdateCronWorkflow(ctx context.Context, req
if err != nil {
return nil, sutils.ToStatusError(err, codes.Internal)
}
creator.LabelActor(ctx, req.CronWorkflow, creator.ActionUpdate)
wftmplGetter := c.wftmplStore.Getter(ctx, req.Namespace)
cwftmplGetter := c.cwftmplStore.Getter(ctx)
if err := validate.ValidateCronWorkflow(ctx, wftmplGetter, cwftmplGetter, req.CronWorkflow, c.wfDefaults); err != nil {
Expand Down
3 changes: 3 additions & 0 deletions server/cronworkflow/cron_workflow_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/argoproj/argo-workflows/v3/server/workflowtemplate"
"github.com/argoproj/argo-workflows/v3/util/instanceid"
"github.com/argoproj/argo-workflows/v3/workflow/common"
"github.com/argoproj/argo-workflows/v3/workflow/creator"
)

func Test_cronWorkflowServiceServer(t *testing.T) {
Expand Down Expand Up @@ -104,6 +105,8 @@ metadata:
})
t.Run("Labelled", func(t *testing.T) {
cronWf, err := server.UpdateCronWorkflow(ctx, &cronworkflowpkg.UpdateCronWorkflowRequest{Namespace: "my-ns", CronWorkflow: &cronWf})
assert.Contains(t, cronWf.Labels, common.LabelKeyActor)
assert.Equal(t, string(creator.ActionUpdate), cronWf.Labels[common.LabelKeyAction])
require.NoError(t, err)
assert.NotNil(t, cronWf)
})
Expand Down
2 changes: 1 addition & 1 deletion server/event/dispatch/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (o *Operation) dispatch(ctx context.Context, wfeb wfv1.WorkflowEventBinding

// users will always want to know why a workflow was submitted,
// so we label with creator (which is a standard) and the name of the triggering event
creator.Label(o.ctx, wf)
creator.LabelCreator(o.ctx, wf)
labels.Label(wf, common.LabelKeyWorkflowEventBinding, wfeb.Name)
if submit.Arguments != nil {
for _, p := range submit.Arguments.Parameters {
Expand Down
6 changes: 3 additions & 3 deletions server/workflow/workflow_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (s *workflowServer) CreateWorkflow(ctx context.Context, req *workflowpkg.Wo
}

s.instanceIDService.Label(req.Workflow)
creator.Label(ctx, req.Workflow)
creator.LabelCreator(ctx, req.Workflow)

wftmplGetter := s.wftmplStore.Getter(ctx, req.Workflow.Namespace)
cwftmplGetter := s.cwftmplStore.Getter(ctx)
Expand Down Expand Up @@ -669,7 +669,7 @@ func (s *workflowServer) LintWorkflow(ctx context.Context, req *workflowpkg.Work
wftmplGetter := s.wftmplStore.Getter(ctx, req.Workflow.Namespace)
cwftmplGetter := s.cwftmplStore.Getter(ctx)
s.instanceIDService.Label(req.Workflow)
creator.Label(ctx, req.Workflow)
creator.LabelCreator(ctx, req.Workflow)

err := validate.ValidateWorkflow(wftmplGetter, cwftmplGetter, req.Workflow, s.wfDefaults, validate.ValidateOpts{Lint: true})
if err != nil {
Expand Down Expand Up @@ -785,7 +785,7 @@ func (s *workflowServer) SubmitWorkflow(ctx context.Context, req *workflowpkg.Wo
}

s.instanceIDService.Label(wf)
creator.Label(ctx, wf)
creator.LabelCreator(ctx, wf)
err := util.ApplySubmitOpts(wf, req.SubmitOptions)
if err != nil {
return nil, sutils.ToStatusError(err, codes.Internal)
Expand Down
9 changes: 9 additions & 0 deletions server/workflow/workflow_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/argoproj/argo-workflows/v3/util"
"github.com/argoproj/argo-workflows/v3/util/instanceid"
"github.com/argoproj/argo-workflows/v3/workflow/common"
"github.com/argoproj/argo-workflows/v3/workflow/creator"
)

const unlabelled = `{
Expand Down Expand Up @@ -811,9 +812,13 @@ func TestSuspendResumeWorkflow(t *testing.T) {
require.NoError(t, err)
assert.NotNil(t, wf)
assert.True(t, *wf.Spec.Suspend)
assert.Contains(t, wf.Labels, common.LabelKeyActor)
assert.Equal(t, string(creator.ActionSuspend), wf.Labels[common.LabelKeyAction])
wf, err = server.ResumeWorkflow(ctx, &workflowpkg.WorkflowResumeRequest{Name: wf.Name, Namespace: wf.Namespace})
require.NoError(t, err)
assert.NotNil(t, wf)
assert.Contains(t, wf.Labels, common.LabelKeyActor)
assert.Equal(t, string(creator.ActionResume), wf.Labels[common.LabelKeyAction])
assert.Nil(t, wf.Spec.Suspend)
}

Expand Down Expand Up @@ -848,6 +853,8 @@ func TestTerminateWorkflow(t *testing.T) {
wf, err = server.TerminateWorkflow(ctx, &rsmWfReq)
assert.NotNil(t, wf)
assert.Equal(t, v1alpha1.ShutdownStrategyTerminate, wf.Spec.Shutdown)
assert.Contains(t, wf.Labels, common.LabelKeyActor)
assert.Equal(t, string(creator.ActionTerminate), wf.Labels[common.LabelKeyAction])
require.NoError(t, err)

rsmWfReq = workflowpkg.WorkflowTerminateRequest{
Expand All @@ -868,6 +875,8 @@ func TestStopWorkflow(t *testing.T) {
require.NoError(t, err)
assert.NotNil(t, wf)
assert.Equal(t, v1alpha1.WorkflowRunning, wf.Status.Phase)
assert.Contains(t, wf.Labels, common.LabelKeyActor)
assert.Equal(t, string(creator.ActionStop), wf.Labels[common.LabelKeyAction])
}

func TestResubmitWorkflow(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions server/workflowtemplate/workflow_template_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (wts *WorkflowTemplateServer) CreateWorkflowTemplate(ctx context.Context, r
return nil, sutils.ToStatusError(fmt.Errorf("workflow template was not found in the request body"), codes.InvalidArgument)
}
wts.instanceIDService.Label(req.Template)
creator.Label(ctx, req.Template)
creator.LabelCreator(ctx, req.Template)
wftmplGetter := wts.wftmplStore.Getter(ctx, req.Namespace)
cwftmplGetter := wts.cwftmplStore.Getter(ctx)
err := validate.ValidateWorkflowTemplate(wftmplGetter, cwftmplGetter, req.Template, nil, validate.ValidateOpts{})
Expand Down Expand Up @@ -177,7 +177,7 @@ func (wts *WorkflowTemplateServer) DeleteWorkflowTemplate(ctx context.Context, r

func (wts *WorkflowTemplateServer) LintWorkflowTemplate(ctx context.Context, req *workflowtemplatepkg.WorkflowTemplateLintRequest) (*v1alpha1.WorkflowTemplate, error) {
wts.instanceIDService.Label(req.Template)
creator.Label(ctx, req.Template)
creator.LabelCreator(ctx, req.Template)
wftmplGetter := wts.wftmplStore.Getter(ctx, req.Namespace)
cwftmplGetter := wts.cwftmplStore.Getter(ctx)
err := validate.ValidateWorkflowTemplate(wftmplGetter, cwftmplGetter, req.Template, nil, validate.ValidateOpts{Lint: true})
Expand All @@ -195,6 +195,7 @@ func (wts *WorkflowTemplateServer) UpdateWorkflowTemplate(ctx context.Context, r
if err != nil {
return nil, sutils.ToStatusError(err, codes.InvalidArgument)
}
creator.LabelActor(ctx, req.Template, creator.ActionUpdate)
wfClient := auth.GetWfClient(ctx)
wftmplGetter := wts.wftmplStore.Getter(ctx, req.Namespace)
cwftmplGetter := wts.cwftmplStore.Getter(ctx)
Expand Down
3 changes: 3 additions & 0 deletions server/workflowtemplate/workflow_template_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/argoproj/argo-workflows/v3/server/clusterworkflowtemplate"
"github.com/argoproj/argo-workflows/v3/util/instanceid"
"github.com/argoproj/argo-workflows/v3/workflow/common"
"github.com/argoproj/argo-workflows/v3/workflow/creator"
)

const unlabelled = `{
Expand Down Expand Up @@ -266,6 +267,8 @@ func TestWorkflowTemplateServer_UpdateWorkflowTemplate(t *testing.T) {
Template: &wftObj1,
})
require.NoError(t, err)
assert.Contains(t, wftRsp.Labels, common.LabelKeyActor)
assert.Equal(t, string(creator.ActionUpdate), wftRsp.Labels[common.LabelKeyAction])
assert.Equal(t, "alpine:latest", wftRsp.Spec.Templates[0].Container.Image)
})
t.Run("Unlabelled", func(t *testing.T) {
Expand Down
5 changes: 5 additions & 0 deletions workflow/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ const (
LabelKeyCreator = workflow.WorkflowFullName + "/creator"
LabelKeyCreatorEmail = workflow.WorkflowFullName + "/creator-email"
LabelKeyCreatorPreferredUsername = workflow.WorkflowFullName + "/creator-preferred-username"
// Who action on this workflow.
LabelKeyActor = workflow.WorkflowFullName + "/actor"
LabelKeyActorEmail = workflow.WorkflowFullName + "/actor-email"
LabelKeyActorPreferredUsername = workflow.WorkflowFullName + "/actor-preferred-username"
LabelKeyAction = workflow.WorkflowFullName + "/action"
// LabelKeyCompleted is the metadata label applied on workflows and workflow pods to indicates if resource is completed
// Workflows and pods with a completed=true label will be ignored by the controller.
// See also `LabelKeyWorkflowArchivingStatus`.
Expand Down
66 changes: 56 additions & 10 deletions workflow/creator/creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,58 @@ import (
"github.com/argoproj/argo-workflows/v3/workflow/common"
)

func Label(ctx context.Context, obj metav1.Object) {
type ActionType string

const (
ActionUpdate ActionType = "Update"
ActionSuspend ActionType = "Suspend"
ActionStop ActionType = "Stop"
ActionTerminate ActionType = "Terminate"
ActionResume ActionType = "Resume"
ActionNone ActionType = ""
)

func Label(ctx context.Context, obj metav1.Object, userLabelKey string, userEmailLabelKey string, preferredUsernameLabelKey string, action ActionType) {
claims := auth.GetClaims(ctx)
if claims != nil {
if claims.Subject != "" {
labels.Label(obj, common.LabelKeyCreator, dnsFriendly(claims.Subject))
labels.Label(obj, userLabelKey, dnsFriendly(claims.Subject))
} else {
labels.UnLabel(obj, common.LabelKeyCreator)
labels.UnLabel(obj, userLabelKey)
}
if claims.Email != "" {
labels.Label(obj, common.LabelKeyCreatorEmail, dnsFriendly(strings.Replace(claims.Email, "@", ".at.", 1)))
labels.Label(obj, userEmailLabelKey, dnsFriendly(strings.Replace(claims.Email, "@", ".at.", 1)))
} else {
labels.UnLabel(obj, common.LabelKeyCreatorEmail)
labels.UnLabel(obj, userEmailLabelKey)
}
if claims.PreferredUsername != "" {
labels.Label(obj, common.LabelKeyCreatorPreferredUsername, dnsFriendly(claims.PreferredUsername))
labels.Label(obj, preferredUsernameLabelKey, dnsFriendly(claims.PreferredUsername))
} else {
labels.UnLabel(obj, common.LabelKeyCreatorPreferredUsername)
labels.UnLabel(obj, preferredUsernameLabelKey)
}
if action != ActionNone {
labels.Label(obj, common.LabelKeyAction, dnsFriendly(string(action)))
} else {
labels.UnLabel(obj, common.LabelKeyAction)
}
} else {
// If the object already has creator-related labels, but the actual request lacks auth information,
// remove the creator-related labels from the object.
labels.UnLabel(obj, common.LabelKeyCreator)
labels.UnLabel(obj, common.LabelKeyCreatorEmail)
labels.UnLabel(obj, common.LabelKeyCreatorPreferredUsername)
labels.UnLabel(obj, userLabelKey)
labels.UnLabel(obj, userEmailLabelKey)
labels.UnLabel(obj, preferredUsernameLabelKey)
labels.UnLabel(obj, common.LabelKeyAction)
}
}

func LabelCreator(ctx context.Context, obj metav1.Object) {
Label(ctx, obj, common.LabelKeyCreator, common.LabelKeyCreatorEmail, common.LabelKeyCreatorPreferredUsername, ActionNone)
}

func LabelActor(ctx context.Context, obj metav1.Object, action ActionType) {
Label(ctx, obj, common.LabelKeyActor, common.LabelKeyActorEmail, common.LabelKeyActorPreferredUsername, action)
}

// https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set
func dnsFriendly(s string) string {
value := regexp.MustCompile("[^-_.a-z0-9A-Z]").ReplaceAllString(s, "-")
Expand Down Expand Up @@ -67,3 +92,24 @@ func UserInfoMap(ctx context.Context) map[string]string {
}
return res
}

func UserActionLabel(ctx context.Context, action ActionType) map[string]string {
claims := auth.GetClaims(ctx)
if claims == nil {
return nil
}
res := map[string]string{}
if claims.Subject != "" {
res[common.LabelKeyActor] = dnsFriendly(claims.Subject)
}
if claims.Email != "" {
res[common.LabelKeyActorEmail] = dnsFriendly(claims.Email)
}
if claims.PreferredUsername != "" {
res[common.LabelKeyActorPreferredUsername] = dnsFriendly(claims.PreferredUsername)
}
if action != ActionNone {
res[common.LabelKeyAction] = string(action)
}
return res
}
33 changes: 24 additions & 9 deletions workflow/creator/creator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,52 @@ import (
"github.com/argoproj/argo-workflows/v3/workflow/common"
)

func TestLabel(t *testing.T) {
t.Run("Empty", func(t *testing.T) {
func TestLabelCreator(t *testing.T) {
t.Run("EmptyCreator", func(t *testing.T) {
wf := &wfv1.Workflow{}
Label(context.TODO(), wf)
LabelCreator(context.TODO(), wf)
assert.Empty(t, wf.Labels)
})
t.Run("NotEmpty", func(t *testing.T) {
t.Run("EmptyActor", func(t *testing.T) {
wf := &wfv1.Workflow{}
LabelActor(context.TODO(), wf, ActionResume)
assert.Empty(t, wf.Labels)
})
t.Run("NotEmptyCreator", func(t *testing.T) {
wf := &wfv1.Workflow{}
Label(context.WithValue(context.TODO(), auth.ClaimsKey, &types.Claims{Claims: jwt.Claims{Subject: strings.Repeat("x", 63) + "y"}, Email: "my@email", PreferredUsername: "username"}), wf)
LabelCreator(context.WithValue(context.TODO(), auth.ClaimsKey, &types.Claims{Claims: jwt.Claims{Subject: strings.Repeat("x", 63) + "y"}, Email: "my@email", PreferredUsername: "username"}), wf)
require.NotEmpty(t, wf.Labels)
assert.Equal(t, strings.Repeat("x", 62)+"y", wf.Labels[common.LabelKeyCreator], "creator is truncated")
assert.Equal(t, "my.at.email", wf.Labels[common.LabelKeyCreatorEmail], "'@' is replaced by '.at.'")
assert.Equal(t, "username", wf.Labels[common.LabelKeyCreatorPreferredUsername], "username is matching")
assert.Empty(t, wf.Labels[common.LabelKeyAction])
})
t.Run("NotEmptyActor", func(t *testing.T) {
wf := &wfv1.Workflow{}
LabelActor(context.WithValue(context.TODO(), auth.ClaimsKey, &types.Claims{Claims: jwt.Claims{Subject: strings.Repeat("x", 63) + "y"}, Email: "my@email", PreferredUsername: "username"}), wf, ActionResume)
require.NotEmpty(t, wf.Labels)
assert.Equal(t, strings.Repeat("x", 62)+"y", wf.Labels[common.LabelKeyActor], "creator is truncated")
assert.Equal(t, "my.at.email", wf.Labels[common.LabelKeyActorEmail], "'@' is replaced by '.at.'")
assert.Equal(t, "username", wf.Labels[common.LabelKeyActorPreferredUsername], "username is matching")
assert.Equal(t, "Resume", wf.Labels[common.LabelKeyAction])
})
t.Run("TooLongHyphen", func(t *testing.T) {
wf := &wfv1.Workflow{}
Label(context.WithValue(context.TODO(), auth.ClaimsKey, &types.Claims{Claims: jwt.Claims{Subject: strings.Repeat("-", 63) + "y"}}), wf)
LabelCreator(context.WithValue(context.TODO(), auth.ClaimsKey, &types.Claims{Claims: jwt.Claims{Subject: strings.Repeat("-", 63) + "y"}}), wf)
require.NotEmpty(t, wf.Labels)
assert.Equal(t, "y", wf.Labels[common.LabelKeyCreator])
})
t.Run("InvalidDNSNames", func(t *testing.T) {
wf := &wfv1.Workflow{}
Label(context.WithValue(context.TODO(), auth.ClaimsKey, &types.Claims{Claims: jwt.Claims{Subject: "!@#$%^&*()--__" + strings.Repeat("y", 35) + "__--!@#$%^&*()"}, PreferredUsername: "us#er@name#"}), wf)
LabelCreator(context.WithValue(context.TODO(), auth.ClaimsKey, &types.Claims{Claims: jwt.Claims{Subject: "!@#$%^&*()--__" + strings.Repeat("y", 35) + "__--!@#$%^&*()"}, PreferredUsername: "us#er@name#"}), wf)
require.NotEmpty(t, wf.Labels)
assert.Equal(t, strings.Repeat("y", 35), wf.Labels[common.LabelKeyCreator])
assert.Equal(t, "us-er-name", wf.Labels[common.LabelKeyCreatorPreferredUsername], "username is truncated")
})
t.Run("InvalidDNSNamesWithMidDashes", func(t *testing.T) {
wf := &wfv1.Workflow{}
sub := strings.Repeat("x", 20) + strings.Repeat("-", 70) + strings.Repeat("x", 20)
Label(context.WithValue(context.TODO(), auth.ClaimsKey, &types.Claims{Claims: jwt.Claims{Subject: sub}}), wf)
LabelCreator(context.WithValue(context.TODO(), auth.ClaimsKey, &types.Claims{Claims: jwt.Claims{Subject: sub}}), wf)
require.NotEmpty(t, wf.Labels)
assert.Equal(t, strings.Repeat("x", 20), wf.Labels[common.LabelKeyCreator])
})
Expand Down Expand Up @@ -113,7 +128,7 @@ func TestLabel(t *testing.T) {
},
} {
t.Run(testCase.name, func(t *testing.T) {
Label(context.WithValue(context.TODO(), auth.ClaimsKey, testCase.input.claims), testCase.input.wf)
LabelCreator(context.WithValue(context.TODO(), auth.ClaimsKey, testCase.input.claims), testCase.input.wf)
labels := testCase.input.wf.GetLabels()
for k, expectedValue := range testCase.output.creatorLabelsToHave {
assert.Equal(t, expectedValue, labels[k])
Expand Down
Loading

0 comments on commit 7305c18

Please sign in to comment.