summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/external/file/base.rb
blob: f4da07b0b02aa4a8e4803b2e97fed7e32c102c20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

module Gitlab
  module Ci
    module External
      module File
        class Base
          YAML_WHITELIST_EXTENSION = /(yml|yaml)$/i.freeze

          def initialize(location, opts = {})
            @location = location
          end

          def valid?
            location.match(YAML_WHITELIST_EXTENSION) && content
          end

          def content
            raise NotImplementedError, 'content must be implemented and return a string or nil'
          end

          def error_message
            raise NotImplementedError, 'error_message must be implemented and return a string'
          end
        end
      end
    end
  end
end