Class: RubyFly::Commands::SetPipeline

Inherits:
Base
  • Object
show all
Includes:
Mixins::Environment
Defined in:
lib/ruby_fly/commands/set_pipeline.rb

Instance Attribute Summary

Attributes inherited from Base

#binary

Instance Method Summary collapse

Methods included from Mixins::Environment

#for_environment, #initialize

Methods inherited from Base

#do_after, #do_before, #execute, #initialize, #instantiate_builder, #stderr, #stdin, #stdout

Instance Method Details

#configure_command(builder, opts) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/ruby_fly/commands/set_pipeline.rb', line 10

def configure_command(builder, opts)
  builder = super(builder, opts)

  missing_params = [
      :target,
      :pipeline,
      :config
  ].select { |param| opts[param].nil? }

  unless missing_params.empty?
    description = missing_params.map { |p| "'#{p}'" }.join(', ')
    raise(
        ArgumentError,
        "Error: #{description} required but not provided.")
  end

  target = opts[:target]
  pipeline = opts[:pipeline]
  config = opts[:config]
  vars = opts[:vars] || {}
  var_files = opts[:var_files] || []
  non_interactive = opts[:non_interactive]
  team = opts[:team]

  builder
    .with_subcommand('set-pipeline') do |sub|
      sub = sub.with_option('-t', target)
      sub = sub.with_option('-p', pipeline)
      sub = sub.with_option('-c', config)
      sub = sub.with_option('--team', team) if team
      vars.each do |key, value|
        sub = sub.with_option('-v', "'#{key}=#{value}'")
      end
      var_files.each do |var_file|
        sub = sub.with_option('-l', var_file)
      end
      sub = sub.with_flag('-n') if non_interactive
      sub
    end
end