summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/external/file/base.rb
blob: 4591b3ec82e71385c2b596c6a0c11b6f071c5711 (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
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