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
- #cancel_gracefully? ⇒ Boolean
- #degenerate! ⇒ Object
- #degenerated? ⇒ Boolean
- #enqueue_immediately? ⇒ Boolean
- #ensure_metadata ⇒ Object
- #has_exposed_artifacts? ⇒ Boolean
- #id_tokens=(value) ⇒ Object
- #id_tokens? ⇒ Boolean
- #interruptible ⇒ Object
- #interruptible=(value) ⇒ Object
- #options ⇒ Object
- #options=(value) ⇒ Object
- #set_enqueue_immediately! ⇒ Object
- #yaml_variables ⇒ Object
- #yaml_variables=(value) ⇒ Object
Instance Method Details
#cancel_gracefully? ⇒ 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
47 48 49 |
# File 'app/models/concerns/ci/metadatable.rb', line 47 def degenerated? self..blank? end |
#enqueue_immediately? ⇒ Boolean
97 98 99 |
# File 'app/models/concerns/ci/metadatable.rb', line 97 def enqueue_immediately? !![:enqueue_immediately] end |
#ensure_metadata ⇒ Object
43 44 45 |
# File 'app/models/concerns/ci/metadatable.rb', line 43 def || (project: project) end |
#has_exposed_artifacts? ⇒ 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
89 90 91 |
# File 'app/models/concerns/ci/metadatable.rb', line 89 def id_tokens? &.id_tokens.present? end |
#interruptible ⇒ Object
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 |
#options ⇒ Object
59 60 61 |
# File 'app/models/concerns/ci/metadatable.rb', line 59 def (: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 (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. = .merge(enqueue_immediately: true) end |
#yaml_variables ⇒ Object
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 |