Sha256: 6556b33cdbf679f56aba64ff9bd1921e08c0c7ffd7356a00668853a1799cf3b4

Contents?: true

Size: 1.35 KB

Versions: 7

Compression:

Stored size: 1.35 KB

Contents

require 'lino'
require_relative 'base'

module RubyFly
  module Commands
    class SetPipeline < Base
      def configure_command(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
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ruby_fly-0.23.0 lib/ruby_fly/commands/set_pipeline.rb
ruby_fly-0.22.0.pre.2 lib/ruby_fly/commands/set_pipeline.rb
ruby_fly-0.22.0.pre.1 lib/ruby_fly/commands/set_pipeline.rb
ruby_fly-0.21.0 lib/ruby_fly/commands/set_pipeline.rb
ruby_fly-0.20.0.pre.1 lib/ruby_fly/commands/set_pipeline.rb
ruby_fly-0.19.0 lib/ruby_fly/commands/set_pipeline.rb
ruby_fly-0.18.0.pre.1 lib/ruby_fly/commands/set_pipeline.rb