Skip to content

Commit

Permalink
changed method to isGoogleArtifactRegistry
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Köttinger committed Mar 3, 2022
1 parent fec2590 commit 6c152e6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion trigger/pubsub/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (s *DefaultManager) scan(ctx context.Context) error {
}

for _, trackedImage := range trackedImages {
if !isGoogleContainerRegistry(trackedImage.Image.Registry()) {
if !isGoogleArtifactRegistry(trackedImage.Image.Registry()) {
log.Debugf("registry %s is not a GCR, skipping", trackedImage.Image.Registry())
continue
}
Expand Down
8 changes: 4 additions & 4 deletions trigger/pubsub/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ func getClusterName(metadataEndpoint string) (string, error) {
return string(body), nil
}

// isGoogleContainerRegistry - we only care about gcr.io and pkg.dev images,
// isGoogleArtifactRegistry - we only care about gcr.io and pkg.dev images,
// with other registries - we won't be able to receive events.
// Theoretically if someone publishes messages for updated images to
// google pubsub - we could turn this off
func isGoogleContainerRegistry(registry string) bool {
func isGoogleArtifactRegistry(registry string) bool {
matched, err := regexp.MatchString(`(gcr\.io|pkg\.dev)`, registry)
if err != nil {
log.WithFields(log.Fields{
"error": err,
}).Warn("trigger.pubsub.isGoogleContainerRegistry: got error while checking if registry is gcr")
}).Warn("trigger.pubsub.isGoogleArtifactRegistry: got error while checking if registry is gcr")
return false
}
return matched
}
}
4 changes: 2 additions & 2 deletions trigger/pubsub/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func Test_isGoogleContainerRegistry(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := isGoogleContainerRegistry(tt.args.registry); got != tt.want {
t.Errorf("isGoogleContainerRegistry() = %v, want %v", got, tt.want)
if got := isGoogleArtifactRegistry(tt.args.registry); got != tt.want {
t.Errorf("isGoogleArtifactRegistry() = %v, want %v", got, tt.want)
}
})
}
Expand Down

0 comments on commit 6c152e6

Please sign in to comment.