vagrant-exec 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -2
- data/README.md +3 -1
- data/Rakefile +1 -1
- data/cucumber.yml +1 -0
- data/features/step_definitions/steps.rb +1 -1
- data/features/vagrant-exec.feature +9 -13
- data/features/vagrant-exec/directory.feature +0 -9
- data/features/vagrant-exec/environment_variables.feature +12 -9
- data/features/vagrant-exec/prepend.feature +12 -9
- data/features/vagrant-exec/validations.feature +0 -3
- data/lib/vagrant-exec/command.rb +13 -10
- data/lib/vagrant-exec/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2473ab163ba85fb8cc4d9e802771390a95d977f
|
4
|
+
data.tar.gz: 4af5e4619102413eaf5ef543f6f848cc991be591
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 886d5a874793ed7a27eadf7830095e12e21ac6f241c63c7ce77d51f476ddbc266e1dbcc0748ae6d680bc8477557ac40b62e286b52965bc831bda5c7710bfcafc
|
7
|
+
data.tar.gz: 40e06e6cdc5ed0c7a09d6ab93e35b8da76dc23ad6d6cfd6098ffaa64ef2c6108872f708d325c7c348dc25a87a07880587786bf0005b2245dda5faca37b2ed00b
|
data/Gemfile
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
|
-
gemspec
|
4
|
-
|
5
3
|
group :development do
|
6
4
|
# We depend on Vagrant for development, but we don't add it as a
|
7
5
|
# gem dependency because we expect to be installed within the
|
8
6
|
# Vagrant environment itself using `vagrant plugin`.
|
9
7
|
gem 'vagrant', git: 'git://github.com/mitchellh/vagrant.git'
|
10
8
|
end
|
9
|
+
|
10
|
+
group :plugins do
|
11
|
+
gemspec
|
12
|
+
end
|
data/README.md
CHANGED
@@ -59,7 +59,7 @@ Vagrant.configure('2') do |config|
|
|
59
59
|
# ➜ vagrant exec env
|
60
60
|
# # is the same as
|
61
61
|
# ➜ vagrant ssh -c "cd /etc && env"
|
62
|
-
config.exec.commands '
|
62
|
+
config.exec.commands 'env', directory: '/etc'
|
63
63
|
end
|
64
64
|
```
|
65
65
|
|
@@ -122,6 +122,8 @@ After you're done, remove Vagrant box.
|
|
122
122
|
➜ bundle exec rake features:cleanup
|
123
123
|
```
|
124
124
|
|
125
|
+
To show stduot, add `@announce-stdout` tag to scenario/feature.
|
126
|
+
|
125
127
|
Known issues
|
126
128
|
-----------------------------
|
127
129
|
|
data/Rakefile
CHANGED
data/cucumber.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
default: --require features --format html --out results.html --format pretty
|
@@ -3,6 +3,6 @@ Then(/^SHH subprocess should execute command "(.+)"$/) do |command|
|
|
3
3
|
ssh += %w(-o DSAAuthentication=yes -o LogLevel=FATAL)
|
4
4
|
ssh += %w(-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null)
|
5
5
|
ssh += %W(-o IdentitiesOnly=yes -i #{Dir.home}/.vagrant.d/insecure_private_key)
|
6
|
-
ssh += ['-q', '-t', "bash -l -c '#{command.delete('"
|
6
|
+
ssh += ['-q', '-t', "bash -l -c '#{command.delete("''")}'"]
|
7
7
|
assert_partial_output("Executing SSH in subprocess: #{ssh}", all_output)
|
8
8
|
end
|
@@ -8,16 +8,13 @@ Feature: vagrant-exec
|
|
8
8
|
Background:
|
9
9
|
Given I write to "Vagrantfile" with:
|
10
10
|
"""
|
11
|
-
$LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__)
|
12
|
-
require 'vagrant-exec'
|
13
|
-
|
14
11
|
Vagrant.configure('2') do |config|
|
15
12
|
config.vm.box = 'vagrant_exec'
|
16
13
|
end
|
17
14
|
"""
|
15
|
+
And I run `bundle exec vagrant up`
|
18
16
|
|
19
17
|
Scenario Outline: shows help correctly
|
20
|
-
Given I run `bundle exec vagrant up`
|
21
18
|
When I run `bundle exec vagrant exec <args>`
|
22
19
|
Then the output should contain "Usage: vagrant exec [options] <command>"
|
23
20
|
Examples:
|
@@ -29,13 +26,12 @@ Feature: vagrant-exec
|
|
29
26
|
| --help pwd -h |
|
30
27
|
|
31
28
|
Scenario Outline: passes command arguments correctly
|
32
|
-
|
33
|
-
|
34
|
-
Then SHH subprocess should execute command "cd /vagrant && <cmd>"
|
29
|
+
When I run `bundle exec vagrant exec <command>`
|
30
|
+
Then SHH subprocess should execute command "cd /vagrant && <command>"
|
35
31
|
Examples:
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
| command |
|
33
|
+
| pwd . |
|
34
|
+
| pwd ~ |
|
35
|
+
| pwd -h |
|
36
|
+
| pwd --blah |
|
37
|
+
| 'pwd -h blah -v blah' |
|
@@ -8,9 +8,6 @@ Feature: vagrant-exec directory
|
|
8
8
|
Scenario: uses /vagrant as default directory
|
9
9
|
Given I write to "Vagrantfile" with:
|
10
10
|
"""
|
11
|
-
$LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__)
|
12
|
-
require 'vagrant-exec'
|
13
|
-
|
14
11
|
Vagrant.configure('2') do |config|
|
15
12
|
config.vm.box = 'vagrant_exec'
|
16
13
|
end
|
@@ -23,9 +20,6 @@ Feature: vagrant-exec directory
|
|
23
20
|
Scenario: can use custom directory for all commands
|
24
21
|
Given I write to "Vagrantfile" with:
|
25
22
|
"""
|
26
|
-
$LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__)
|
27
|
-
require 'vagrant-exec'
|
28
|
-
|
29
23
|
Vagrant.configure('2') do |config|
|
30
24
|
config.vm.box = 'vagrant_exec'
|
31
25
|
config.exec.commands '*', directory: '/tmp'
|
@@ -39,9 +33,6 @@ Feature: vagrant-exec directory
|
|
39
33
|
Scenario: can use custom directory for specific commands
|
40
34
|
Given I write to "Vagrantfile" with:
|
41
35
|
"""
|
42
|
-
$LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__)
|
43
|
-
require 'vagrant-exec'
|
44
|
-
|
45
36
|
Vagrant.configure('2') do |config|
|
46
37
|
config.vm.box = 'vagrant_exec'
|
47
38
|
config.exec.commands %w(pwd echo), directory: '/tmp'
|
@@ -8,9 +8,6 @@ Feature: vagrant-exec environment variables
|
|
8
8
|
Scenario: can export environment variables for all commands
|
9
9
|
Given I write to "Vagrantfile" with:
|
10
10
|
"""
|
11
|
-
$LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__)
|
12
|
-
require 'vagrant-exec'
|
13
|
-
|
14
11
|
Vagrant.configure('2') do |config|
|
15
12
|
config.vm.box = 'vagrant_exec'
|
16
13
|
config.exec.commands '*', env: { 'TEST1' => true, 'TEST2' => false }
|
@@ -24,9 +21,6 @@ Feature: vagrant-exec environment variables
|
|
24
21
|
Scenario: can export environment variables for specific commands
|
25
22
|
Given I write to "Vagrantfile" with:
|
26
23
|
"""
|
27
|
-
$LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__)
|
28
|
-
require 'vagrant-exec'
|
29
|
-
|
30
24
|
Vagrant.configure('2') do |config|
|
31
25
|
config.vm.box = 'vagrant_exec'
|
32
26
|
config.exec.commands 'cmd', env: { 'TEST1' => 'yo' }
|
@@ -46,9 +40,6 @@ Feature: vagrant-exec environment variables
|
|
46
40
|
Scenario: can combine environment variables
|
47
41
|
Given I write to "Vagrantfile" with:
|
48
42
|
"""
|
49
|
-
$LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__)
|
50
|
-
require 'vagrant-exec'
|
51
|
-
|
52
43
|
Vagrant.configure('2') do |config|
|
53
44
|
config.vm.box = 'vagrant_exec'
|
54
45
|
config.exec.commands '*', env: { 'TEST1' => true }
|
@@ -63,3 +54,15 @@ Feature: vagrant-exec environment variables
|
|
63
54
|
Then SHH subprocess should execute command "cd /vagrant && export TEST1=true && export TEST3=false && echo 1"
|
64
55
|
When I run `bundle exec vagrant exec env`
|
65
56
|
Then SHH subprocess should execute command "cd /vagrant && export TEST1=true && env"
|
57
|
+
|
58
|
+
Scenario: wraps values with spaces to quotes
|
59
|
+
Given I write to "Vagrantfile" with:
|
60
|
+
"""
|
61
|
+
Vagrant.configure('2') do |config|
|
62
|
+
config.vm.box = 'vagrant_exec'
|
63
|
+
config.exec.commands 'pwd', env: { 'TEST' => 'one two' }
|
64
|
+
end
|
65
|
+
"""
|
66
|
+
And I run `bundle exec vagrant up`
|
67
|
+
When I run `bundle exec vagrant exec pwd`
|
68
|
+
Then SHH subprocess should execute command "cd /vagrant && export TEST="one two" && pwd"
|
@@ -8,9 +8,6 @@ Feature: vagrant-exec prepend
|
|
8
8
|
Scenario: can prepend all commands
|
9
9
|
Given I write to "Vagrantfile" with:
|
10
10
|
"""
|
11
|
-
$LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__)
|
12
|
-
require 'vagrant-exec'
|
13
|
-
|
14
11
|
Vagrant.configure('2') do |config|
|
15
12
|
config.vm.box = 'vagrant_exec'
|
16
13
|
config.exec.commands '*', prepend: 'echo vagrant-exec &&'
|
@@ -24,9 +21,6 @@ Feature: vagrant-exec prepend
|
|
24
21
|
Scenario: can prepend specific commands
|
25
22
|
Given I write to "Vagrantfile" with:
|
26
23
|
"""
|
27
|
-
$LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__)
|
28
|
-
require 'vagrant-exec'
|
29
|
-
|
30
24
|
Vagrant.configure('2') do |config|
|
31
25
|
config.vm.box = 'vagrant_exec'
|
32
26
|
config.exec.commands 'cmd', prepend: 'echo vagrant-exec1 &&'
|
@@ -46,9 +40,6 @@ Feature: vagrant-exec prepend
|
|
46
40
|
Scenario: can combine prepended
|
47
41
|
Given I write to "Vagrantfile" with:
|
48
42
|
"""
|
49
|
-
$LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__)
|
50
|
-
require 'vagrant-exec'
|
51
|
-
|
52
43
|
Vagrant.configure('2') do |config|
|
53
44
|
config.vm.box = 'vagrant_exec'
|
54
45
|
config.exec.commands '*', prepend: 'echo vagrant-exec1 &&'
|
@@ -64,3 +55,15 @@ Feature: vagrant-exec prepend
|
|
64
55
|
When I run `bundle exec vagrant exec env`
|
65
56
|
Then SHH subprocess should execute command "cd /vagrant && echo vagrant-exec1 && env"
|
66
57
|
|
58
|
+
Scenario: adds prepend only in the end
|
59
|
+
Given I write to "Vagrantfile" with:
|
60
|
+
"""
|
61
|
+
Vagrant.configure('2') do |config|
|
62
|
+
config.vm.box = 'vagrant_exec'
|
63
|
+
config.exec.commands 'pwd', prepend: 'bundle exec'
|
64
|
+
config.exec.commands 'pwd', env: { 'TEST' => true }
|
65
|
+
end
|
66
|
+
"""
|
67
|
+
And I run `bundle exec vagrant up`
|
68
|
+
When I run `bundle exec vagrant exec pwd`
|
69
|
+
Then SHH subprocess should execute command "cd /vagrant && export TEST=true && bundle exec pwd"
|
@@ -7,9 +7,6 @@ Feature: vagrant-exec validations
|
|
7
7
|
Background:
|
8
8
|
Given I write to "Vagrantfile" with:
|
9
9
|
"""
|
10
|
-
$LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__)
|
11
|
-
require 'vagrant-exec'
|
12
|
-
|
13
10
|
Vagrant.configure('2') do |config|
|
14
11
|
config.vm.box = 'vagrant_exec'
|
15
12
|
config.exec.commands true, directory: nil, prepend: true, env: 0
|
data/lib/vagrant-exec/command.rb
CHANGED
@@ -15,22 +15,24 @@ module VagrantPlugins
|
|
15
15
|
settings = vm.config.exec._parsed_commands
|
16
16
|
passed_command, constructed_command = cmd.dup, ''
|
17
17
|
|
18
|
-
# directory is applied only once
|
18
|
+
# directory is applied only once in the beginning
|
19
19
|
settings.reverse.each do |command|
|
20
|
-
|
21
|
-
|
22
|
-
if command_matches?(cmd, passed_command) && !directory_added?
|
23
|
-
constructed_command << add_directory(opts[:directory])
|
20
|
+
if command_matches?(command[:cmd], passed_command) && !directory_added?
|
21
|
+
constructed_command << add_directory(command[:opts][:directory])
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
27
|
-
# apply
|
25
|
+
# apply environment variables
|
28
26
|
settings.each do |command|
|
29
|
-
|
27
|
+
if command_matches?(command[:cmd], passed_command)
|
28
|
+
constructed_command << add_env(command[:opts][:env])
|
29
|
+
end
|
30
|
+
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
# apply prepend in the end
|
33
|
+
settings.each do |command|
|
34
|
+
if command_matches?(command[:cmd], passed_command)
|
35
|
+
constructed_command << add_prepend(command[:opts][:prepend])
|
34
36
|
end
|
35
37
|
end
|
36
38
|
|
@@ -86,6 +88,7 @@ module VagrantPlugins
|
|
86
88
|
def add_env(env)
|
87
89
|
''.tap do |str|
|
88
90
|
env.each do |key, value|
|
91
|
+
value = %("#{value}") if value.is_a?(String) && value.include?(' ')
|
89
92
|
str << "export #{key}=#{value} && "
|
90
93
|
end if env
|
91
94
|
end
|
data/lib/vagrant-exec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-exec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Rodionov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aruba
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- LICENSE.md
|
50
50
|
- README.md
|
51
51
|
- Rakefile
|
52
|
+
- cucumber.yml
|
52
53
|
- features/step_definitions/steps.rb
|
53
54
|
- features/support/env.rb
|
54
55
|
- features/vagrant-exec.feature
|