summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/pipeline/chain/config/content/source.rb
blob: 69dca1568b65d2c3c1274bc349903ba64590f533 (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
40
41
42
43
44
45
46
47
48
49
# frozen_string_literal: true

module Gitlab
  module Ci
    module Pipeline
      module Chain
        module Config
          class Content
            # When removing ci_project_pipeline_config_refactoring, this and its subclasses will be removed.
            class Source
              include Gitlab::Utils::StrongMemoize

              DEFAULT_YAML_FILE = '.gitlab-ci.yml'

              attr_reader :command

              def initialize(pipeline, command)
                @pipeline = pipeline
                @command = command
              end

              def exists?
                strong_memoize(:exists) do
                  content.present?
                end
              end

              def content
                raise NotImplementedError
              end

              def source
                raise NotImplementedError
              end

              def project
                @project ||= @pipeline.project
              end

              def ci_config_path
                @ci_config_path ||= project.ci_config_path.presence || DEFAULT_YAML_FILE
              end
            end
          end
        end
      end
    end
  end
end