Class: Chef::Knife::NodeEditor
- Defined in:
- lib/chef/knife/core/node_editor.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#ui ⇒ Object
readonly
Returns the value of attribute ui.
Instance Method Summary collapse
- #edit_node ⇒ Object
-
#initialize(node, ui, config) ⇒ NodeEditor
constructor
A new instance of NodeEditor.
- #updated? ⇒ Boolean
Constructor Details
#initialize(node, ui, config) ⇒ NodeEditor
Returns a new instance of NodeEditor.
31 32 33 |
# File 'lib/chef/knife/core/node_editor.rb', line 31 def initialize(node, ui, config) @node, @ui, @config = node, ui, config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
29 30 31 |
# File 'lib/chef/knife/core/node_editor.rb', line 29 def config @config end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
27 28 29 |
# File 'lib/chef/knife/core/node_editor.rb', line 27 def node @node end |
#ui ⇒ Object (readonly)
Returns the value of attribute ui.
28 29 30 |
# File 'lib/chef/knife/core/node_editor.rb', line 28 def ui @ui end |
Instance Method Details
#edit_node ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/chef/knife/core/node_editor.rb', line 35 def edit_node abort "You specified the --disable_editing option, nothing to edit" if config[:disable_editing] assert_editor_set! updated_node_data = @ui.edit_data(view) apply_updates(updated_node_data) @updated_node end |
#updated? ⇒ Boolean
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/chef/knife/core/node_editor.rb', line 44 def updated? pristine_copy = Chef::JSONCompat.parse(Chef::JSONCompat.to_json(node)) updated_copy = Chef::JSONCompat.parse(Chef::JSONCompat.to_json(@updated_node)) unless pristine_copy == updated_copy updated_properties = %w{name normal chef_environment run_list default override automatic}.reject do |key| pristine_copy[key] == updated_copy[key] end end ( pristine_copy != updated_copy ) && updated_properties end |