Class: Kontena::Cli::Master::Config::ExportCommand
Instance Attribute Summary
#arguments, #exit_code, #result
Instance Method Summary
collapse
Methods included from Common
#access_token=, #add_master, #any_key_to_continue, #any_key_to_continue_with_timeout, #api_url, #api_url=, #caret, #clear_current_grid, #client, #cloud_auth?, #cloud_client, #config, #confirm, #confirm_command, #current_grid, #current_master_index, #debug?, #display_account_login_info, #display_login_info, display_logo, #display_master_login_info, #error, exit_with_error, #kontena_account, #logger, #pastel, #print, #prompt, #puts, #require_api_url, #require_token, #reset_client, #reset_cloud_client, #running_quiet?, #running_silent?, #running_verbose?, #spin_if, #spinner, #sprint, #sputs, #stdin_input, #use_refresh_token, #vfakespinner, #vputs, #vspinner, #warning
banner, callback_matcher, #help_requested?, inherited, #instance, load_subcommand, requires_current_account_token, requires_current_account_token?, requires_current_grid, requires_current_grid?, requires_current_master, requires_current_master?, requires_current_master_token, requires_current_master_token?, #run, #run_callbacks, #verify_current_account_token, #verify_current_grid, #verify_current_master, #verify_current_master_token
Instance Method Details
#data ⇒ Object
33
34
35
|
# File 'lib/kontena/cli/master/config/export_command.rb', line 33
def data
client.get("config", self.filter ? { filter: self.filter } : nil)
end
|
#decorate(data) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/kontena/cli/master/config/export_command.rb', line 16
def decorate(data)
case self.format.downcase
when 'json'
require 'json'
JSON.pretty_generate(data)
when 'yaml', 'yml'
require 'yaml'
YAML.dump(data)
else
exit_with_error "Unknown output format '#{self.format}'"
end
end
|
#execute ⇒ Object
41
42
43
44
|
# File 'lib/kontena/cli/master/config/export_command.rb', line 41
def execute
set_default_format
output(decorate(data))
end
|
#output(content) ⇒ Object
29
30
31
|
# File 'lib/kontena/cli/master/config/export_command.rb', line 29
def output(content)
self.path ? File.write(self.path, content) : puts(content)
end
|
37
38
39
|
# File 'lib/kontena/cli/master/config/export_command.rb', line 37
def set_default_format
self.format ||= self.path.to_s.end_with?('.yml') ? 'yaml' : 'json'
end
|