class R10K::Action::Deploy::Display

Public Instance Methods

call() click to toggle source
# File lib/r10k/action/deploy/display.rb, line 12
def call
  expect_config!
  deployment = R10K::Deployment.new(@settings)

  if @fetch
    deployment.preload!
  end

  output = { :sources => deployment.sources.map { |source| source_info(source, @argv) } }

  case @format
  when 'json' then json_format(output)
  else yaml_format(output)
  end

  # exit 0
  true
rescue => e
  logger.error R10K::Errors::Formatting.format_exception(e, @trace)
  false
end

Private Instance Methods

allowed_initialize_opts() click to toggle source
# File lib/r10k/action/deploy/display.rb, line 83
def allowed_initialize_opts
  super.merge(puppetfile: :self, detail: :self, format: :self, fetch: :self)
end
environment_info(env) click to toggle source
# File lib/r10k/action/deploy/display.rb, line 61
def environment_info(env)
  if !@puppetfile && !@detail
    env.dirname
  else
    env_info = env.info.merge({
      :status => (env.status rescue nil),
    })

    env_info[:modules] = env.modules.map { |mod| module_info(mod) } if @puppetfile

    env_info
  end
end
json_format(output) click to toggle source
# File lib/r10k/action/deploy/display.rb, line 36
def json_format(output)
  require 'json'
  puts JSON.pretty_generate(output)
end
module_info(mod) click to toggle source
# File lib/r10k/action/deploy/display.rb, line 75
def module_info(mod)
  if @detail
    { :name => mod.title, :properties => mod.properties }
  else
    mod.title
  end
end
source_info(source, argv=[]) click to toggle source
# File lib/r10k/action/deploy/display.rb, line 46
def source_info(source, argv=[])
  source_info = {
    :name => source.name,
    :basedir => source.basedir,
  }

  source_info[:prefix] = source.prefix if source.prefix
  source_info[:remote] = source.remote if source.respond_to?(:remote)

  env_list = source.environments.select { |env| argv.empty? || argv.include?(env.name) }
  source_info[:environments] = env_list.map { |env| environment_info(env) }

  source_info
end
yaml_format(output) click to toggle source
# File lib/r10k/action/deploy/display.rb, line 41
def yaml_format(output)
  require 'yaml'
  puts output.to_yaml
end