Cleanup: pass submittedJob as pointer to two-way variable replacer

The two-way variable replacement function changes the submitted job. To
clarify that this happens, pass the pointer `&submittedJob`.

Both pass-by-pointer and pass-by-value work, because the variable
replacement typically works on maps/slices, which are passed by reference
anyway. Better to be explicit about this, though.

No functional changes.
This commit is contained in:
Sybren A. Stüvel 2022-10-20 12:55:01 +02:00
parent e77bd9b841
commit 73dd8c7d78
3 changed files with 4 additions and 4 deletions

View File

@ -89,7 +89,7 @@ func (f *Flamenco) SubmitJob(e echo.Context) error {
// Before compiling the job, replace the two-way variables. This ensures all
// the tasks also use those.
replaceTwoWayVariables(f.config, submittedJob)
replaceTwoWayVariables(f.config, &submittedJob)
authoredJob, err := f.jobCompiler.Compile(ctx, submittedJob)
switch {

View File

@ -77,7 +77,7 @@ func replaceTaskVariables(replacer VariableReplacer, task api.AssignedTask, work
// `{render}/output.png`
//
// NOTE: this updates the job in place.
func replaceTwoWayVariables(replacer VariableReplacer, job api.SubmittedJob) {
func replaceTwoWayVariables(replacer VariableReplacer, job *api.SubmittedJob) {
feeder := make(chan string, 1)
receiver := make(chan string, 1)

View File

@ -197,7 +197,7 @@ func TestReplaceTwoWayVariables(t *testing.T) {
replaced := varReplSubmittedJob()
replaced.Settings = nil
replaced.Metadata = nil
replaceTwoWayVariables(&c, replaced)
replaceTwoWayVariables(&c, &replaced)
assert.Equal(t, original.Type, replaced.Type, "two-way variable replacement shouldn't happen on the Type property")
assert.Equal(t, original.Name, replaced.Name, "two-way variable replacement shouldn't happen on the Name property")
@ -211,7 +211,7 @@ func TestReplaceTwoWayVariables(t *testing.T) {
{
original := varReplSubmittedJob()
replaced := jsonWash(varReplSubmittedJob())
replaceTwoWayVariables(&c, replaced)
replaceTwoWayVariables(&c, &replaced)
expectSettings := map[string]interface{}{
"blender_cmd": "{blender}",