Class: ContainerRegistry::Event

Inherits:
Object
  • Object
show all
Defined in:
app/models/container_registry/event.rb

Constant Summary collapse

ALLOWED_ACTIONS =
%w(push delete).freeze
PUSH_ACTION =
'push'
EVENT_TRACKING_CATEGORY =
'container_registry:notification'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event) ⇒ Event

Returns a new instance of Event.


11
12
13
# File 'app/models/container_registry/event.rb', line 11

def initialize(event)
  @event = event
end

Instance Attribute Details

#eventObject (readonly)

Returns the value of attribute event


9
10
11
# File 'app/models/container_registry/event.rb', line 9

def event
  @event
end

Instance Method Details

#handle!Object


19
20
21
# File 'app/models/container_registry/event.rb', line 19

def handle!
  # no op
end

#supported?Boolean

Returns:

  • (Boolean)

15
16
17
# File 'app/models/container_registry/event.rb', line 15

def supported?
  action.in?(ALLOWED_ACTIONS)
end

#track!Object


23
24
25
26
27
28
29
30
31
32
# File 'app/models/container_registry/event.rb', line 23

def track!
  tracked_target = target_tag? ? :tag : :repository
  tracking_action = "#{action}_#{tracked_target}"

  if target_repository? && action_push? && !container_repository_exists?
    tracking_action = "create_repository"
  end

  ::Gitlab::Tracking.event(EVENT_TRACKING_CATEGORY, tracking_action)
end