Class: Chef::Knife::Cloud::GoogleZoneList

Inherits:
ResourceListCommand
  • Object
show all
Includes:
GoogleServiceOptions
Defined in:
lib/chef/knife/google_zone_list.rb

Instance Method Summary collapse

Methods included from GoogleServiceOptions

included

Instance Method Details

#before_exec_commandObject



41
42
43
44
45
46
47
48
# File 'lib/chef/knife/google_zone_list.rb', line 41

def before_exec_command
  @columns_with_info = [
    { label: "Zone",   key: "name" },
    { label: "Status", key: "status", value_callback: method(:format_status_value) },
  ]

  @sort_by_field = "name"
end

#format_status_value(status) ⇒ Object



50
51
52
53
54
55
56
57
58
59
# File 'lib/chef/knife/google_zone_list.rb', line 50

def format_status_value(status)
  status = status.downcase
  status_color = if status == "up"
                   :green
                 else
                   :red
                 end

  ui.color(status, status_color)
end

#query_resourceObject



61
62
63
# File 'lib/chef/knife/google_zone_list.rb', line 61

def query_resource
  service.list_zones
end

#validate_params!Object



36
37
38
39
# File 'lib/chef/knife/google_zone_list.rb', line 36

def validate_params!
  check_for_missing_config_values!
  super
end