summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/config/external/file/base.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/ci/config/external/file/base.rb')
-rw-r--r--lib/gitlab/ci/config/external/file/base.rb61
1 files changed, 21 insertions, 40 deletions
diff --git a/lib/gitlab/ci/config/external/file/base.rb b/lib/gitlab/ci/config/external/file/base.rb
index 7899fe0ff73..84f34f2584b 100644
--- a/lib/gitlab/ci/config/external/file/base.rb
+++ b/lib/gitlab/ci/config/external/file/base.rb
@@ -46,13 +46,6 @@ module Gitlab
expanded_content_hash
end
- def validate!
- validate_location!
- validate_context! if valid?
- fetch_and_validate_content! if valid?
- load_and_validate_expanded_hash! if valid?
- end
-
def metadata
{
context_project: context.project&.full_path,
@@ -68,22 +61,16 @@ module Gitlab
[params, context.project&.full_path, context.sha].hash
end
- protected
-
- def expanded_content_hash
- return unless content_hash
-
- strong_memoize(:expanded_content_yaml) do
- expand_includes(content_hash)
+ def load_and_validate_expanded_hash!
+ context.logger.instrument(:config_file_fetch_content_hash) do
+ content_hash # calling the method loads then memoizes the result
end
- end
- def content_hash
- strong_memoize(:content_yaml) do
- ::Gitlab::Ci::Config::Yaml.load!(content)
+ context.logger.instrument(:config_file_expand_content_includes) do
+ expanded_content_hash # calling the method expands then memoizes the result
end
- rescue Gitlab::Config::Loader::FormatError
- nil
+
+ validate_hash!
end
def validate_location!
@@ -98,34 +85,28 @@ module Gitlab
raise NotImplementedError, 'subclass must implement validate_context'
end
- def fetch_and_validate_content!
- context.logger.instrument(:config_file_fetch_content) do
- content # calling the method fetches then memoizes the result
- end
-
- return if errors.any?
-
- context.logger.instrument(:config_file_validate_content) do
- validate_content!
+ def validate_content!
+ if content.blank?
+ errors.push("Included file `#{masked_location}` is empty or does not exist!")
end
end
- def load_and_validate_expanded_hash!
- context.logger.instrument(:config_file_fetch_content_hash) do
- content_hash # calling the method loads then memoizes the result
- end
+ protected
- context.logger.instrument(:config_file_expand_content_includes) do
- expanded_content_hash # calling the method expands then memoizes the result
- end
+ def expanded_content_hash
+ return unless content_hash
- validate_hash!
+ strong_memoize(:expanded_content_hash) do
+ expand_includes(content_hash)
+ end
end
- def validate_content!
- if content.blank?
- errors.push("Included file `#{masked_location}` is empty or does not exist!")
+ def content_hash
+ strong_memoize(:content_hash) do
+ ::Gitlab::Ci::Config::Yaml.load!(content)
end
+ rescue Gitlab::Config::Loader::FormatError
+ nil
end
def validate_hash!