vagrant-google 1.0.0 → 2.0.0.rc0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.rubocop.yml +6 -0
- data/.rubocop_todo.yml +140 -95
- data/CHANGELOG.md +18 -0
- data/README.md +20 -18
- data/example_boxes/gce-test/Vagrantfile +1 -0
- data/google-test.box +0 -0
- data/google.box +0 -0
- data/lib/vagrant-google/action.rb +3 -4
- data/lib/vagrant-google/action/assign_instance_groups.rb +14 -10
- data/lib/vagrant-google/action/connect_google.rb +11 -5
- data/lib/vagrant-google/action/read_ssh_info.rb +2 -2
- data/lib/vagrant-google/action/read_state.rb +2 -2
- data/lib/vagrant-google/action/run_instance.rb +56 -22
- data/lib/vagrant-google/action/stop_instance.rb +0 -2
- data/lib/vagrant-google/action/terminate_instance.rb +2 -0
- data/lib/vagrant-google/config.rb +28 -24
- data/lib/vagrant-google/provider.rb +5 -0
- data/lib/vagrant-google/version.rb +1 -1
- data/locales/en.yml +3 -6
- data/tasks/acceptance.rake +8 -4
- data/test/acceptance/skeletons/generic/Vagrantfile +5 -4
- data/test/acceptance/skeletons/instance_groups/Vagrantfile +6 -5
- data/test/acceptance/skeletons/multi_instance/Vagrantfile +6 -4
- data/test/acceptance/skeletons/preemptible/Vagrantfile +8 -7
- data/test/acceptance/skeletons/scopes/Vagrantfile +6 -5
- data/test/unit/base.rb +3 -1
- data/test/unit/common/config_test.rb +28 -36
- data/vagrant-google.gemspec +11 -10
- data/vagrant-spec.config.rb +1 -1
- data/vagrantfile_examples/Vagrantfile.simple +2 -0
- metadata +59 -32
- data/lib/vagrant-google/action/sync_folders.rb +0 -106
@@ -1,106 +0,0 @@
|
|
1
|
-
# Copyright 2013 Google Inc. All Rights Reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
require "log4r"
|
15
|
-
require "vagrant/util/subprocess"
|
16
|
-
require "vagrant/util/scoped_hash_override"
|
17
|
-
require "vagrant/util/which"
|
18
|
-
|
19
|
-
module VagrantPlugins
|
20
|
-
module Google
|
21
|
-
module Action
|
22
|
-
# This middleware uses `rsync` to sync the folders over to the
|
23
|
-
# Google instance.
|
24
|
-
class SyncFolders
|
25
|
-
include Vagrant::Util::ScopedHashOverride
|
26
|
-
|
27
|
-
def initialize(app, env)
|
28
|
-
@app = app
|
29
|
-
@logger = Log4r::Logger.new("vagrant_google::action::sync_folders")
|
30
|
-
end
|
31
|
-
|
32
|
-
def call(env) # rubocop:disable Metrics/MethodLength
|
33
|
-
@app.call(env)
|
34
|
-
|
35
|
-
ssh_info = env[:machine].ssh_info
|
36
|
-
|
37
|
-
env[:machine].config.vm.synced_folders.each do |id, data|
|
38
|
-
data = scoped_hash_override(data, :google)
|
39
|
-
|
40
|
-
# Ignore disabled shared folders
|
41
|
-
next if data[:disabled]
|
42
|
-
|
43
|
-
unless Vagrant::Util::Which.which('rsync')
|
44
|
-
env[:ui].warn(I18n.t('vagrant_google.rsync_not_found_warning'))
|
45
|
-
break
|
46
|
-
end
|
47
|
-
|
48
|
-
hostpath = File.expand_path(data[:hostpath], env[:root_path])
|
49
|
-
guestpath = data[:guestpath]
|
50
|
-
|
51
|
-
# Make sure there is a trailing slash on the host path to
|
52
|
-
# avoid creating an additional directory with rsync
|
53
|
-
hostpath = "#{hostpath}/" if hostpath !~ /\/$/
|
54
|
-
|
55
|
-
# on windows rsync.exe requires cygdrive-style paths
|
56
|
-
if Vagrant::Util::Platform.windows?
|
57
|
-
hostpath = hostpath.gsub(/^(\w):/) { "/cygdrive/#{$1}" }
|
58
|
-
end
|
59
|
-
|
60
|
-
env[:ui].info(I18n.t("vagrant_google.rsync_folder",
|
61
|
-
:hostpath => hostpath,
|
62
|
-
:guestpath => guestpath))
|
63
|
-
|
64
|
-
# Create the guest path
|
65
|
-
env[:machine].communicate.sudo("mkdir -p '#{guestpath}'")
|
66
|
-
env[:machine].communicate.sudo(
|
67
|
-
"chown #{ssh_info[:username]} '#{guestpath}'"
|
68
|
-
)
|
69
|
-
|
70
|
-
# patch from https://github.com/tmatilai/vagrant-aws/commit/4a043a96076c332220ec4ec19470c4af5597dd51
|
71
|
-
def ssh_key_options(ssh_info)
|
72
|
-
# Ensure that `private_key_path` is an Array (for Vagrant < 1.4)
|
73
|
-
Array(ssh_info[:private_key_path]).map { |path| "-i '#{path}' " }.join
|
74
|
-
end
|
75
|
-
|
76
|
-
#collect rsync excludes specified :rsync__excludes=>['path1',...] in synced_folder options
|
77
|
-
excludes = ['.vagrant/', *Array(data[:rsync__excludes])]
|
78
|
-
|
79
|
-
# Rsync over to the guest path using the SSH info
|
80
|
-
command = [
|
81
|
-
"rsync", "--verbose", "--archive", "-z",
|
82
|
-
*excludes.map{|e| ['--exclude', e]}.flatten,
|
83
|
-
"-e", "ssh -p #{ssh_info[:port]} -o StrictHostKeyChecking=no #{ssh_key_options(ssh_info)}",
|
84
|
-
hostpath,
|
85
|
-
"#{ssh_info[:username]}@#{ssh_info[:host]}:#{guestpath}"
|
86
|
-
]
|
87
|
-
|
88
|
-
# we need to fix permissions when using rsync.exe on windows, see
|
89
|
-
# http://stackoverflow.com/questions/5798807/rsync-permission-denied-created-directories-have-no-permissions
|
90
|
-
if Vagrant::Util::Platform.windows?
|
91
|
-
command.insert(1, "--chmod", "ugo=rwX")
|
92
|
-
end
|
93
|
-
|
94
|
-
r = Vagrant::Util::Subprocess.execute(*command)
|
95
|
-
if r.exit_code.nonzero?
|
96
|
-
raise Errors::RsyncError,
|
97
|
-
:guestpath => guestpath,
|
98
|
-
:hostpath => hostpath,
|
99
|
-
:stderr => r.stderr
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|