Module: Chef::Knife::Cloud::Helpers
- Included in:
- BootstrapCommand, BootstrapProtocol, Command, Service
- Defined in:
- lib/chef/knife/cloud/helpers.rb
Instance Method Summary collapse
- #after_exec_command ⇒ Object
-
#before_exec_command ⇒ Object
Derived classes can override before_exec_command and after_exec_command.
- #create_service_instance ⇒ Object
- #execute_command ⇒ Object
-
#msg_pair(label, value, color = :cyan) ⇒ Object
Additional helpers.
- #pretty_key(key) ⇒ Object
- #set_default_config ⇒ Object
- #validate!(*keys) ⇒ Object
- #validate_params! ⇒ Object
Instance Method Details
#after_exec_command ⇒ Object
41 |
# File 'lib/chef/knife/cloud/helpers.rb', line 41 def after_exec_command; end |
#before_exec_command ⇒ Object
Derived classes can override before_exec_command and after_exec_command
39 |
# File 'lib/chef/knife/cloud/helpers.rb', line 39 def before_exec_command; end |
#create_service_instance ⇒ Object
30 31 32 |
# File 'lib/chef/knife/cloud/helpers.rb', line 30 def create_service_instance raise Chef::Exceptions::Override, "You must override create_service_instance in #{self} to create cloud specific service" end |
#execute_command ⇒ Object
34 35 36 |
# File 'lib/chef/knife/cloud/helpers.rb', line 34 def execute_command raise Chef::Exceptions::Override, "You must override execute_command in #{self}" end |
#msg_pair(label, value, color = :cyan) ⇒ Object
Additional helpers
24 25 26 27 28 |
# File 'lib/chef/knife/cloud/helpers.rb', line 24 def msg_pair(label, value, color = :cyan) if value && !value.to_s.empty? puts "#{ui.color(label, color)}: #{value}" end end |
#pretty_key(key) ⇒ Object
58 59 60 |
# File 'lib/chef/knife/cloud/helpers.rb', line 58 def pretty_key(key) key.to_s.tr("_", " ").gsub(/\w+/) { |w| (w =~ /(ssh)|(aws)/i) ? w.upcase : w.capitalize } end |
#set_default_config ⇒ Object
43 |
# File 'lib/chef/knife/cloud/helpers.rb', line 43 def set_default_config; end |
#validate!(*keys) ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/chef/knife/cloud/helpers.rb', line 45 def validate!(*keys) # validates necessary options/params to carry out the command. # subclasses to implement this. errors = [] keys.each do |k| errors << "You did not provide a valid '#{pretty_key(k)}' value." if config[k].nil? end = "" raise CloudExceptions::ValidationError, if errors.each { |e| ui.error(e); = "#{} #{e}." }.any? end |
#validate_params! ⇒ Object
56 |
# File 'lib/chef/knife/cloud/helpers.rb', line 56 def validate_params!; end |