Class: Gitlab::Ci::Config::External::File::Local
- Extended by:
- Utils::Override
- Includes:
- Utils::StrongMemoize
- Defined in:
- lib/gitlab/ci/config/external/file/local.rb
Constant Summary
Constants inherited from Base
Base::YAML_WHITELIST_EXTENSION
Instance Attribute Summary
Attributes inherited from Base
#context, #errors, #location, #params
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(params, context) ⇒ Local
constructor
A new instance of Local.
- #metadata ⇒ Object
- #validate_content! ⇒ Object
- #validate_context! ⇒ Object
Methods included from Utils::Override
extended, extensions, included, method_added, override, prepended, queue_verification, verify!
Methods inherited from Base
#eql?, #error_message, #hash, #invalid_extension?, #invalid_location_type?, #load_and_validate_expanded_hash!, #matching?, #preload_content, #preload_context, #to_hash, #valid?, #validate_location!
Constructor Details
#initialize(params, context) ⇒ Local
Returns a new instance of Local.
12 13 14 15 16 17 |
# File 'lib/gitlab/ci/config/external/file/local.rb', line 12 def initialize(params, context) # `Repository#blobs_at` does not support files with the `/` prefix. @location = Gitlab::Utils.remove_leading_slashes(params[:local]) super end |
Instance Method Details
#content ⇒ Object
19 20 21 |
# File 'lib/gitlab/ci/config/external/file/local.rb', line 19 def content strong_memoize(:content) { fetch_local_content } end |
#metadata ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/gitlab/ci/config/external/file/local.rb', line 23 def super.merge( type: :local, location: masked_location, blob: masked_blob, raw: masked_raw, extra: {} ) end |
#validate_content! ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/gitlab/ci/config/external/file/local.rb', line 39 def validate_content! if content.nil? errors.push("Local file `#{masked_location}` does not exist!") elsif content.blank? errors.push("Local file `#{masked_location}` is empty!") end end |
#validate_context! ⇒ Object
33 34 35 36 37 |
# File 'lib/gitlab/ci/config/external/file/local.rb', line 33 def validate_context! return if context.project&.repository errors.push("Local file `#{masked_location}` does not have project!") end |