mirror of
https://github.com/hashicorp/vagrant.git
synced 2026-02-05 06:46:21 +01:00
Merge pull request #11965 from soapy1/cap-target
Add ability to specify target for cap command
This commit is contained in:
@@ -27,6 +27,10 @@ module VagrantPlugins
|
||||
o.on("--check", "Only checks for a capability, does not execute") do |f|
|
||||
options[:check] = f
|
||||
end
|
||||
|
||||
o.on("-t", "--target=TARGET", "Target guest to run against (if applicable)") do |t|
|
||||
options[:target] = t
|
||||
end
|
||||
end
|
||||
|
||||
# Parse the options
|
||||
@@ -45,7 +49,7 @@ module VagrantPlugins
|
||||
if type == :host
|
||||
cap_host = @env.host
|
||||
else
|
||||
with_target_vms([]) do |vm|
|
||||
with_target_vms(options[:target] || []) do |vm|
|
||||
cap_host = case type
|
||||
when :provider
|
||||
vm.provider
|
||||
|
||||
@@ -47,5 +47,26 @@ describe VagrantPlugins::CommandCap::Command do
|
||||
expect(subject.execute).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
context "runs against target vm" do
|
||||
let(:argv) { ["provider", "foo", "--target=dummy"] }
|
||||
let(:cap) {
|
||||
Class.new do
|
||||
def self.foo(m)
|
||||
true
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
before do
|
||||
register_plugin do |p|
|
||||
p.provider_capability(:dummy, :foo) { cap }
|
||||
end
|
||||
end
|
||||
|
||||
it "exits with 0 if it exists" do
|
||||
expect(subject.execute).to eq(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user