Module: Ci::Metadatable

Extended by:
ActiveSupport::Concern
Included in:
Processable
Defined in:
app/models/concerns/ci/metadatable.rb

Overview

This module implements methods that need to read and write metadata for CI/CD entities.

Instance Method Summary collapse

Instance Method Details

#cancel_gracefully?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'app/models/concerns/ci/metadatable.rb', line 39

def cancel_gracefully?
  !!&.cancel_gracefully?
end

#degenerate!Object



51
52
53
54
55
56
57
# File 'app/models/concerns/ci/metadatable.rb', line 51

def degenerate!
  self.class.transaction do
    self.update!(options: nil, yaml_variables: nil)
    self.needs.all.delete_all
    self.&.destroy
  end
end

#degenerated?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'app/models/concerns/ci/metadatable.rb', line 47

def degenerated?
  self.options.blank?
end

#enqueue_immediately?Boolean

Returns:

  • (Boolean)


97
98
99
# File 'app/models/concerns/ci/metadatable.rb', line 97

def enqueue_immediately?
  !!options[:enqueue_immediately]
end

#ensure_metadataObject



43
44
45
# File 'app/models/concerns/ci/metadatable.rb', line 43

def 
   || (project: project)
end

#has_exposed_artifacts?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'app/models/concerns/ci/metadatable.rb', line 35

def has_exposed_artifacts?
  !!&.has_exposed_artifacts?
end

#id_tokens=(value) ⇒ Object



93
94
95
# File 'app/models/concerns/ci/metadatable.rb', line 93

def id_tokens=(value)
  .id_tokens = value
end

#id_tokens?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'app/models/concerns/ci/metadatable.rb', line 89

def id_tokens?
  &.id_tokens.present?
end

#interruptibleObject



81
82
83
# File 'app/models/concerns/ci/metadatable.rb', line 81

def interruptible
  &.interruptible
end

#interruptible=(value) ⇒ Object



85
86
87
# File 'app/models/concerns/ci/metadatable.rb', line 85

def interruptible=(value)
  .interruptible = value
end

#optionsObject



59
60
61
# File 'app/models/concerns/ci/metadatable.rb', line 59

def options
  (:options, :config_options, {})
end

#options=(value) ⇒ Object



67
68
69
70
71
72
73
74
75
# File 'app/models/concerns/ci/metadatable.rb', line 67

def options=(value)
  (:options, :config_options, value)

  .tap do ||
    # Store presence of exposed artifacts in build metadata to make it easier to query
    .has_exposed_artifacts = value&.dig(:artifacts, :expose_as).present?
    .environment_auto_stop_in = value&.dig(:environment, :auto_stop_in)
  end
end

#set_enqueue_immediately!Object



101
102
103
104
105
# File 'app/models/concerns/ci/metadatable.rb', line 101

def set_enqueue_immediately!
  # ensures that even if `config_options: nil` in the database we set the
  # new value correctly.
  self.options = options.merge(enqueue_immediately: true)
end

#yaml_variablesObject



63
64
65
# File 'app/models/concerns/ci/metadatable.rb', line 63

def yaml_variables
  (:yaml_variables, :config_variables, [])
end

#yaml_variables=(value) ⇒ Object



77
78
79
# File 'app/models/concerns/ci/metadatable.rb', line 77

def yaml_variables=(value)
  (:yaml_variables, :config_variables, value)
end