Skip to content

Commit

Permalink
Added validation for image_os_type and connection_port
Browse files Browse the repository at this point in the history
Signed-off-by: Kapil Chouhan <kapil.chouhan@msystechnologies.com>
  • Loading branch information
Kapil Chouhan committed Jun 27, 2019
1 parent 9ca6c07 commit d5d30e4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/chef/knife/google_server_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ def validate_params!
"It is required when resetting passwords on Windows hosts."
end

raise "Please provide connection port via --connection-port." unless locate_config_value(:connection_port)
raise "Please provide image os type via --image-os-type." unless locate_config_value(:image_os_type)
ui.warn("Auto-migrate disabled for preemptible instance") if preemptible? && locate_config_value(:auto_migrate)
ui.warn("Auto-restart disabled for preemptible instance") if preemptible? && locate_config_value(:auto_restart)
ui.warn("[DEPRECATED] --bootstrap-protocol option is deprecated. Use --connection-protocol option instead.") if locate_config_value(:bootstrap_protocol)
Expand All @@ -203,7 +205,8 @@ def before_bootstrap

config[:chef_node_name] = locate_config_value(:chef_node_name) ? locate_config_value(:chef_node_name) : instance_name
config[:bootstrap_ip_address] = ip_address_for_bootstrap
if locate_config_value(:connection_protocol) == "winrm"

if locate_config_value(:image_os_type) == "windows"
ui.msg("Resetting the Windows login password so the bootstrap can continue...")
config[:connection_password] = reset_windows_password
end
Expand Down

0 comments on commit d5d30e4

Please sign in to comment.