2020-06-23 00:09:42 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
module Build
|
|
|
|
class Releaser
|
|
|
|
BASE_COMMAND = 'release-cli create'
|
2020-07-28 23:09:34 +05:30
|
|
|
SINGLE_FLAGS = %i[name description tag_name ref released_at].freeze
|
|
|
|
ARRAY_FLAGS = %i[milestones].freeze
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
attr_reader :config
|
|
|
|
|
|
|
|
def initialize(config:)
|
|
|
|
@config = config
|
|
|
|
end
|
|
|
|
|
|
|
|
def script
|
|
|
|
command = BASE_COMMAND.dup
|
2020-07-28 23:09:34 +05:30
|
|
|
single_flags.each { |k, v| command.concat(" --#{k.to_s.dasherize} \"#{v}\"") }
|
|
|
|
array_commands.each { |k, v| v.each { |elem| command.concat(" --#{k.to_s.singularize.dasherize} \"#{elem}\"") } }
|
2020-06-23 00:09:42 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
[command]
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def single_flags
|
|
|
|
config.slice(*SINGLE_FLAGS)
|
|
|
|
end
|
|
|
|
|
|
|
|
def array_commands
|
|
|
|
config.slice(*ARRAY_FLAGS)
|
2020-06-23 00:09:42 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|