Class: Vanagon::CLI::Build
- Inherits:
-
Vanagon::CLI
- Object
- Vanagon::CLI
- Vanagon::CLI::Build
- Defined in:
- lib/vanagon/cli/build.rb
Constant Summary collapse
- DOCUMENTATION =
<<~DOCOPT.freeze Usage: build [options] <project-name> <platforms> [<targets>] 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] -o, --only-build COMPONENT,COMPONENT,... Only build listed COMPONENTs -p, --preserve [RULE] Rule for VM preservation: never, on-failure, always [Default: always] -r, --remote-workdir DIRECTORY Working directory on the remote host -s, --skipcheck Skip the "check" stage when building components -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
- #options_translate(docopt_options) ⇒ Object
- #options_validate(options) ⇒ Object
- #parse(argv) ⇒ Object
-
#run(options) ⇒ Object
rubocop:disable Metrics/AbcSize.
Instance Method Details
#options_translate(docopt_options) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/vanagon/cli/build.rb', line 55 def () translations = { '--verbose' => :verbose, '--workdir' => :workdir, '--remote-workdir' => :"remote-workdir", '--configdir' => :configdir, '--engine' => :engine, '--skipcheck' => :skipcheck, '--preserve' => :preserve, '--only-build' => :only_build, '<project-name>' => :project_name, '<platforms>' => :platforms, '<targets>' => :targets } return .map { |k, v| [translations[k], v] }.to_h end |
#options_validate(options) ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/vanagon/cli/build.rb', line 72 def () # Handle --preserve option checking valid_preserves = %w[always never on-failure] unless valid_preserves.include? [:preserve] raise InvalidArgument, "--preserve option can only be one of: " + valid_preserves.join(', ') end [:preserve] = [:preserve].to_sym return end |
#parse(argv) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/vanagon/cli/build.rb', line 33 def parse(argv) Docopt.docopt(DOCUMENTATION, { argv: argv }) rescue Docopt::Exit => e VanagonLogger.error e. exit 1 end |
#run(options) ⇒ Object
rubocop:disable Metrics/AbcSize
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/vanagon/cli/build.rb', line 40 def run() # rubocop:disable Metrics/AbcSize project = [:project_name] platform_list = [:platforms].split(',') target_list = [] unless [:targets].nil? || [:targets].empty? target_list = [:targets].split(',') end platform_list.zip(target_list).each do |pair| platform, target = pair artifact = Vanagon::Driver.new(platform, project, .merge({ :target => target })) artifact.run end end |