Class: Ci::PipelineCreation::PushOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/ci/pipeline_creation/push_options.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(push_options) ⇒ PushOptions

Returns a new instance of PushOptions.



18
19
20
# File 'lib/ci/pipeline_creation/push_options.rb', line 18

def initialize(push_options)
  @push_options = push_options&.deep_symbolize_keys || {}
end

Class Method Details

.fabricate(push_options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/ci/pipeline_creation/push_options.rb', line 6

def self.fabricate(push_options)
  if push_options.is_a?(self)
    push_options
  elsif push_options.is_a?(Hash)
    new(push_options)
  elsif push_options.blank?
    new({})
  else
    raise ArgumentError, 'Unknown type of push_option'
  end
end

Instance Method Details

#inputsObject



37
38
39
40
41
42
# File 'lib/ci/pipeline_creation/push_options.rb', line 37

def inputs
  raw_push_options_inputs = push_options.dig(:ci, :input)
  return {} unless raw_push_options_inputs

  extract_key_value_pairs_from_push_option(raw_push_options_inputs).to_h
end

#skips_ci?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/ci/pipeline_creation/push_options.rb', line 22

def skips_ci?
  push_options.dig(:ci, :skip).present?
end

#variablesObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/ci/pipeline_creation/push_options.rb', line 26

def variables
  raw_push_options_variables = push_options.dig(:ci, :variable)
  return [] unless raw_push_options_variables

  raw_vars = extract_key_value_pairs_from_push_option(raw_push_options_variables)

  raw_vars.map do |key, value|
    { "key" => key, "variable_type" => "env_var", "secret_value" => value }
  end
end