opswalrus 1.0.3 → 1.0.4

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: b31832ac2c06fb96c6abac86dacccce0f4fa280d679f2f12573eb37044d49b93
4
- data.tar.gz: dc69618f8f83b0845f5e93a8e4699bcade24e37a3ce24fcecc49a427f2b471ff
3
+ metadata.gz: fa4d06b1bc87888397e4509eda913a1a5ad0cf4f069762852282de9c1cd7c6a0
4
+ data.tar.gz: 605d4b7e09d3fe47b2fa5106d5cd27e8255ba5265dff1bcfe8fbda3fb380195d
5
5
  SHA512:
6
- metadata.gz: c107c7165daa8536b4831c7f84d34c662dcc86cad1da29334412460e2995adad5bb076f14ae48b90578e2c349ea55411e4f2794371d417e714bffb093dca4f3b
7
- data.tar.gz: d6e0983ef2d59ed545370dd670753436026244b0cc5c84dadb3745b188931839f5edd57425f65fa4a607324b4d1e17bd4e0431bb5bb2cbb825e8a95e1f9eca6c
6
+ metadata.gz: cce83e3128b0d19d7ccec3d0fe85411d19959229fc8cd3ad9fdf47b40c739e598f3dd2020078492361df9d309b15e0c82824901ff2511b434adea09c9484d246
7
+ data.tar.gz: 7bc58a62f322c543e2aa57b5a75611d4984c3b72454c4ac52fbd91bfa074efde217fa8355bfc38718d13b0ac839fbe13c8c567307e0c1516e3067cea351f4594
data/lib/opswalrus/app.rb CHANGED
@@ -64,6 +64,14 @@ module OpsWalrus
64
64
  "" # return empty string because we won't want anyone accidentally printing or inspecting @sudo_password
65
65
  end
66
66
 
67
+ def emit_json_output!
68
+ @emit_json_output = true
69
+ end
70
+
71
+ def emit_json_output?
72
+ @emit_json_output
73
+ end
74
+
67
75
  def set_local_hostname(hostname)
68
76
  hostname = hostname.strip
69
77
  @local_hostname = hostname.empty? ? "localhost" : hostname
@@ -186,6 +194,10 @@ module OpsWalrus
186
194
  puts JSON.pretty_generate(result.value)
187
195
  end
188
196
 
197
+ if emit_json_output?
198
+ puts JSON.pretty_generate(result.value)
199
+ end
200
+
189
201
  exit_status
190
202
  ensure
191
203
  FileUtils.remove_entry(tmp_dir) if tmp_dir
data/lib/opswalrus/cli.rb CHANGED
@@ -53,6 +53,7 @@ module OpsWalrus
53
53
  c.flag [:u, :user], desc: "Specify the user that the operation will run as"
54
54
  c.switch :pass, desc: "Prompt for a sudo password"
55
55
  c.flag [:p, :params], desc: "JSON string that represents the input parameters for the operation. The JSON string must conform to the params schema for the operation."
56
+ c.switch :json, desc: "Emit JSON output"
56
57
 
57
58
  c.action do |global_options, options, args|
58
59
  hosts = global_options[:hosts] || []
@@ -80,6 +81,10 @@ module OpsWalrus
80
81
  $app.prompt_sudo_password
81
82
  end
82
83
 
84
+ if options[:json]
85
+ $app.emit_json_output!
86
+ end
87
+
83
88
  # puts "verbose"
84
89
  # puts verbose.inspect
85
90
  # puts "user"
@@ -86,19 +86,26 @@ module OpsWalrus
86
86
  # so we want to build up a command and send it to the remote host via HostDSL#run_ops
87
87
  @method_chain.unshift(Bundler::BUNDLE_DIR) if @is_invocation_a_call_to_package_in_bundle_dir
88
88
 
89
- # path_to_ops_file_basename = @method_chain.join(File::Separator)
90
- # remote_run_command_args << path_to_ops_file_basename
89
+ remote_run_command_args = "--json"
91
90
 
92
- remote_run_command_args = @method_chain.join(" ")
91
+ remote_run_command_args << " "
92
+ remote_run_command_args << @method_chain.join(" ")
93
93
 
94
94
  unless args.empty?
95
95
  remote_run_command_args << " "
96
96
  remote_run_command_args << args.join(" ")
97
97
  end
98
98
 
99
- unless kvargs.empty?
99
+ unless kwargs.empty?
100
100
  remote_run_command_args << " "
101
- remote_run_command_args << kvargs.map{|k,v| "#{k}=#{v}" }.join(" ") unless kvargs.empty?
101
+ remote_run_command_args << kwargs.map do |k, v|
102
+ case v
103
+ when Array
104
+ v.map {|v_element| "#{k}:#{v_element}" }
105
+ else
106
+ "#{k}:#{v}"
107
+ end
108
+ end.join(" ")
102
109
  end
103
110
 
104
111
  @host_proxy.run_ops(:run, remote_run_command_args)
@@ -148,9 +148,11 @@ module OpsWalrus
148
148
  # we run the block in the context of the host, s.t. `self` within the block evaluates to `host`
149
149
  retval = host.instance_exec(local_host, &block) # host is passed as the argument to the block
150
150
 
151
+ puts retval.inspect
152
+
151
153
  # cleanup
152
- if tmp_bundle_dir =~ /tmp/ # sanity check the temp path before we blow away something we don't intend
153
- host.execute(:rm, "-rf", "tmpopsbootstrap.sh", "tmpops.zip", tmp_bundle_dir)
154
+ if tmp_bundle_root_dir =~ /tmp/ # sanity check the temp path before we blow away something we don't intend
155
+ host.execute(:rm, "-rf", "tmpopsbootstrap.sh", "tmpops.zip", tmp_bundle_root_dir)
154
156
  else
155
157
  host.execute(:rm, "-rf", "tmpopsbootstrap.sh", "tmpops.zip")
156
158
  end
@@ -1,3 +1,3 @@
1
1
  module OpsWalrus
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
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.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Ellis