fix: normalize suppression keys in registry suppression methods
- commit
- 935f0d1eb531fa31816beb0676700293ccdfb392
- author
- brice · · 2026-03-04 08:59 UTC
- parent
- 3bec053
- signature
- unsigned
1 file · +15 -0
M internal/usecase/registry/service.go +15 -0
| @@ -54,6 +54,11 @@ func NewService( | |||
| 54 | 54 | // SuppressDeployEvent marks an image name to skip image.pushed events. | |
| 55 | 55 | // The suppression auto-expires after 2 minutes to prevent leaks. | |
| 56 | 56 | func (s *Service) SuppressDeployEvent(imageName string) { | |
| 57 | + | imageName = ExtractImageName(strings.TrimSpace(imageName)) | |
| 58 | + | if imageName == "" { | |
| 59 | + | return | |
| 60 | + | } | |
| 61 | + | ||
| 57 | 62 | var timer *time.Timer | |
| 58 | 63 | timer = time.AfterFunc(2*time.Minute, func() { | |
| 59 | 64 | // Only delete if this timer is still the current one, preventing an | |
| @@ -70,6 +75,11 @@ func (s *Service) SuppressDeployEvent(imageName string) { | |||
| 70 | 75 | ||
| 71 | 76 | // ClearDeployEventSuppression removes event suppression for an image. | |
| 72 | 77 | func (s *Service) ClearDeployEventSuppression(imageName string) { | |
| 78 | + | imageName = ExtractImageName(strings.TrimSpace(imageName)) | |
| 79 | + | if imageName == "" { | |
| 80 | + | return | |
| 81 | + | } | |
| 82 | + | ||
| 73 | 83 | if v, loaded := s.suppressedImages.LoadAndDelete(imageName); loaded { | |
| 74 | 84 | v.(*time.Timer).Stop() | |
| 75 | 85 | } | |
| @@ -111,6 +121,11 @@ func ExtractImageName(imageRef string) string { | |||
| 111 | 121 | ||
| 112 | 122 | // IsDeployEventSuppressed checks if deploy events are suppressed for an image. | |
| 113 | 123 | func (s *Service) IsDeployEventSuppressed(imageName string) bool { | |
| 124 | + | imageName = ExtractImageName(strings.TrimSpace(imageName)) | |
| 125 | + | if imageName == "" { | |
| 126 | + | return false | |
| 127 | + | } | |
| 128 | + | ||
| 114 | 129 | _, exists := s.suppressedImages.Load(imageName) | |
| 115 | 130 | return exists | |
| 116 | 131 | } | |
| @@ -54,6 +54,11 @@ func NewService( | |||||
| 54 | // SuppressDeployEvent marks an image name to skip image.pushed events. | 54 | // SuppressDeployEvent marks an image name to skip image.pushed events. | ||
| 55 | // The suppression auto-expires after 2 minutes to prevent leaks. | 55 | // The suppression auto-expires after 2 minutes to prevent leaks. | ||
| 56 | func (s *Service) SuppressDeployEvent(imageName string) { | 56 | func (s *Service) SuppressDeployEvent(imageName string) { | ||
| 57 | + | imageName = ExtractImageName(strings.TrimSpace(imageName)) | |||
| 58 | + | if imageName == "" { | |||
| 59 | + | return | |||
| 60 | + | } | |||
| 61 | + | ||||
| 57 | var timer *time.Timer | 62 | var timer *time.Timer | ||
| 58 | timer = time.AfterFunc(2*time.Minute, func() { | 63 | timer = time.AfterFunc(2*time.Minute, func() { | ||
| 59 | // Only delete if this timer is still the current one, preventing an | 64 | // Only delete if this timer is still the current one, preventing an | ||
| @@ -70,6 +75,11 @@ func (s *Service) SuppressDeployEvent(imageName string) { | |||||
| 70 | 75 | ||||
| 71 | // ClearDeployEventSuppression removes event suppression for an image. | 76 | // ClearDeployEventSuppression removes event suppression for an image. | ||
| 72 | func (s *Service) ClearDeployEventSuppression(imageName string) { | 77 | func (s *Service) ClearDeployEventSuppression(imageName string) { | ||
| 78 | + | imageName = ExtractImageName(strings.TrimSpace(imageName)) | |||
| 79 | + | if imageName == "" { | |||
| 80 | + | return | |||
| 81 | + | } | |||
| 82 | + | ||||
| 73 | if v, loaded := s.suppressedImages.LoadAndDelete(imageName); loaded { | 83 | if v, loaded := s.suppressedImages.LoadAndDelete(imageName); loaded { | ||
| 74 | v.(*time.Timer).Stop() | 84 | v.(*time.Timer).Stop() | ||
| 75 | } | 85 | } | ||
| @@ -111,6 +121,11 @@ func ExtractImageName(imageRef string) string { | |||||
| 111 | 121 | ||||
| 112 | // IsDeployEventSuppressed checks if deploy events are suppressed for an image. | 122 | // IsDeployEventSuppressed checks if deploy events are suppressed for an image. | ||
| 113 | func (s *Service) IsDeployEventSuppressed(imageName string) bool { | 123 | func (s *Service) IsDeployEventSuppressed(imageName string) bool { | ||
| 124 | + | imageName = ExtractImageName(strings.TrimSpace(imageName)) | |||
| 125 | + | if imageName == "" { | |||
| 126 | + | return false | |||
| 127 | + | } | |||
| 128 | + | ||||
| 114 | _, exists := s.suppressedImages.Load(imageName) | 129 | _, exists := s.suppressedImages.Load(imageName) | ||
| 115 | return exists | 130 | return exists | ||
| 116 | } | 131 | } | ||