Class: Gitlab::Ci::Components::InstancePath
- Inherits:
-
Object
- Object
- Gitlab::Ci::Components::InstancePath
- Includes:
- Utils::StrongMemoize
- Defined in:
- lib/gitlab/ci/components/instance_path.rb
Constant Summary collapse
- LATEST_VERSION_KEYWORD =
'~latest'
- TEMPLATES_DIR =
'templates'
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#project_file_path ⇒ Object
readonly
Returns the value of attribute project_file_path.
Class Method Summary collapse
Instance Method Summary collapse
- #fetch_content!(current_user:) ⇒ Object
-
#initialize(address:, content_filename:) ⇒ InstancePath
constructor
A new instance of InstancePath.
- #project ⇒ Object
- #sha ⇒ Object
Constructor Details
#initialize(address:, content_filename:) ⇒ InstancePath
Returns a new instance of InstancePath.
18 19 20 21 22 23 |
# File 'lib/gitlab/ci/components/instance_path.rb', line 18 def initialize(address:, content_filename:) @full_path, @version = address.to_s.split('@', 2) @content_filename = content_filename @host = Settings.gitlab_ci['component_fqdn'] @project_file_path = nil end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
16 17 18 |
# File 'lib/gitlab/ci/components/instance_path.rb', line 16 def host @host end |
#project_file_path ⇒ Object (readonly)
Returns the value of attribute project_file_path.
16 17 18 |
# File 'lib/gitlab/ci/components/instance_path.rb', line 16 def project_file_path @project_file_path end |
Class Method Details
.match?(address) ⇒ Boolean
12 13 14 |
# File 'lib/gitlab/ci/components/instance_path.rb', line 12 def self.match?(address) address.include?('@') && address.start_with?(Settings.gitlab_ci['component_fqdn']) end |
Instance Method Details
#fetch_content!(current_user:) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/gitlab/ci/components/instance_path.rb', line 25 def fetch_content!(current_user:) return unless project return unless sha raise Gitlab::Access::AccessDeniedError unless Ability.allowed?(current_user, :download_code, project) content(simple_template_path) || content(complex_template_path) || content(legacy_template_path) end |
#project ⇒ Object
34 35 36 |
# File 'lib/gitlab/ci/components/instance_path.rb', line 34 def project find_project_by_component_path(instance_path) end |
#sha ⇒ Object
39 40 41 42 43 44 |
# File 'lib/gitlab/ci/components/instance_path.rb', line 39 def sha return unless project return latest_version_sha if version == LATEST_VERSION_KEYWORD project.commit(version)&.id end |