diff --git a/cmd/registry/config-cache.yml b/cmd/registry/config-cache.yml index f7e47b82..d648303d 100644 --- a/cmd/registry/config-cache.yml +++ b/cmd/registry/config-cache.yml @@ -30,7 +30,7 @@ redis: writetimeout: 10ms notifications: events: - manifestlayers: true + includereferences: true endpoints: - name: local-8082 url: http://localhost:5003/callback diff --git a/cmd/registry/config-dev.yml b/cmd/registry/config-dev.yml index 25002569..9539bae4 100644 --- a/cmd/registry/config-dev.yml +++ b/cmd/registry/config-dev.yml @@ -48,7 +48,7 @@ redis: writetimeout: 10ms notifications: events: - manifestlayers: true + includereferences: true endpoints: - name: local-5003 url: http://localhost:5003/callback diff --git a/configuration/configuration.go b/configuration/configuration.go index 59841382..0b5b46aa 100644 --- a/configuration/configuration.go +++ b/configuration/configuration.go @@ -568,7 +568,7 @@ type Endpoint struct { // Events configures notification events. type Events struct { - ManifestLayers bool `yaml:"manifestlayers"` // include layer data in manifest events + IncludeReferences bool `yaml:"includereferences"` // include reference data in manifest events } //Ignore configures mediaTypes and actions of the event, that it won't be propagated diff --git a/docs/configuration.md b/docs/configuration.md index 7a6b9b2c..3f346439 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -227,7 +227,7 @@ http: disabled: false notifications: events: - manifestlayers: true + includereferences: true endpoints: - name: alistener disabled: false @@ -856,7 +856,7 @@ settings for the registry. ```none notifications: events: - manifestlayers: true + includereferences: true endpoints: - name: alistener disabled: false @@ -906,7 +906,7 @@ The `events` structure configures the information provided in event notification | Parameter | Required | Description | |-----------|----------|-------------------------------------------------------| -| `manifestlayers` | no | If `true`, include layer information in manifest events. | +| `includereferences` | no | If `true`, include reference information in manifest events. | ## `redis` diff --git a/notifications/bridge.go b/notifications/bridge.go index 1a58c2bb..efc73f68 100644 --- a/notifications/bridge.go +++ b/notifications/bridge.go @@ -12,12 +12,12 @@ import ( ) type bridge struct { - ub URLBuilder - manifestLayers bool - actor ActorRecord - source SourceRecord - request RequestRecord - sink Sink + ub URLBuilder + includeReferences bool + actor ActorRecord + source SourceRecord + request RequestRecord + sink Sink } var _ Listener = &bridge{} @@ -32,14 +32,14 @@ type URLBuilder interface { // using the actor and source. Any urls populated in the events created by // this bridge will be created using the URLBuilder. // TODO(stevvooe): Update this to simply take a context.Context object. -func NewBridge(ub URLBuilder, source SourceRecord, actor ActorRecord, request RequestRecord, sink Sink, manifestLayers bool) Listener { +func NewBridge(ub URLBuilder, source SourceRecord, actor ActorRecord, request RequestRecord, sink Sink, includeReferences bool) Listener { return &bridge{ - ub: ub, - manifestLayers: manifestLayers, - actor: actor, - source: source, - request: request, - sink: sink, + ub: ub, + includeReferences: includeReferences, + actor: actor, + source: source, + request: request, + sink: sink, } } @@ -146,8 +146,8 @@ func (b *bridge) createManifestEvent(action string, repo reference.Named, sm dis event.Target.Length = desc.Size event.Target.Size = desc.Size event.Target.Digest = desc.Digest - if b.manifestLayers { - event.Target.Layers = append(event.Target.Layers, manifest.References()...) + if b.includeReferences { + event.Target.References = append(event.Target.References, manifest.References()...) } ref, err := reference.WithDigest(repo, event.Target.Digest) diff --git a/notifications/bridge_test.go b/notifications/bridge_test.go index cdf500c3..87c868a5 100644 --- a/notifications/bridge_test.go +++ b/notifications/bridge_test.go @@ -180,12 +180,12 @@ func checkCommonManifest(t *testing.T, action string, events ...Event) { t.Fatalf("incorrect url passed: \n%q != \n%q", event.Target.URL, u) } - if len(event.Target.Layers) != len(layers) { - t.Fatalf("unexpected number of layers %v != %v", len(event.Target.Layers), len(layers)) + if len(event.Target.References) != len(layers) { + t.Fatalf("unexpected number of references %v != %v", len(event.Target.References), len(layers)) } - for i, layer := range event.Target.Layers { - if layer.Digest != layers[i].BlobSum { - t.Fatalf("unexpected layer: %q != %q", layer.Digest, layers[i].BlobSum) + for i, targetReference := range event.Target.References { + if targetReference.Digest != layers[i].BlobSum { + t.Fatalf("unexpected reference: %q != %q", targetReference.Digest, layers[i].BlobSum) } } } diff --git a/notifications/event.go b/notifications/event.go index ab74c675..54940a46 100644 --- a/notifications/event.go +++ b/notifications/event.go @@ -72,8 +72,8 @@ type Event struct { // Tag provides the tag Tag string `json:"tag,omitempty"` - // Layers provides the layers descriptors. - Layers []distribution.Descriptor `json:"layers,omitempty"` + // References provides the references descriptors. + References []distribution.Descriptor `json:"references,omitempty"` } `json:"target,omitempty"` // Request covers the request that generated the event. diff --git a/registry/handlers/app.go b/registry/handlers/app.go index 8ccfffe5..8c1f18e6 100644 --- a/registry/handlers/app.go +++ b/registry/handlers/app.go @@ -869,7 +869,7 @@ func (app *App) eventBridge(ctx *Context, r *http.Request) notifications.Listene } request := notifications.NewRequestRecord(dcontext.GetRequestID(ctx), r) - return notifications.NewBridge(ctx.urlBuilder, app.events.source, actor, request, app.events.sink, app.Config.Notifications.EventConfig.ManifestLayers) + return notifications.NewBridge(ctx.urlBuilder, app.events.source, actor, request, app.events.sink, app.Config.Notifications.EventConfig.IncludeReferences) } // nameRequired returns true if the route requires a name.