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:
parent
e77bd9b841
commit
73dd8c7d78
@ -89,7 +89,7 @@ func (f *Flamenco) SubmitJob(e echo.Context) error {
|
|||||||
|
|
||||||
// Before compiling the job, replace the two-way variables. This ensures all
|
// Before compiling the job, replace the two-way variables. This ensures all
|
||||||
// the tasks also use those.
|
// the tasks also use those.
|
||||||
replaceTwoWayVariables(f.config, submittedJob)
|
replaceTwoWayVariables(f.config, &submittedJob)
|
||||||
|
|
||||||
authoredJob, err := f.jobCompiler.Compile(ctx, submittedJob)
|
authoredJob, err := f.jobCompiler.Compile(ctx, submittedJob)
|
||||||
switch {
|
switch {
|
||||||
|
@ -77,7 +77,7 @@ func replaceTaskVariables(replacer VariableReplacer, task api.AssignedTask, work
|
|||||||
// `{render}/output.png`
|
// `{render}/output.png`
|
||||||
//
|
//
|
||||||
// NOTE: this updates the job in place.
|
// 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)
|
feeder := make(chan string, 1)
|
||||||
receiver := make(chan string, 1)
|
receiver := make(chan string, 1)
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ func TestReplaceTwoWayVariables(t *testing.T) {
|
|||||||
replaced := varReplSubmittedJob()
|
replaced := varReplSubmittedJob()
|
||||||
replaced.Settings = nil
|
replaced.Settings = nil
|
||||||
replaced.Metadata = 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.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")
|
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()
|
original := varReplSubmittedJob()
|
||||||
replaced := jsonWash(varReplSubmittedJob())
|
replaced := jsonWash(varReplSubmittedJob())
|
||||||
replaceTwoWayVariables(&c, replaced)
|
replaceTwoWayVariables(&c, &replaced)
|
||||||
|
|
||||||
expectSettings := map[string]interface{}{
|
expectSettings := map[string]interface{}{
|
||||||
"blender_cmd": "{blender}",
|
"blender_cmd": "{blender}",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user