opswalrus 1.0.11 → 1.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/opswalrus/app.rb +0 -19
- data/lib/opswalrus/bundler.rb +61 -25
- data/lib/opswalrus/host.rb +6 -7
- data/lib/opswalrus/ops_file_script_dsl.rb +5 -5
- data/lib/opswalrus/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9c838dbf7a64b90664fa94e0b6579508e0967d20a2fa8d8779616fa36cf9b8f
|
4
|
+
data.tar.gz: 9787c55859ab6ed5f5ceb50803c72df06f9d021e25dcbe7dc917db4f2f30b2ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 644d62c00d36280d5be184f8408c0fc8d5da05d02bae7207b6899d819c98c3f6456be34bb50db1ebfd4012419e6710e193d278c6065bdf2a5b5cc6025b291606
|
7
|
+
data.tar.gz: a0a2f5663a4bc748feba02bf4609de61347a8ef5519420ba578dfade18c5fdb877f9aada5332bc705c3714db3284b0e137844fa43a56718c3a99d23ceda8b613
|
data/Gemfile.lock
CHANGED
data/lib/opswalrus/app.rb
CHANGED
@@ -239,25 +239,6 @@ module OpsWalrus
|
|
239
239
|
|
240
240
|
ops_file_path, operation_kv_args = find_entry_point_ops_file_in_dir(destination_package_path, package_operation_and_args)
|
241
241
|
|
242
|
-
# ops_file_path = nil
|
243
|
-
# base_path = Pathname.new(destination_package_path)
|
244
|
-
# path_parts = 0
|
245
|
-
# package_operation_and_args.each do |candidate_path_arg|
|
246
|
-
# candidate_base_path = base_path.join(candidate_path_arg)
|
247
|
-
# candidate_ops_file = candidate_base_path.sub_ext(".ops")
|
248
|
-
# if candidate_ops_file.exist?
|
249
|
-
# path_parts += 1
|
250
|
-
# ops_file_path = candidate_ops_file
|
251
|
-
# break
|
252
|
-
# elsif candidate_base_path.exist?
|
253
|
-
# path_parts += 1
|
254
|
-
# else
|
255
|
-
# raise Error, "Operation not found in #{repo_url}: #{candidate_base_path}"
|
256
|
-
# end
|
257
|
-
# base_path = candidate_base_path
|
258
|
-
# end
|
259
|
-
# operation_kv_args = package_operation_and_args.drop(path_parts)
|
260
|
-
|
261
242
|
# for an original package_operation_and_args of ["github.com/davidkellis/my-package", "operation1", "arg1:val1", "arg2:val2", "arg3:val3"]
|
262
243
|
# we return: [ "#{pwd}/#{Bundler::BUNDLE_DIR}/github-com-davidkellis-my-package/operation1.ops", ["arg1:val1", "arg2:val2", "arg3:val3"] ]
|
263
244
|
[ops_file_path, operation_kv_args, tmp_dir]
|
data/lib/opswalrus/bundler.rb
CHANGED
@@ -109,38 +109,74 @@ module OpsWalrus
|
|
109
109
|
package_url = package_reference.package_uri
|
110
110
|
version = package_reference.version
|
111
111
|
|
112
|
-
destination_package_path = @bundle_dir.join(package_reference.
|
112
|
+
destination_package_path = @bundle_dir.join(package_reference.import_resolution_dirname)
|
113
113
|
FileUtils.remove_dir(destination_package_path) if destination_package_path.exist?
|
114
114
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
115
|
+
download_package_contents(package_file, local_name, package_url, version, destination_package_path)
|
116
|
+
# case
|
117
|
+
# when package_url =~ /\.git/ # git reference
|
118
|
+
# download_git_package(package_url, version, destination_package_path)
|
119
|
+
# when package_url.start_with?("file://") # local path
|
120
|
+
# path = package_url.sub("file://", "")
|
121
|
+
# path = path.to_pathname
|
122
|
+
# package_path_to_download = if path.relative? # relative path
|
123
|
+
# package_file.containing_directory.join(path)
|
124
|
+
# else # absolute path
|
125
|
+
# path.realpath
|
126
|
+
# end
|
127
|
+
|
128
|
+
# raise Error, "Package not found: #{package_path_to_download}" unless package_path_to_download.exist?
|
129
|
+
# FileUtils.cp_r(package_path_to_download, destination_package_path)
|
130
|
+
# when package_url.to_pathname.exist? || package_file.containing_directory.join(package_url).exist? # local path
|
131
|
+
# path = package_url.to_pathname
|
132
|
+
# package_path_to_download = if path.relative? # relative path
|
133
|
+
# package_file.containing_directory.join(path)
|
134
|
+
# else # absolute path
|
135
|
+
# path.realpath
|
136
|
+
# end
|
137
|
+
|
138
|
+
# raise Error, "Package not found: #{package_path_to_download}" unless File.exist?(package_path_to_download)
|
139
|
+
# FileUtils.cp_r(package_path_to_download, destination_package_path)
|
140
|
+
# else # git reference
|
141
|
+
# download_git_package(package_url, version, destination_package_path)
|
142
|
+
# end
|
143
|
+
|
144
|
+
destination_package_path
|
145
|
+
end
|
126
146
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
147
|
+
def download_package_contents(package_file, local_name, package_url, version, destination_package_path)
|
148
|
+
package_path = package_url.to_pathname
|
149
|
+
package_path = package_path.to_s.gsub(/^~/, Dir.home).to_pathname
|
150
|
+
if package_path.absolute? && package_path.exist? # absolute path reference
|
151
|
+
return case
|
152
|
+
when package_path.directory?
|
153
|
+
package_path_to_download = package_path.realpath
|
154
|
+
FileUtils.cp_r(package_path_to_download, destination_package_path)
|
155
|
+
when package_path.file?
|
156
|
+
raise Error, "Package reference must be a directory, not a file:: #{local_name}: #{package_path}"
|
157
|
+
else
|
158
|
+
raise Error, "Unknown package reference for absolute path: #{local_name}: #{package_path}"
|
135
159
|
end
|
160
|
+
end
|
161
|
+
if package_path.relative? # relative path reference
|
162
|
+
rebased_path = package_file.containing_directory.join(package_path)
|
163
|
+
if rebased_path.exist?
|
164
|
+
return case
|
165
|
+
when rebased_path.directory?
|
166
|
+
package_path_to_download = rebased_path.realpath
|
167
|
+
FileUtils.cp_r(package_path_to_download, destination_package_path)
|
168
|
+
when rebased_path.file?
|
169
|
+
raise Error, "Package reference must be a directory, not a file:: #{local_name}: #{package_path}"
|
170
|
+
else
|
171
|
+
raise Error, "Unknown package reference for relative path: #{local_name}: #{package_path}"
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
136
175
|
|
137
|
-
|
138
|
-
|
139
|
-
else # git reference
|
176
|
+
package_uri = package_url
|
177
|
+
if Git.repo?(package_uri) # git repo
|
140
178
|
download_git_package(package_url, version, destination_package_path)
|
141
179
|
end
|
142
|
-
|
143
|
-
destination_package_path
|
144
180
|
end
|
145
181
|
|
146
182
|
def download_git_package(package_url, version = nil, destination_package_path = nil)
|
data/lib/opswalrus/host.rb
CHANGED
@@ -22,10 +22,7 @@ module OpsWalrus
|
|
22
22
|
# so we want to build up a command and send it to the remote host via HostDSL#run_ops
|
23
23
|
@method_chain.unshift(Bundler::BUNDLE_DIR) if @is_invocation_a_call_to_package_in_bundle_dir
|
24
24
|
|
25
|
-
remote_run_command_args = "
|
26
|
-
|
27
|
-
remote_run_command_args << " "
|
28
|
-
remote_run_command_args << @method_chain.join(" ")
|
25
|
+
remote_run_command_args = @method_chain.join(" ")
|
29
26
|
|
30
27
|
unless args.empty?
|
31
28
|
remote_run_command_args << " "
|
@@ -44,7 +41,7 @@ module OpsWalrus
|
|
44
41
|
end.join(" ")
|
45
42
|
end
|
46
43
|
|
47
|
-
@host_proxy.run_ops(:run, remote_run_command_args)
|
44
|
+
@host_proxy.run_ops(:run, "--script", remote_run_command_args)
|
48
45
|
end
|
49
46
|
end
|
50
47
|
end
|
@@ -164,13 +161,15 @@ module OpsWalrus
|
|
164
161
|
# end
|
165
162
|
|
166
163
|
# runs the specified ops command with the specified command arguments
|
167
|
-
def run_ops(
|
164
|
+
def run_ops(ops_command, ops_command_options = nil, command_arguments, in_bundle_root_dir: true, verbose: false)
|
168
165
|
# e.g. /home/linuxbrew/.linuxbrew/bin/gem exec -g opswalrus ops bundle unzip tmpops.zip
|
169
166
|
# e.g. /home/linuxbrew/.linuxbrew/bin/gem exec -g opswalrus ops run echo.ops args:foo args:bar
|
170
167
|
|
168
|
+
# cmd = "/home/linuxbrew/.linuxbrew/bin/gem exec -g opswalrus ops"
|
171
169
|
cmd = "/home/linuxbrew/.linuxbrew/bin/gem exec -g opswalrus ops"
|
172
170
|
cmd << " -v" if verbose
|
173
|
-
cmd << " #{
|
171
|
+
cmd << " #{ops_command.to_s}"
|
172
|
+
cmd << " #{ops_command_options.to_s}" if ops_command_options
|
174
173
|
cmd << " #{@tmp_bundle_root_dir}" if in_bundle_root_dir
|
175
174
|
cmd << " #{command_arguments}" unless command_arguments.empty?
|
176
175
|
|
@@ -157,11 +157,11 @@ module OpsWalrus
|
|
157
157
|
# puts retval.inspect
|
158
158
|
|
159
159
|
# cleanup
|
160
|
-
if tmp_bundle_root_dir =~ /tmp/ # sanity check the temp path before we blow away something we don't intend
|
161
|
-
|
162
|
-
else
|
163
|
-
|
164
|
-
end
|
160
|
+
# if tmp_bundle_root_dir =~ /tmp/ # sanity check the temp path before we blow away something we don't intend
|
161
|
+
# host.execute(:rm, "-rf", "tmpopsbootstrap.sh", "tmpops.zip", tmp_bundle_root_dir)
|
162
|
+
# else
|
163
|
+
# host.execute(:rm, "-rf", "tmpopsbootstrap.sh", "tmpops.zip")
|
164
|
+
# end
|
165
165
|
|
166
166
|
retval
|
167
167
|
rescue SSHKit::Command::Failed => e
|
data/lib/opswalrus/version.rb
CHANGED