Class: ContainerRegistry::Event
- Inherits:
-
Object
- Object
- ContainerRegistry::Event
- Includes:
- Gitlab::Utils::StrongMemoize
- Defined in:
- app/models/container_registry/event.rb
Constant Summary collapse
- ALLOWED_ACTIONS =
%w[push delete].freeze
- PUSH_ACTION =
'push'
- DELETE_ACTION =
'delete'
- EVENT_TRACKING_CATEGORY =
'container_registry:notification'
- EVENT_PREFIX =
'i_container_registry'
- ALLOWED_ACTOR_TYPES =
%w[ personal_access_token build gitlab_or_ldap ].freeze
- TRACKABLE_ACTOR_EVENTS =
%w[ push_tag delete_tag push_repository delete_repository create_repository ].freeze
Instance Attribute Summary collapse
-
#event ⇒ Object
readonly
Returns the value of attribute event.
Instance Method Summary collapse
- #handle! ⇒ Object
-
#initialize(event) ⇒ Event
constructor
A new instance of Event.
- #supported? ⇒ Boolean
- #track! ⇒ Object
Constructor Details
#initialize(event) ⇒ Event
Returns a new instance of Event.
29 30 31 |
# File 'app/models/container_registry/event.rb', line 29 def initialize(event) @event = event end |
Instance Attribute Details
#event ⇒ Object (readonly)
Returns the value of attribute event.
27 28 29 |
# File 'app/models/container_registry/event.rb', line 27 def event @event end |
Instance Method Details
#handle! ⇒ Object
37 38 39 |
# File 'app/models/container_registry/event.rb', line 37 def handle! update_project_statistics end |
#supported? ⇒ Boolean
33 34 35 |
# File 'app/models/container_registry/event.rb', line 33 def supported? action.in?(ALLOWED_ACTIONS) end |
#track! ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/models/container_registry/event.rb', line 41 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) if manifest_delete_event? ::Gitlab::UsageDataCounters::ContainerRegistryEventCounter.count("#{EVENT_PREFIX}_delete_manifest") else event = usage_data_event_for(tracking_action) ::Gitlab::UsageDataCounters::HLLRedisCounter.track_event(event, values: originator.id) if event end end |