2018-09-11 10:26:57 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-09-08 06:09:14 -04:00
|
|
|
module Gitlab
|
|
|
|
module Ci
|
2018-10-16 09:09:36 -04:00
|
|
|
class Config
|
|
|
|
module External
|
|
|
|
module File
|
|
|
|
class Base
|
|
|
|
YAML_WHITELIST_EXTENSION = /(yml|yaml)$/i.freeze
|
2018-09-08 06:09:14 -04:00
|
|
|
|
2018-10-16 09:09:36 -04:00
|
|
|
def initialize(location, opts = {})
|
|
|
|
@location = location
|
|
|
|
end
|
2018-09-08 06:09:14 -04:00
|
|
|
|
2018-10-16 09:09:36 -04:00
|
|
|
def valid?
|
|
|
|
location.match(YAML_WHITELIST_EXTENSION) && content
|
|
|
|
end
|
2018-09-08 06:09:14 -04:00
|
|
|
|
2018-10-16 09:09:36 -04:00
|
|
|
def content
|
|
|
|
raise NotImplementedError, 'content must be implemented and return a string or nil'
|
|
|
|
end
|
2018-09-08 06:09:14 -04:00
|
|
|
|
2018-10-16 09:09:36 -04:00
|
|
|
def error_message
|
|
|
|
raise NotImplementedError, 'error_message must be implemented and return a string'
|
|
|
|
end
|
2018-09-08 06:09:14 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|