Skip to content

Commit 8aad740

Browse files
committed
chore: merge fix
Signed-off-by: Alan Clucas <alan@clucas.org>
1 parent 8f505a5 commit 8aad740

1 file changed

Lines changed: 12 additions & 16 deletions

File tree

workflow/controller/operator_test.go

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5660,58 +5660,54 @@ func TestReferenceModeBlocksPodSpecPatch(t *testing.T) {
56605660
t.Run("Strict rejects podSpecPatch", func(t *testing.T) {
56615661
wfWithPatch := wf.DeepCopy()
56625662
wfWithPatch.Spec.PodSpecPatch = `{"containers":[{"name":"main","securityContext":{"privileged":true}}]}`
5663-
cancel, controller := newController(logging.TestContext(t.Context()), wfWithPatch, wfTmpl)
5663+
cancel, controller := newController(wfWithPatch, wfTmpl)
56645664
defer cancel()
56655665

5666-
ctx := logging.TestContext(t.Context())
56675666
controller.Config.WorkflowRestrictions = &config.WorkflowRestrictions{
56685667
TemplateReferencing: config.TemplateReferencingStrict,
56695668
}
5670-
woc := newWorkflowOperationCtx(ctx, wfWithPatch, controller)
5671-
woc.operate(ctx)
5669+
woc := newWorkflowOperationCtx(wfWithPatch, controller)
5670+
woc.operate(t.Context())
56725671
assert.Equal(t, wfv1.WorkflowError, woc.wf.Status.Phase)
56735672
assert.Contains(t, woc.wf.Status.Message, "podSpecPatch is not permitted")
56745673
})
56755674

56765675
t.Run("Secure rejects podSpecPatch", func(t *testing.T) {
56775676
wfWithPatch := wf.DeepCopy()
56785677
wfWithPatch.Spec.PodSpecPatch = `{"containers":[{"name":"main","securityContext":{"runAsUser":0}}]}`
5679-
cancel, controller := newController(logging.TestContext(t.Context()), wfWithPatch, wfTmpl)
5678+
cancel, controller := newController(wfWithPatch, wfTmpl)
56805679
defer cancel()
56815680

5682-
ctx := logging.TestContext(t.Context())
56835681
controller.Config.WorkflowRestrictions = &config.WorkflowRestrictions{
56845682
TemplateReferencing: config.TemplateReferencingSecure,
56855683
}
5686-
woc := newWorkflowOperationCtx(ctx, wfWithPatch, controller)
5687-
woc.operate(ctx)
5684+
woc := newWorkflowOperationCtx(wfWithPatch, controller)
5685+
woc.operate(t.Context())
56885686
assert.Equal(t, wfv1.WorkflowError, woc.wf.Status.Phase)
56895687
assert.Contains(t, woc.wf.Status.Message, "podSpecPatch is not permitted")
56905688
})
56915689

56925690
t.Run("No restrictions allows podSpecPatch", func(t *testing.T) {
56935691
wfWithPatch := wf.DeepCopy()
56945692
wfWithPatch.Spec.PodSpecPatch = `{"containers":[{"name":"main","resources":{"limits":{"cpu":"1"}}}]}`
5695-
cancel, controller := newController(logging.TestContext(t.Context()), wfWithPatch, wfTmpl)
5693+
cancel, controller := newController(wfWithPatch, wfTmpl)
56965694
defer cancel()
56975695

5698-
ctx := logging.TestContext(t.Context())
56995696
controller.Config.WorkflowRestrictions = nil
5700-
woc := newWorkflowOperationCtx(ctx, wfWithPatch, controller)
5701-
woc.operate(ctx)
5697+
woc := newWorkflowOperationCtx(wfWithPatch, controller)
5698+
woc.operate(t.Context())
57025699
assert.Equal(t, wfv1.WorkflowRunning, woc.wf.Status.Phase)
57035700
})
57045701

57055702
t.Run("Without podSpecPatch still works in Strict mode", func(t *testing.T) {
5706-
cancel, controller := newController(logging.TestContext(t.Context()), wf, wfTmpl)
5703+
cancel, controller := newController(wf, wfTmpl)
57075704
defer cancel()
57085705

5709-
ctx := logging.TestContext(t.Context())
57105706
controller.Config.WorkflowRestrictions = &config.WorkflowRestrictions{
57115707
TemplateReferencing: config.TemplateReferencingStrict,
57125708
}
5713-
woc := newWorkflowOperationCtx(ctx, wf, controller)
5714-
woc.operate(ctx)
5709+
woc := newWorkflowOperationCtx(wf, controller)
5710+
woc.operate(t.Context())
57155711
assert.Equal(t, wfv1.WorkflowRunning, woc.wf.Status.Phase)
57165712
})
57175713
}

0 commit comments

Comments
 (0)