From d5d30e44407b9b56c7dad350737fb6a0af93d047 Mon Sep 17 00:00:00 2001 From: Kapil Chouhan Date: Thu, 27 Jun 2019 13:20:09 +0530 Subject: [PATCH] Added validation for image_os_type and connection_port Signed-off-by: Kapil Chouhan --- lib/chef/knife/google_server_create.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/chef/knife/google_server_create.rb b/lib/chef/knife/google_server_create.rb index ecc6a85..c9a5e66 100644 --- a/lib/chef/knife/google_server_create.rb +++ b/lib/chef/knife/google_server_create.rb @@ -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) @@ -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