knife-opc 0.4.4 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef/knife/opc_user_create.rb +1 -1
- data/lib/chef/knife/opc_user_edit.rb +30 -5
- data/lib/knife-opc/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7af88ddccf9a69fbab41970cfeb23bc0f9fd0f0b04451673933115f887c4d27
|
4
|
+
data.tar.gz: c0ab4f3057dcee7b9a5d10d64de463ebb638f3aecb477be696b6b83a3dd2ab8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e4e0abf5f50ff0f8b5eef59551c1e1e2ae341a8e2d4bd31579f77e99c6be410b9257ffd0ff870c5ef4a73e7ef3f6a874c93fa68306c6b1a0dad6dfe89379649
|
7
|
+
data.tar.gz: e220bd8ea974284ac13910b7fe6006d9bfe67a42e2fc87c21031674062b2eb672330c5109fad4303ae8eb7171e1ed4e416766692868941a1f2c90f4d71eef66a
|
@@ -69,7 +69,7 @@ module Opc
|
|
69
69
|
password: password,
|
70
70
|
}
|
71
71
|
|
72
|
-
|
72
|
+
# Check the file before creating the user so the api is more transactional.
|
73
73
|
if config[:filename]
|
74
74
|
file = config[:filename]
|
75
75
|
unless File.exist?(file) ? File.writable?(file) : File.writable?(File.dirname(file))
|
@@ -44,11 +44,7 @@ module Opc
|
|
44
44
|
end
|
45
45
|
|
46
46
|
original_user = root_rest.get("users/#{user_name}")
|
47
|
-
|
48
|
-
edited_user = JSON.parse(IO.read(config[:input]))
|
49
|
-
else
|
50
|
-
edited_user = edit_data(original_user)
|
51
|
-
end
|
47
|
+
edited_user = get_updated_user(original_user)
|
52
48
|
if original_user != edited_user
|
53
49
|
result = root_rest.put("users/#{user_name}", edited_user)
|
54
50
|
ui.msg("Saved #{user_name}.")
|
@@ -65,5 +61,34 @@ module Opc
|
|
65
61
|
ui.msg("User unchanged, not saving.")
|
66
62
|
end
|
67
63
|
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
# Check the options for ex: input or filename
|
68
|
+
# Read Or Open file to update user information
|
69
|
+
# return updated user
|
70
|
+
def get_updated_user(original_user)
|
71
|
+
if config[:input]
|
72
|
+
edited_user = JSON.parse(IO.read(config[:input]))
|
73
|
+
elsif config[:filename]
|
74
|
+
file = config[:filename]
|
75
|
+
unless File.exist?(file) ? File.writable?(file) : File.writable?(File.dirname(file))
|
76
|
+
ui.fatal "File #{file} is not writable. Check permissions."
|
77
|
+
exit 1
|
78
|
+
else
|
79
|
+
output = Chef::JSONCompat.to_json_pretty(original_user)
|
80
|
+
File.open(file, "w") do |f|
|
81
|
+
f.sync = true
|
82
|
+
f.puts output
|
83
|
+
f.close
|
84
|
+
raise "Please set EDITOR environment variable. See https://docs.chef.io/knife_setup/ for details." unless system("#{config[:editor]} #{f.path}")
|
85
|
+
|
86
|
+
edited_user = JSON.parse(IO.read(f.path))
|
87
|
+
end
|
88
|
+
end
|
89
|
+
else
|
90
|
+
edited_user = JSON.parse(edit_data(original_user, false))
|
91
|
+
end
|
92
|
+
end
|
68
93
|
end
|
69
94
|
end
|
data/lib/knife-opc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-opc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Danna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Knife Tools for Chef Server
|
14
14
|
email: steve@chef.io
|