Module: Ci::Metadatable

Extended by:
ActiveSupport::Concern
Included in:
Bridge, Build
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

#degenerate!Object


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

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)

30
31
32
# File 'app/models/concerns/ci/metadatable.rb', line 30

def degenerated?
  self.options.blank?
end

#ensure_metadataObject


26
27
28
# File 'app/models/concerns/ci/metadatable.rb', line 26

def 
   || (project: project)
end

#interruptibleObject


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

def interruptible
  &.interruptible
end

#interruptible=(value) ⇒ Object


68
69
70
# File 'app/models/concerns/ci/metadatable.rb', line 68

def interruptible=(value)
  .interruptible = value
end

#optionsObject


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

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

#options=(value) ⇒ Object


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

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

#yaml_variablesObject


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

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

#yaml_variables=(value) ⇒ Object


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

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