knife-essentials 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/chef/knife/raw.rb +14 -3
- data/lib/chef_fs/version.rb +1 -1
- metadata +1 -1
data/lib/chef/knife/raw.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
1
3
|
class Chef
|
2
4
|
class Knife
|
3
5
|
class Raw < Chef::Knife
|
@@ -7,7 +9,13 @@ class Chef
|
|
7
9
|
:long => '--method METHOD',
|
8
10
|
:short => '-m METHOD',
|
9
11
|
:default => "GET",
|
10
|
-
:description => "
|
12
|
+
:description => "Request method (GET, POST, PUT or DELETE)"
|
13
|
+
|
14
|
+
option :pretty,
|
15
|
+
:long => '--[no-]pretty',
|
16
|
+
:boolean => true,
|
17
|
+
:default => true,
|
18
|
+
:description => "Pretty-print JSON output"
|
11
19
|
|
12
20
|
option :input,
|
13
21
|
:long => '--input FILE',
|
@@ -60,8 +68,11 @@ class Chef
|
|
60
68
|
response_body = response.body
|
61
69
|
|
62
70
|
if response.kind_of?(Net::HTTPSuccess)
|
63
|
-
|
64
|
-
|
71
|
+
if config[:pretty] && response['content-type'] =~ /json/
|
72
|
+
JSON.pretty_generate(JSON.parse(response_body, :create_additions => false))
|
73
|
+
else
|
74
|
+
response_body
|
75
|
+
end
|
65
76
|
elsif redirect_location = redirected_to(response)
|
66
77
|
raise "Redirected to #{create_url(redirect_location)}"
|
67
78
|
follow_redirect {api_request(:GET, create_url(redirect_location))}
|
data/lib/chef_fs/version.rb
CHANGED