Class: Chef::Knife::Cloud::GoogleImageList

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

Instance Method Summary collapse

Methods included from GoogleServiceOptions

included

Instance Method Details

#before_exec_commandObject



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

def before_exec_command
  @columns_with_info = [
    { label: "NAME", key: "name" },
    { label: "PROJECT", key: "self_link", value_callback: method(:find_project_name) },
    { label: "FAMILY", key: "family" },
    { label: "DISK SIZE", key: "disk_size_gb", value_callback: method(:format_disk_size_value) },
    { label: "STATUS", key: "status" },
  ]
end

#find_project_name(self_link) ⇒ Object



50
51
52
# File 'lib/chef/knife/google_image_list.rb', line 50

def find_project_name(self_link)
  self_link[%r{projects\/(.*?)\/}m, 1]
end

#format_disk_size_value(disk_size) ⇒ Object



54
55
56
# File 'lib/chef/knife/google_image_list.rb', line 54

def format_disk_size_value(disk_size)
  "#{disk_size} GB"
end

#query_resourceObject



58
59
60
# File 'lib/chef/knife/google_image_list.rb', line 58

def query_resource
  service.list_images
end

#validate_params!Object



35
36
37
38
# File 'lib/chef/knife/google_image_list.rb', line 35

def validate_params!
  check_for_missing_config_values!
  super
end