opswalrus 1.0.10 → 1.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 472ae5aafb306653a32149c08a481288237c6c524a3f72761e09ac9887a4c0f4
4
- data.tar.gz: 449e723590784e10faf30bbbebb122d0ae00c6652e02559decc0cbbac0ba670f
3
+ metadata.gz: d9c838dbf7a64b90664fa94e0b6579508e0967d20a2fa8d8779616fa36cf9b8f
4
+ data.tar.gz: 9787c55859ab6ed5f5ceb50803c72df06f9d021e25dcbe7dc917db4f2f30b2ab
5
5
  SHA512:
6
- metadata.gz: 319c28870d5b1e91680e9aed29834df12c25dae3bbc6abeb0d54566f7d6a7662064dc8d54f7851d9d9ce7dc82d48c73a019abe58b384281e8b7c98ec5d252d99
7
- data.tar.gz: 3e4a3d90ef1f30f29f4acb0acc8a34422e4f6f687f42fef3cba890e052b1d07848f38276b88d5c95f91be3d3e966c5b4a1e3f5c8e1faa8d31b1342dd8364c64e
6
+ metadata.gz: 644d62c00d36280d5be184f8408c0fc8d5da05d02bae7207b6899d819c98c3f6456be34bb50db1ebfd4012419e6710e193d278c6065bdf2a5b5cc6025b291606
7
+ data.tar.gz: a0a2f5663a4bc748feba02bf4609de61347a8ef5519420ba578dfade18c5fdb877f9aada5332bc705c3714db3284b0e137844fa43a56718c3a99d23ceda8b613
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- opswalrus (1.0.10)
4
+ opswalrus (1.0.12)
5
5
  bcrypt_pbkdf (~> 1.1)
6
6
  citrus (~> 3.0)
7
7
  ed25519 (~> 1.3)
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]
@@ -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.dirname)
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
- case
116
- when package_url =~ /\.git/ # git reference
117
- download_git_package(package_url, version, destination_package_path)
118
- when package_url.start_with?("file://") # local path
119
- path = package_url.sub("file://", "")
120
- path = path.to_pathname
121
- package_path_to_download = if path.relative? # relative path
122
- package_file.containing_directory.join(path)
123
- else # absolute path
124
- path.realpath
125
- end
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
- raise Error, "Package not found: #{package_path_to_download}" unless package_path_to_download.exist?
128
- FileUtils.cp_r(package_path_to_download, destination_package_path)
129
- when package_url.to_pathname.exist? || package_file.containing_directory.join(package_url).exist? # local path
130
- path = package_url.to_pathname
131
- package_path_to_download = if path.relative? # relative path
132
- package_file.containing_directory.join(path)
133
- else # absolute path
134
- path.realpath
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
- raise Error, "Package not found: #{package_path_to_download}" unless File.exist?(package_path_to_download)
138
- FileUtils.cp_r(package_path_to_download, destination_package_path)
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)
@@ -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 = "--json"
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(command, command_arguments, in_bundle_root_dir: true, verbose: false)
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 << " #{command.to_s}"
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
- 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
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
@@ -1,3 +1,3 @@
1
1
  module OpsWalrus
2
- VERSION = "1.0.10"
2
+ VERSION = "1.0.12"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opswalrus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Ellis