Class: Gitlab::Ci::Pipeline::Seed::Build::ResourceGroup

Inherits:
Gitlab::Ci::Pipeline::Seed::Base show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/ci/pipeline/seed/build/resource_group.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods inherited from Gitlab::Ci::Pipeline::Seed::Base

#attributes, #errors, #included?

Constructor Details

#initialize(build, resource_group_key) ⇒ ResourceGroup

Returns a new instance of ResourceGroup.


13
14
15
16
# File 'lib/gitlab/ci/pipeline/seed/build/resource_group.rb', line 13

def initialize(build, resource_group_key)
  @build = build
  @resource_group_key = resource_group_key
end

Instance Attribute Details

#buildObject (readonly)

Returns the value of attribute build


11
12
13
# File 'lib/gitlab/ci/pipeline/seed/build/resource_group.rb', line 11

def build
  @build
end

#resource_group_keyObject (readonly)

Returns the value of attribute resource_group_key


11
12
13
# File 'lib/gitlab/ci/pipeline/seed/build/resource_group.rb', line 11

def resource_group_key
  @resource_group_key
end

Instance Method Details

#to_resourceObject


18
19
20
21
22
23
24
25
# File 'lib/gitlab/ci/pipeline/seed/build/resource_group.rb', line 18

def to_resource
  return unless resource_group_key.present?

  resource_group = build.project.resource_groups
    .safe_find_or_create_by(key: expanded_resource_group_key)

  resource_group if resource_group.persisted?
end