ridley 0.10.2 → 0.11.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +147 -216
- data/lib/ridley.rb +2 -0
- data/lib/ridley/bootstrap_bindings/unix_template_binding.rb +21 -25
- data/lib/ridley/bootstrap_bindings/windows_template_binding.rb +29 -34
- data/lib/ridley/bootstrapper.rb +2 -2
- data/lib/ridley/bootstrapper/context.rb +5 -5
- data/lib/ridley/chef.rb +0 -1
- data/lib/ridley/chef/cookbook.rb +0 -9
- data/lib/ridley/chef_object.rb +128 -0
- data/lib/ridley/chef_objects.rb +3 -0
- data/lib/ridley/chef_objects/client_object.rb +55 -0
- data/lib/ridley/chef_objects/cookbook_object.rb +190 -0
- data/lib/ridley/chef_objects/data_bag_item_obect.rb +104 -0
- data/lib/ridley/chef_objects/data_bag_object.rb +31 -0
- data/lib/ridley/chef_objects/environment_object.rb +59 -0
- data/lib/ridley/chef_objects/node_object.rb +161 -0
- data/lib/ridley/chef_objects/role_object.rb +62 -0
- data/lib/ridley/chef_objects/sandbox_object.rb +58 -0
- data/lib/ridley/client.rb +76 -45
- data/lib/ridley/connection.rb +1 -1
- data/lib/ridley/errors.rb +8 -1
- data/lib/ridley/host_connector.rb +26 -6
- data/lib/ridley/host_connector/ssh.rb +3 -3
- data/lib/ridley/host_connector/ssh/worker.rb +7 -9
- data/lib/ridley/host_connector/winrm/worker.rb +4 -5
- data/lib/ridley/mixin/bootstrap_binding.rb +1 -12
- data/lib/ridley/resource.rb +51 -171
- data/lib/ridley/resources/client_resource.rb +18 -68
- data/lib/ridley/resources/cookbook_resource.rb +181 -381
- data/lib/ridley/resources/data_bag_item_resource.rb +55 -161
- data/lib/ridley/resources/data_bag_resource.rb +20 -61
- data/lib/ridley/resources/environment_resource.rb +9 -64
- data/lib/ridley/resources/node_resource.rb +135 -311
- data/lib/ridley/resources/role_resource.rb +1 -57
- data/lib/ridley/resources/sandbox_resource.rb +80 -65
- data/lib/ridley/resources/search_resource.rb +99 -0
- data/lib/ridley/sandbox_uploader.rb +12 -52
- data/lib/ridley/version.rb +1 -1
- data/spec/acceptance/bootstrapping_spec.rb +1 -1
- data/spec/acceptance/client_resource_spec.rb +15 -37
- data/spec/acceptance/data_bag_item_resource_spec.rb +8 -14
- data/spec/acceptance/data_bag_resource_spec.rb +1 -1
- data/spec/acceptance/environment_resource_spec.rb +13 -22
- data/spec/acceptance/node_resource_spec.rb +10 -29
- data/spec/acceptance/role_resource_spec.rb +14 -13
- data/spec/acceptance/sandbox_resource_spec.rb +2 -2
- data/spec/support/shared_examples/ridley_resource.rb +2 -23
- data/spec/unit/ridley/bootstrap_bindings/unix_template_binding_spec.rb +3 -4
- data/spec/unit/ridley/bootstrap_bindings/windows_template_binding_spec.rb +3 -5
- data/spec/unit/ridley/bootstrapper/context_spec.rb +2 -3
- data/spec/unit/ridley/bootstrapper_spec.rb +1 -1
- data/spec/unit/ridley/chef_object_spec.rb +240 -0
- data/spec/unit/ridley/chef_objects/client_object_spec.rb +11 -0
- data/spec/unit/ridley/chef_objects/cookbook_object_spec.rb +93 -0
- data/spec/unit/ridley/chef_objects/data_bag_item_object_spec.rb +74 -0
- data/spec/unit/ridley/chef_objects/data_bag_object_spec.rb +9 -0
- data/spec/unit/ridley/chef_objects/environment_object_spec.rb +57 -0
- data/spec/unit/ridley/chef_objects/node_object_spec.rb +252 -0
- data/spec/unit/ridley/chef_objects/role_object_spec.rb +57 -0
- data/spec/unit/ridley/chef_objects/sandbox_object_spec.rb +66 -0
- data/spec/unit/ridley/client_spec.rb +51 -51
- data/spec/unit/ridley/host_connector/ssh/worker_spec.rb +4 -4
- data/spec/unit/ridley/host_connector/ssh_spec.rb +26 -24
- data/spec/unit/ridley/host_connector/winrm/worker_spec.rb +3 -4
- data/spec/unit/ridley/host_connector/winrm_spec.rb +4 -4
- data/spec/unit/ridley/host_connector_spec.rb +40 -3
- data/spec/unit/ridley/mixin/bootstrap_binding_spec.rb +1 -1
- data/spec/unit/ridley/resource_spec.rb +81 -109
- data/spec/unit/ridley/resources/client_resource_spec.rb +18 -33
- data/spec/unit/ridley/resources/cookbook_resource_spec.rb +56 -230
- data/spec/unit/ridley/resources/data_bag_item_resource_spec.rb +2 -57
- data/spec/unit/ridley/resources/data_bag_resource_spec.rb +12 -7
- data/spec/unit/ridley/resources/environment_resource_spec.rb +10 -118
- data/spec/unit/ridley/resources/node_resource_spec.rb +83 -394
- data/spec/unit/ridley/resources/role_resource_spec.rb +2 -56
- data/spec/unit/ridley/resources/sandbox_resource_spec.rb +139 -136
- data/spec/unit/ridley/resources/search_resource_spec.rb +234 -0
- data/spec/unit/ridley/sandbox_uploader_spec.rb +13 -58
- metadata +36 -17
- data/lib/ridley/chef/chefignore.rb +0 -76
- data/lib/ridley/resources/encrypted_data_bag_item_resource.rb +0 -55
- data/lib/ridley/resources/search.rb +0 -101
- data/spec/fixtures/chefignore +0 -8
- data/spec/unit/ridley/chef/chefignore_spec.rb +0 -40
- data/spec/unit/ridley/resources/search_spec.rb +0 -221
data/lib/ridley.rb
CHANGED
@@ -36,6 +36,7 @@ module Ridley
|
|
36
36
|
autoload :Connection, 'ridley/connection'
|
37
37
|
autoload :ChainLink, 'ridley/chain_link'
|
38
38
|
autoload :Chef, 'ridley/chef'
|
39
|
+
autoload :ChefObject, 'ridley/chef_object'
|
39
40
|
autoload :DSL, 'ridley/dsl'
|
40
41
|
autoload :Logging, 'ridley/logging'
|
41
42
|
autoload :Mixin, 'ridley/mixin'
|
@@ -71,4 +72,5 @@ Celluloid.logger = Ridley.logger
|
|
71
72
|
|
72
73
|
require 'ridley/bootstrap_bindings'
|
73
74
|
require 'ridley/middleware'
|
75
|
+
require 'ridley/chef_objects'
|
74
76
|
require 'ridley/resources'
|
@@ -1,15 +1,11 @@
|
|
1
|
-
#
|
2
|
-
# Ridley::UnixTemplateBinding
|
3
|
-
# Represents a binding that will be evaluated as an ERB template. When bootstrapping
|
4
|
-
# nodes, an instance of this class represents the customizable and necessary configurations
|
5
|
-
# need by the Host in order to install and connect to Chef. By default, this class will be used
|
6
|
-
# when SSH is the best way to connect to the node.
|
7
|
-
#
|
8
|
-
# @author Kyle Allan <kallan@riotgames.com>
|
9
|
-
#
|
10
1
|
module Ridley
|
2
|
+
# Represents a binding that will be evaluated as an ERB template. When bootstrapping
|
3
|
+
# nodes, an instance of this class represents the customizable and necessary configurations
|
4
|
+
# needed by the Host in order to install and connect to Chef. By default, this class will be used
|
5
|
+
# when SSH is the best way to connect to the node.
|
6
|
+
#
|
7
|
+
# @author Kyle Allan <kallan@riotgames.com>
|
11
8
|
class UnixTemplateBinding
|
12
|
-
|
13
9
|
include Ridley::BootstrapBinding
|
14
10
|
|
15
11
|
attr_reader :sudo
|
@@ -20,8 +16,8 @@ module Ridley
|
|
20
16
|
# filepath to the validator used to bootstrap the node (required)
|
21
17
|
# @option options [String] :bootstrap_proxy (nil)
|
22
18
|
# URL to a proxy server to bootstrap through
|
23
|
-
# @option options [String] :
|
24
|
-
#
|
19
|
+
# @option options [String] :encrypted_data_bag_secret
|
20
|
+
# your organizations encrypted data bag secret
|
25
21
|
# @option options [Hash] :hints (Hash.new)
|
26
22
|
# a hash of Ohai hints to place on the bootstrapped node
|
27
23
|
# @option options [Hash] :attributes (Hash.new)
|
@@ -41,19 +37,19 @@ module Ridley
|
|
41
37
|
options[:template] ||= default_template
|
42
38
|
self.class.validate_options(options)
|
43
39
|
|
44
|
-
@template_file
|
45
|
-
@bootstrap_proxy
|
46
|
-
@chef_version
|
47
|
-
@sudo
|
48
|
-
@validator_path
|
49
|
-
@
|
50
|
-
@hints
|
51
|
-
@server_url
|
52
|
-
@validator_client
|
53
|
-
@node_name
|
54
|
-
@attributes
|
55
|
-
@run_list
|
56
|
-
@environment
|
40
|
+
@template_file = options[:template]
|
41
|
+
@bootstrap_proxy = options[:bootstrap_proxy]
|
42
|
+
@chef_version = options[:chef_version]
|
43
|
+
@sudo = options[:sudo]
|
44
|
+
@validator_path = options[:validator_path]
|
45
|
+
@encrypted_data_bag_secret = options[:encrypted_data_bag_secret]
|
46
|
+
@hints = options[:hints]
|
47
|
+
@server_url = options[:server_url]
|
48
|
+
@validator_client = options[:validator_client]
|
49
|
+
@node_name = options[:node_name]
|
50
|
+
@attributes = options[:attributes]
|
51
|
+
@run_list = options[:run_list]
|
52
|
+
@environment = options[:environment]
|
57
53
|
end
|
58
54
|
|
59
55
|
# @return [String]
|
@@ -1,20 +1,17 @@
|
|
1
|
-
#
|
2
|
-
# Ridley::WindowsTemplateBinding
|
3
|
-
# Represents a binding that will be evaluated as an ERB template. When bootstrapping
|
4
|
-
# nodes, an instance of this class represents the customizable and necessary configurations
|
5
|
-
# need by the Host in order to install and connect to Chef. By default, this class will be used
|
6
|
-
# when WinRM is the best way to connect to the node.
|
7
|
-
#
|
8
|
-
# @author Kyle Allan <kallan@riotgames.com>
|
9
|
-
#
|
10
|
-
# Windows Specific code written by Seth Chisamore (<schisamo@opscode.com>) in knife-windows
|
11
|
-
# https://github.com/opscode/knife-windows/blob/3b8886ddcfb928ca0958cd05b22f8c3d78bee86e/lib/chef/knife/bootstrap/windows-chef-client-msi.erb
|
12
|
-
# https://github.com/opscode/knife-windows/blob/78d38bbed358ac20107fc2b5b427f4b5e52e5cb2/lib/chef/knife/core/windows_bootstrap_context.rb
|
13
1
|
module Ridley
|
2
|
+
# Represents a binding that will be evaluated as an ERB template. When bootstrapping
|
3
|
+
# nodes, an instance of this class represents the customizable and necessary configurations
|
4
|
+
# needed by the Host in order to install and connect to Chef. By default, this class will be used
|
5
|
+
# when WinRM is the best way to connect to the node.
|
6
|
+
#
|
7
|
+
# @author Kyle Allan <kallan@riotgames.com>
|
8
|
+
#
|
9
|
+
# Windows Specific code written by Seth Chisamore (<schisamo@opscode.com>) in knife-windows
|
10
|
+
# https://github.com/opscode/knife-windows/blob/3b8886ddcfb928ca0958cd05b22f8c3d78bee86e/lib/chef/knife/bootstrap/windows-chef-client-msi.erb
|
11
|
+
# https://github.com/opscode/knife-windows/blob/78d38bbed358ac20107fc2b5b427f4b5e52e5cb2/lib/chef/knife/core/windows_bootstrap_context.rb
|
14
12
|
class WindowsTemplateBinding
|
15
|
-
|
16
13
|
include Ridley::BootstrapBinding
|
17
|
-
|
14
|
+
|
18
15
|
attr_reader :template_file
|
19
16
|
|
20
17
|
# @option options [String] :validator_client
|
@@ -22,8 +19,8 @@ module Ridley
|
|
22
19
|
# filepath to the validator used to bootstrap the node (required)
|
23
20
|
# @option options [String] :bootstrap_proxy (nil)
|
24
21
|
# URL to a proxy server to bootstrap through
|
25
|
-
# @option options [String] :
|
26
|
-
#
|
22
|
+
# @option options [String] :encrypted_data_bag_secret
|
23
|
+
# your organizations encrypted data bag secret
|
27
24
|
# @option options [Hash] :hints (Hash.new)
|
28
25
|
# a hash of Ohai hints to place on the bootstrapped node
|
29
26
|
# @option options [Hash] :attributes (Hash.new)
|
@@ -43,24 +40,24 @@ module Ridley
|
|
43
40
|
options[:template] ||= default_template
|
44
41
|
self.class.validate_options(options)
|
45
42
|
|
46
|
-
@template_file
|
47
|
-
@bootstrap_proxy
|
48
|
-
@chef_version
|
49
|
-
@validator_path
|
50
|
-
@
|
51
|
-
@server_url
|
52
|
-
@validator_client
|
53
|
-
@node_name
|
54
|
-
@attributes
|
55
|
-
@run_list
|
56
|
-
@environment
|
43
|
+
@template_file = options[:template]
|
44
|
+
@bootstrap_proxy = options[:bootstrap_proxy]
|
45
|
+
@chef_version = options[:chef_version] ? options[:chef_version] : "latest"
|
46
|
+
@validator_path = options[:validator_path]
|
47
|
+
@encrypted_data_bag_secret = options[:encrypted_data_bag_secret]
|
48
|
+
@server_url = options[:server_url]
|
49
|
+
@validator_client = options[:validator_client]
|
50
|
+
@node_name = options[:node_name]
|
51
|
+
@attributes = options[:attributes]
|
52
|
+
@run_list = options[:run_list]
|
53
|
+
@environment = options[:environment]
|
57
54
|
end
|
58
55
|
|
59
56
|
# @return [String]
|
60
57
|
def boot_command
|
61
58
|
template.evaluate(self)
|
62
59
|
end
|
63
|
-
|
60
|
+
|
64
61
|
# @return [String]
|
65
62
|
def chef_config
|
66
63
|
body = <<-CONFIG
|
@@ -112,16 +109,14 @@ CONFIG
|
|
112
109
|
|
113
110
|
# @return [String]
|
114
111
|
def encrypted_data_bag_secret
|
115
|
-
return unless
|
112
|
+
return unless @encrypted_data_bag_secret
|
116
113
|
|
117
|
-
escape_and_echo(
|
118
|
-
rescue Errno::ENOENT
|
119
|
-
raise Errors::EncryptedDataBagSecretNotFound, "Error bootstrapping: Encrypted data bag secret provided but not found at '#{encrypted_data_bag_secret_path}'"
|
114
|
+
escape_and_echo(@encrypted_data_bag_secret)
|
120
115
|
end
|
121
116
|
|
122
117
|
# Implements a Powershell script that attempts a simple
|
123
118
|
# 'wget' to download the Chef msi
|
124
|
-
#
|
119
|
+
#
|
125
120
|
# @return [String]
|
126
121
|
def windows_wget_powershell
|
127
122
|
win_wget_ps = <<-WGET_PS
|
@@ -130,7 +125,7 @@ param(
|
|
130
125
|
[String] $localPath
|
131
126
|
)
|
132
127
|
|
133
|
-
$webClient = new-object System.Net.WebClient;
|
128
|
+
$webClient = new-object System.Net.WebClient;
|
134
129
|
|
135
130
|
$webClient.DownloadFile($remoteUrl, $localPath);
|
136
131
|
WGET_PS
|
data/lib/ridley/bootstrapper.rb
CHANGED
@@ -27,8 +27,8 @@ module Ridley
|
|
27
27
|
# filepath to the validator used to bootstrap the node (required)
|
28
28
|
# @option options [String] :bootstrap_proxy (nil)
|
29
29
|
# URL to a proxy server to bootstrap through
|
30
|
-
# @option options [String] :
|
31
|
-
#
|
30
|
+
# @option options [String] :encrypted_data_bag_secret
|
31
|
+
# your organizations encrypted data bag secret
|
32
32
|
# @option options [Hash] :hints (Hash.new)
|
33
33
|
# a hash of Ohai hints to place on the bootstrapped node
|
34
34
|
# @option options [Hash] :attributes (Hash.new)
|
@@ -21,8 +21,8 @@ module Ridley
|
|
21
21
|
# filepath to the validator used to bootstrap the node (required)
|
22
22
|
# @option options [String] :bootstrap_proxy (nil)
|
23
23
|
# URL to a proxy server to bootstrap through
|
24
|
-
# @option options [String] :
|
25
|
-
#
|
24
|
+
# @option options [String] :encrypted_data_bag_secret
|
25
|
+
# your organizations encrypted data bag secret
|
26
26
|
# @option options [Hash] :hints (Hash.new)
|
27
27
|
# a hash of Ohai hints to place on the bootstrapped node
|
28
28
|
# @option options [Hash] :attributes (Hash.new)
|
@@ -67,9 +67,9 @@ module Ridley
|
|
67
67
|
# @param [Ridley::Binding] template_binding
|
68
68
|
# an instance of either the UnixTemplateBinding or WindowsTemplateBinding class
|
69
69
|
def initialize(host, host_connector, template_binding)
|
70
|
-
@host
|
71
|
-
@host_connector
|
72
|
-
@template_binding
|
70
|
+
@host = host
|
71
|
+
@host_connector = host_connector
|
72
|
+
@template_binding = template_binding
|
73
73
|
end
|
74
74
|
|
75
75
|
# @return [String]
|
data/lib/ridley/chef.rb
CHANGED
data/lib/ridley/chef/cookbook.rb
CHANGED
@@ -96,7 +96,6 @@ module Ridley::Chef
|
|
96
96
|
root_files: Array.new
|
97
97
|
)
|
98
98
|
@frozen = false
|
99
|
-
@chefignore = Ridley::Chef::Chefignore.new(@path)
|
100
99
|
|
101
100
|
load_files
|
102
101
|
end
|
@@ -208,12 +207,7 @@ module Ridley::Chef
|
|
208
207
|
|
209
208
|
private
|
210
209
|
|
211
|
-
# @return [Array]
|
212
210
|
attr_reader :files
|
213
|
-
# @return [Ridley::Chef::Chefignore]
|
214
|
-
attr_reader :chefignore
|
215
|
-
|
216
|
-
def_delegator :chefignore, :ignored?
|
217
211
|
|
218
212
|
def load_files
|
219
213
|
load_shallow(:recipes, 'recipes', '*.rb')
|
@@ -231,7 +225,6 @@ module Ridley::Chef
|
|
231
225
|
[].tap do |files|
|
232
226
|
Dir.glob(path.join('*'), File::FNM_DOTMATCH).each do |file|
|
233
227
|
next if File.directory?(file)
|
234
|
-
next if ignored?(file)
|
235
228
|
@files << file
|
236
229
|
@manifest[:root_files] << file_metadata(:root_files, file)
|
237
230
|
end
|
@@ -243,7 +236,6 @@ module Ridley::Chef
|
|
243
236
|
file_spec = path.join(category_dir, '**', glob)
|
244
237
|
Dir.glob(file_spec, File::FNM_DOTMATCH).each do |file|
|
245
238
|
next if File.directory?(file)
|
246
|
-
next if ignored?(file)
|
247
239
|
@files << file
|
248
240
|
@manifest[category] << file_metadata(category, file)
|
249
241
|
end
|
@@ -253,7 +245,6 @@ module Ridley::Chef
|
|
253
245
|
def load_shallow(category, *path_glob)
|
254
246
|
[].tap do |files|
|
255
247
|
Dir[path.join(*path_glob)].each do |file|
|
256
|
-
next if ignored?(file)
|
257
248
|
@files << file
|
258
249
|
@manifest[category] << file_metadata(category, file)
|
259
250
|
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
module Ridley
|
2
|
+
# @author Jamie Winsor <reset@riotgames.com>
|
3
|
+
class ChefObject
|
4
|
+
class << self
|
5
|
+
# @return [String, nil]
|
6
|
+
def chef_id
|
7
|
+
@chef_id
|
8
|
+
end
|
9
|
+
|
10
|
+
# @param [String, Symbol] identifier
|
11
|
+
#
|
12
|
+
# @return [String]
|
13
|
+
def set_chef_id(identifier)
|
14
|
+
@chef_id = identifier.to_sym
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [String]
|
18
|
+
def chef_type
|
19
|
+
@chef_type ||= self.class.name.underscore
|
20
|
+
end
|
21
|
+
|
22
|
+
# @param [String, Symbol] type
|
23
|
+
#
|
24
|
+
# @return [String]
|
25
|
+
def set_chef_type(type)
|
26
|
+
@chef_type = type.to_s
|
27
|
+
attribute(:chef_type, default: type)
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [String, nil]
|
31
|
+
def chef_json_class
|
32
|
+
@chef_json_class
|
33
|
+
end
|
34
|
+
|
35
|
+
# @param [String, Symbol] klass
|
36
|
+
#
|
37
|
+
# @return [String]
|
38
|
+
def set_chef_json_class(klass)
|
39
|
+
@chef_json_class = klass
|
40
|
+
attribute(:json_class, default: klass)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
include Chozo::VariaModel
|
45
|
+
include Comparable
|
46
|
+
|
47
|
+
# @param [Ridley::Resource] resource
|
48
|
+
# @param [Hash] new_attrs
|
49
|
+
def initialize(resource, new_attrs = {})
|
50
|
+
@resource = resource
|
51
|
+
mass_assign(new_attrs)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Creates a resource on the target remote or updates one if the resource
|
55
|
+
# already exists.
|
56
|
+
#
|
57
|
+
# @raise [Errors::InvalidResource]
|
58
|
+
# if the resource does not pass validations
|
59
|
+
#
|
60
|
+
# @return [Boolean]
|
61
|
+
def save
|
62
|
+
raise Errors::InvalidResource.new(self.errors) unless valid?
|
63
|
+
|
64
|
+
mass_assign(resource.create(self)._attributes_)
|
65
|
+
true
|
66
|
+
rescue Errors::HTTPConflict
|
67
|
+
self.update
|
68
|
+
true
|
69
|
+
end
|
70
|
+
|
71
|
+
# Updates the instantiated resource on the target remote with any changes made
|
72
|
+
# to self
|
73
|
+
#
|
74
|
+
# @raise [Errors::InvalidResource]
|
75
|
+
# if the resource does not pass validations
|
76
|
+
#
|
77
|
+
# @return [Boolean]
|
78
|
+
def update
|
79
|
+
raise Errors::InvalidResource.new(self.errors) unless valid?
|
80
|
+
|
81
|
+
mass_assign(resource.update(self)._attributes_)
|
82
|
+
true
|
83
|
+
end
|
84
|
+
|
85
|
+
# Reload the attributes of the instantiated resource
|
86
|
+
#
|
87
|
+
# @return [Object]
|
88
|
+
def reload
|
89
|
+
mass_assign(resource.find(self)._attributes_)
|
90
|
+
self
|
91
|
+
end
|
92
|
+
|
93
|
+
# @return [String]
|
94
|
+
def chef_id
|
95
|
+
get_attribute(self.class.chef_id)
|
96
|
+
end
|
97
|
+
|
98
|
+
def inspect
|
99
|
+
"#<#{self.class} chef_id:#{self.chef_id}, attributes:#{self._attributes_}>"
|
100
|
+
end
|
101
|
+
|
102
|
+
# @param [Object] other
|
103
|
+
#
|
104
|
+
# @return [Boolean]
|
105
|
+
def <=>(other)
|
106
|
+
self.chef_id <=> other.chef_id
|
107
|
+
end
|
108
|
+
|
109
|
+
def ==(other)
|
110
|
+
self.chef_id == other.chef_id
|
111
|
+
end
|
112
|
+
|
113
|
+
# @param [Object] other
|
114
|
+
#
|
115
|
+
# @return [Boolean]
|
116
|
+
def eql?(other)
|
117
|
+
self.class == other.class && self == other
|
118
|
+
end
|
119
|
+
|
120
|
+
def hash
|
121
|
+
self.chef_id.hash
|
122
|
+
end
|
123
|
+
|
124
|
+
private
|
125
|
+
|
126
|
+
attr_reader :resource
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Ridley
|
2
|
+
# @author Jamie Winsor <reset@riotgames.com>
|
3
|
+
class ClientObject < Ridley::ChefObject
|
4
|
+
set_chef_id "name"
|
5
|
+
set_chef_type "client"
|
6
|
+
set_chef_json_class "Chef::ApiClient"
|
7
|
+
|
8
|
+
attribute :name,
|
9
|
+
type: String,
|
10
|
+
required: true
|
11
|
+
|
12
|
+
attribute :admin,
|
13
|
+
type: Boolean,
|
14
|
+
required: true,
|
15
|
+
default: false
|
16
|
+
|
17
|
+
attribute :validator,
|
18
|
+
type: Boolean,
|
19
|
+
required: true,
|
20
|
+
default: false
|
21
|
+
|
22
|
+
attribute :certificate,
|
23
|
+
type: String
|
24
|
+
|
25
|
+
attribute :public_key,
|
26
|
+
type: String
|
27
|
+
|
28
|
+
attribute :private_key,
|
29
|
+
type: [ String, Boolean ]
|
30
|
+
|
31
|
+
attribute :orgname,
|
32
|
+
type: String
|
33
|
+
|
34
|
+
# Regenerates the private key of the instantiated client object. The new
|
35
|
+
# private key will be set to the value of the 'private_key' accessor
|
36
|
+
# of the instantiated client object.
|
37
|
+
#
|
38
|
+
# @return [Boolean]
|
39
|
+
# true for success and false for failure
|
40
|
+
def regenerate_key
|
41
|
+
self.private_key = true
|
42
|
+
self.save
|
43
|
+
end
|
44
|
+
|
45
|
+
# Override to_json to reflect to massage the returned attributes based on the type
|
46
|
+
# of connection. Only OHC/OPC requires the json_class attribute is not present.
|
47
|
+
def to_json
|
48
|
+
if resource.connection.hosted?
|
49
|
+
to_hash.except(:json_class).to_json
|
50
|
+
else
|
51
|
+
super
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|