Class: ContainerRegistry::Event
- Inherits:
-
Object
- Object
- ContainerRegistry::Event
- Includes:
- Gitlab::InternalEventsTracking, 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_PREFIX =
'i_container_registry'- ALLOWED_ACTOR_TYPES =
%w[ personal_access_token build gitlab_or_ldap deploy_token ].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
Methods included from Gitlab::InternalEventsTracking
Constructor Details
#initialize(event) ⇒ Event
Returns a new instance of Event.
30 31 32 |
# File 'app/models/container_registry/event.rb', line 30 def initialize(event) @event = event end |
Instance Attribute Details
#event ⇒ Object (readonly)
Returns the value of attribute event.
28 29 30 |
# File 'app/models/container_registry/event.rb', line 28 def event @event end |
Instance Method Details
#handle! ⇒ Object
38 39 40 |
# File 'app/models/container_registry/event.rb', line 38 def handle! update_project_statistics end |
#supported? ⇒ Boolean
34 35 36 |
# File 'app/models/container_registry/event.rb', line 34 def supported? action.in?(ALLOWED_ACTIONS) end |
#track! ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/models/container_registry/event.rb', line 42 def track! tracking_action = "#{action}_#{tracked_target}" if target_repository? && action_push? && !container_repository_exists? tracking_action = "create_repository" end context = { project: project, namespace: project&.namespace } context[:user] = originator if originator.is_a?(User) if manifest_delete_event? track_internal_event("delete_manifest_from_container_registry", context) else event = usage_data_event_for(tracking_action) return unless event if originator.is_a?(DeployToken) context[:additional_properties] = { property: originator.id.to_s } end track_internal_event(event, context) end end |