Class: Gitlab::Ci::Components::InstancePath
- Inherits:
-
Object
- Object
- Gitlab::Ci::Components::InstancePath
- Includes:
- LoopHelpers, Utils::StrongMemoize
- Defined in:
- lib/gitlab/ci/components/instance_path.rb
Constant Summary collapse
- SHORTHAND_SEMVER_PATTERN =
/^\d+(\.\d+)?$/- LATEST =
'~latest'
Instance Attribute Summary collapse
-
#component_name ⇒ Object
readonly
Returns the value of attribute component_name.
-
#reference ⇒ Object
readonly
Returns the value of attribute reference.
Class Method Summary collapse
Instance Method Summary collapse
- #fetch_content!(current_user:) ⇒ Object
-
#initialize(address:) ⇒ InstancePath
constructor
A new instance of InstancePath.
- #invalid_usage_for_latest? ⇒ Boolean
- #invalid_usage_for_partial_semver? ⇒ Boolean
- #matched_version ⇒ Object
- #project ⇒ Object
- #sha ⇒ Object
Methods included from LoopHelpers
Constructor Details
#initialize(address:) ⇒ InstancePath
Returns a new instance of InstancePath.
23 24 25 |
# File 'lib/gitlab/ci/components/instance_path.rb', line 23 def initialize(address:) @full_path, @reference = address.to_s.split('@', 2) end |
Instance Attribute Details
#component_name ⇒ Object (readonly)
Returns the value of attribute component_name.
10 11 12 |
# File 'lib/gitlab/ci/components/instance_path.rb', line 10 def component_name @component_name end |
#reference ⇒ Object (readonly)
Returns the value of attribute reference.
10 11 12 |
# File 'lib/gitlab/ci/components/instance_path.rb', line 10 def reference @reference end |
Class Method Details
.fqdn_prefix ⇒ Object
19 20 21 |
# File 'lib/gitlab/ci/components/instance_path.rb', line 19 def self.fqdn_prefix "#{Gitlab.config.gitlab.server_fqdn}/" end |
.match?(address) ⇒ Boolean
15 16 17 |
# File 'lib/gitlab/ci/components/instance_path.rb', line 15 def self.match?(address) address.include?('@') && address.start_with?(fqdn_prefix) end |
Instance Method Details
#fetch_content!(current_user:) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/gitlab/ci/components/instance_path.rb', line 27 def fetch_content!(current_user:) return unless project return unless sha raise Gitlab::Access::AccessDeniedError unless Ability.allowed?(current_user, :download_code, project) component_project = ::Ci::Catalog::ComponentsProject.new(project, sha) component_project.fetch_component(component_name) end |
#invalid_usage_for_latest? ⇒ Boolean
54 55 56 |
# File 'lib/gitlab/ci/components/instance_path.rb', line 54 def invalid_usage_for_latest? reference == LATEST && project && project.catalog_resource.nil? end |
#invalid_usage_for_partial_semver? ⇒ Boolean
58 59 60 |
# File 'lib/gitlab/ci/components/instance_path.rb', line 58 def invalid_usage_for_partial_semver? reference.match?(SHORTHAND_SEMVER_PATTERN) && project && project.catalog_resource.nil? end |
#matched_version ⇒ Object
49 50 51 |
# File 'lib/gitlab/ci/components/instance_path.rb', line 49 def matched_version find_catalog_version&.semver&.to_s end |
#project ⇒ Object
37 38 39 |
# File 'lib/gitlab/ci/components/instance_path.rb', line 37 def project find_project_by_component_path(instance_path) end |
#sha ⇒ Object
42 43 44 45 46 |
# File 'lib/gitlab/ci/components/instance_path.rb', line 42 def sha return unless project find_version_sha end |