Add middleware to run after create script on vagrant up
This commit is contained in:
parent
22e5a48af5
commit
a8cf5deee2
1 changed files with 13 additions and 2 deletions
|
@ -78,6 +78,7 @@ module Vagrant
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
b.use action_start
|
b.use action_start
|
||||||
|
b.use AfterCreate
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -157,6 +158,16 @@ module Vagrant
|
||||||
def call(env)
|
def call(env)
|
||||||
machine_id = env[:machine].provider.container.create(env[:machine].box.metadata)
|
machine_id = env[:machine].provider.container.create(env[:machine].box.metadata)
|
||||||
env[:machine].id = machine_id
|
env[:machine].id = machine_id
|
||||||
|
env[:just_created] = true
|
||||||
|
@app.call env
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class AfterCreate < BaseAction
|
||||||
|
def call(env)
|
||||||
|
if env[:just_created] && (script = env[:machine].box.metadata['after-create-script'])
|
||||||
|
env[:machine].provider.container.run_after_create_script script
|
||||||
|
end
|
||||||
@app.call env
|
@app.call env
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue