2018-12-13 13:39:08 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
class Config
|
|
|
|
module External
|
|
|
|
module File
|
|
|
|
class Local < Base
|
|
|
|
include Gitlab::Utils::StrongMemoize
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
def initialize(params, context)
|
|
|
|
@location = params[:local]
|
2018-12-13 13:39:08 +05:30
|
|
|
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def content
|
|
|
|
strong_memoize(:content) { fetch_local_content }
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def validate_content!
|
|
|
|
if content.nil?
|
|
|
|
errors.push("Local file `#{location}` does not exist!")
|
|
|
|
elsif content.blank?
|
|
|
|
errors.push("Local file `#{location}` is empty!")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def fetch_local_content
|
2019-02-15 15:39:39 +05:30
|
|
|
context.project.repository.blob_data_at(context.sha, location)
|
2018-12-13 13:39:08 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|