summaryrefslogtreecommitdiff
path: root/lib/gitlab/static_site_editor/config/file_config/entry/mount.rb
blob: b10956e17a559ce04e9bb0b5341c65c2aefc1258 (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
30
31
32
33
34
35
36
37
38
39
# frozen_string_literal: true

module Gitlab
  module StaticSiteEditor
    module Config
      class FileConfig
        module Entry
          ##
          # Entry that represents the mappings of mounted source directories to target paths
          #
          class Mount < ::Gitlab::Config::Entry::Node
            include ::Gitlab::Config::Entry::Validatable
            include ::Gitlab::Config::Entry::Attributable

            ALLOWED_KEYS = %i[source target].freeze

            attributes ALLOWED_KEYS

            validations do
              validates :config, allowed_keys: ALLOWED_KEYS

              validates :source, type: String, presence: true
              validates :target, type: String, presence: true, allow_blank: true
            end

            def self.default
              # NOTE: This is the default for middleman projects.  Ideally, this would be determined
              #       based on the defaults for whatever `static_site_generator` is configured.
              {
                source: 'source',
                target: ''
              }
            end
          end
        end
      end
    end
  end
end