class Kontena::Cli::Master::Config::ExportCommand

Public Instance Methods

data() click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# File lib/kontena/cli/master/config/export_command.rb, line 41
def execute
  set_default_format
  output(decorate(data))
end
output(content) click to toggle source
# File lib/kontena/cli/master/config/export_command.rb, line 29
def output(content)
  self.path ? File.write(self.path, content) : puts(content)
end
set_default_format() click to toggle source
# 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