Skip to content

Commit

Permalink
Rename run_scripts to run_script for compatibility reasons
Browse files Browse the repository at this point in the history
The run_scripts agent action expects an array as the first argument.
Both the BOSH director and a set of stemcells have been released with
this action. Renaming the action makes backward and forward
compatibility work, because the director ignores 'unknown action' errors
from the agent when it calls the run_script[s] action. Without the
rename, deployments with mismatched agent and director versions would
fail with a marshalling error.

Signed-off-by: Jonathan Fuerth <[email protected]>
  • Loading branch information
pivotal-jamil-shamy authored and Jonathan Fuerth committed Aug 28, 2015
1 parent 12b931c commit ea1cdf5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
16 changes: 8 additions & 8 deletions agent/action/concrete_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ func NewFactory(
"update_settings": NewUpdateSettings(certManager, logger),

// Job management
"prepare": NewPrepare(applier),
"apply": NewApply(applier, specService, settingsService),
"start": NewStart(jobSupervisor),
"stop": NewStop(jobSupervisor),
"drain": NewDrain(notifier, specService, drainScriptProvider, jobSupervisor, logger),
"get_state": NewGetState(settingsService, specService, jobSupervisor, vitalsService, ntpService),
"run_errand": NewRunErrand(specService, dirProvider.JobsDir(), platform.GetRunner(), logger),
"run_scripts": NewRunScript(jobScriptProvider, specService, logger),
"prepare": NewPrepare(applier),
"apply": NewApply(applier, specService, settingsService),
"start": NewStart(jobSupervisor),
"stop": NewStop(jobSupervisor),
"drain": NewDrain(notifier, specService, drainScriptProvider, jobSupervisor, logger),
"get_state": NewGetState(settingsService, specService, jobSupervisor, vitalsService, ntpService),
"run_errand": NewRunErrand(specService, dirProvider.JobsDir(), platform.GetRunner(), logger),
"run_script": NewRunScript(jobScriptProvider, specService, logger),

// Compilation
"compile_package": NewCompilePackage(compiler),
Expand Down
2 changes: 1 addition & 1 deletion agentclient/agent_client_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type AgentClient interface {
MigrateDisk() error
CompilePackage(packageSource BlobRef, compiledPackageDependencies []BlobRef) (compiledPackageRef BlobRef, err error)
UpdateSettings(settings settings.Settings) error
RunScript(scriptPaths []string, options map[string]interface{}) error
RunScript(scriptName string, options map[string]interface{}) error
}

type AgentState struct {
Expand Down
2 changes: 1 addition & 1 deletion agentclient/fakes/fake_agent_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (c *FakeAgentClient) UpdateSettings(settings settings.Settings) error {
return c.updateSettingsErr
}

func (c *FakeAgentClient) RunScript(scriptPaths []string, options map[string]interface{}) error {
func (c *FakeAgentClient) RunScript(scriptName string, options map[string]interface{}) error {
c.RunScriptCalledTimes++
return c.runScriptErr
}
Expand Down
4 changes: 2 additions & 2 deletions agentclient/http/agent_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ func (c *agentClient) UpdateSettings(settings settings.Settings) error {
return err
}

func (c *agentClient) RunScript(scriptPaths []string, options map[string]interface{}) error {
_, err := c.sendAsyncTaskMessage("run_script", []interface{}{scriptPaths, options})
func (c *agentClient) RunScript(scriptName string, options map[string]interface{}) error {
_, err := c.sendAsyncTaskMessage("run_script", []interface{}{scriptName, options})
return err
}

Expand Down
10 changes: 10 additions & 0 deletions agentclient/mocks/mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,13 @@ func (_m *MockAgentClient) UpdateSettings(settings settings.Settings) error {
func (_mr *_MockAgentClientRecorder) UpdateSettings(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "UpdateSettings", arg0)
}

func (_m *MockAgentClient) RunScript(scriptName string, options map[string]interface{}) error {
ret := _m.ctrl.Call(_m, "RunScript", scriptName, options)
ret0, _ := ret[0].(error)
return ret0
}

func (_mr *_MockAgentClientRecorder) RunScript(arg0, arg1 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "RunScript", arg0, arg1)
}

0 comments on commit ea1cdf5

Please sign in to comment.