debian-mirror-gitlab/lib/gitlab/ci/config/external/file/local.rb
2019-02-13 22:33:31 +05:30

39 lines
898 B
Ruby

# frozen_string_literal: true
module Gitlab
module Ci
class Config
module External
module File
class Local < Base
include Gitlab::Utils::StrongMemoize
def initialize(params, context)
@location = params[:local]
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
context.project.repository.blob_data_at(context.sha, location)
end
end
end
end
end
end
end