From 3a84d9f90f11c21fae0dcabc3188bf88a3c6b8bd Mon Sep 17 00:00:00 2001 From: NikeNano Date: Sun, 8 Mar 2020 08:29:36 +0100 Subject: [PATCH 1/3] updated doc after feedback --- workflow/config/config.go | 1 + workflow/controller/controller.go | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/workflow/config/config.go b/workflow/config/config.go index f6424862d3a2..096ce297fb14 100644 --- a/workflow/config/config.go +++ b/workflow/config/config.go @@ -65,6 +65,7 @@ type WorkflowControllerConfig struct { // Config customized Docker Sock path DockerSockPath string `json:"dockerSockPath,omitempty"` + // Default workflow spec, will be adde to workflow if the parameters are not set in the workflow DefautWorkflowSpec *wfv1.WorkflowSpec `json:"workflowDefaults,omitempty"` } diff --git a/workflow/controller/controller.go b/workflow/controller/controller.go index a35b23fcc8ae..7cf09a6c58a3 100644 --- a/workflow/controller/controller.go +++ b/workflow/controller/controller.go @@ -431,7 +431,6 @@ func (wfc *WorkflowController) processNextItem() bool { // workflowController. Values in the workflow will be given the upper hand over the defaults. // The defaults for the workflow controller is set in the WorkflowController.Config.DefautWorkflowSpec func (wfc *WorkflowController) addingWorkflowDefaultValueIfValueNotExist(wf *wfv1.Workflow) error { - //var workflowSpec *wfv1.WorkflowSpec = &wf.Spec if wfc.Config.DefautWorkflowSpec != nil { defaultsSpec, err := json.Marshal(*wfc.Config.DefautWorkflowSpec) if err != nil { @@ -441,7 +440,7 @@ func (wfc *WorkflowController) addingWorkflowDefaultValueIfValueNotExist(wf *wfv if err != nil { return err } - // https://github.com/kubernetes/apimachinery/blob/2373d029717c4d169463414a6127cd1d0d12680e/pkg/util/strategicpatch/patch.go#L94 + https: //godoc.org/k8s.io/apimachinery/pkg/util/strategicpatch#StrategicMergePatch new, err := strategicpatch.StrategicMergePatch(defaultsSpec, workflowSpec, wfv1.WorkflowSpec{}) if err != nil { return err From 3709e63b81663fc5b6541d8a62133ce235b7f0e1 Mon Sep 17 00:00:00 2001 From: Simon Behar Date: Sun, 8 Mar 2020 09:34:11 -0700 Subject: [PATCH 2/3] Minor fix --- workflow/controller/controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow/controller/controller.go b/workflow/controller/controller.go index 7cf09a6c58a3..a7bf044bb43a 100644 --- a/workflow/controller/controller.go +++ b/workflow/controller/controller.go @@ -440,7 +440,7 @@ func (wfc *WorkflowController) addingWorkflowDefaultValueIfValueNotExist(wf *wfv if err != nil { return err } - https: //godoc.org/k8s.io/apimachinery/pkg/util/strategicpatch#StrategicMergePatch + // https: //godoc.org/k8s.io/apimachinery/pkg/util/strategicpatch#StrategicMergePatch new, err := strategicpatch.StrategicMergePatch(defaultsSpec, workflowSpec, wfv1.WorkflowSpec{}) if err != nil { return err From 4207a3042f847e31da1022518b2522d420575274 Mon Sep 17 00:00:00 2001 From: Simon Behar Date: Sun, 8 Mar 2020 09:38:20 -0700 Subject: [PATCH 3/3] Update workflow/controller/controller.go Co-Authored-By: Bot from GolangCI <42910462+golangcibot@users.noreply.github.com> --- workflow/controller/controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow/controller/controller.go b/workflow/controller/controller.go index a7bf044bb43a..c1576b5c7f7b 100644 --- a/workflow/controller/controller.go +++ b/workflow/controller/controller.go @@ -440,7 +440,7 @@ func (wfc *WorkflowController) addingWorkflowDefaultValueIfValueNotExist(wf *wfv if err != nil { return err } - // https: //godoc.org/k8s.io/apimachinery/pkg/util/strategicpatch#StrategicMergePatch + // https: //godoc.org/k8s.io/apimachinery/pkg/util/strategicpatch#StrategicMergePatch new, err := strategicpatch.StrategicMergePatch(defaultsSpec, workflowSpec, wfv1.WorkflowSpec{}) if err != nil { return err