46 lines
967 B
Ruby
46 lines
967 B
Ruby
require "devops-client/output/base"
|
|
|
|
module Output
|
|
class StackPreset < Base
|
|
|
|
def table
|
|
if outputting_list?
|
|
title = I18n.t("output.title.stack_preset.list")
|
|
headers, rows = create_list
|
|
else
|
|
title = I18n.t("output.title.stack.show", id: @data["id"])
|
|
headers, rows = create_apply
|
|
end
|
|
create_table headers, rows, title, with_num?
|
|
end
|
|
|
|
def csv
|
|
if outputting_list?
|
|
headers, rows = create_list
|
|
else
|
|
headers, rows = create_show
|
|
end
|
|
create_csv headers, rows, with_num?
|
|
end
|
|
|
|
def json
|
|
JSON.pretty_generate(@data)
|
|
end
|
|
|
|
private
|
|
|
|
def create_list
|
|
abort(I18n.t("output.not_found.stack_preset.list")) if @data.empty?
|
|
|
|
fields_to_output = %w(id)
|
|
|
|
headers_and_rows(@data, fields_to_output)
|
|
end
|
|
|
|
def create_apply
|
|
headers_and_rows([@data], %w(id deploy_env stack_template cloud_stack_id stack_status))
|
|
end
|
|
|
|
end
|
|
end
|