Class: Vanagon::CLI::Render

Inherits:
Vanagon::CLI show all
Defined in:
lib/vanagon/cli/render.rb

Constant Summary collapse

DOCUMENTATION =
<<~DOCOPT.freeze
  Usage:
  render [options] <project-name> <platforms>

  Options:
    -h, --help                       Display help
    -c, --configdir DIRECTORY        Configuration directory [default: #{Dir.pwd}/configs]
    -e, --engine ENGINE              Custom engine to use [default: always_be_scheduling]
    -w, --workdir DIRECTORY          Working directory on the local host
    -v, --verbose                    Only here for backwards compatibility. Does nothing.

  Engines:
    always_be_scheduling: default engine using Puppet's ABS infrastructure
    docker: a docker container on the local host
    ec2: an Amazon EC2 instance
    hardware: a dedicated hardware device
    local: the local machine, cannot be used with a target
    pooler: [deprecated] Puppet's vmpooler
DOCOPT

Instance Method Summary collapse

Methods inherited from Vanagon::CLI

#options_validate

Instance Method Details

#options_translate(docopt_options) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/vanagon/cli/render.rb', line 47

def options_translate(docopt_options)
  translations = {
    '--verbose' => :verbose,
    '--workdir' => :workdir,
    '--configdir' => :configdir,
    '--engine' => :engine,
    '<project-name>' => :project_name,
    '<platforms>' => :platforms,
  }
  return docopt_options.map { |k, v| [translations[k], v] }.to_h
end

#parse(argv) ⇒ Object



28
29
30
31
32
33
# File 'lib/vanagon/cli/render.rb', line 28

def parse(argv)
  Docopt.docopt(DOCUMENTATION, { argv: argv })
rescue Docopt::Exit => e
  VanagonLogger.error e.message
  exit 1
end

#run(options) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/vanagon/cli/render.rb', line 35

def run(options)
  platforms = options[:platforms].split(',')
  project = options[:project_name]
  target_list = []

  platforms.zip(target_list).each do |pair|
    platform, target = pair
    artifact = Vanagon::Driver.new(platform, project, options.merge({ :target => target }))
    artifact.render
  end
end