Use references terminology instead of layers.
Signed-off-by: Andrew Leung <anwleung@gmail.com>
This commit is contained in:
parent
54aef6251e
commit
5e4b81a578
8 changed files with 29 additions and 29 deletions
|
@ -30,7 +30,7 @@ redis:
|
||||||
writetimeout: 10ms
|
writetimeout: 10ms
|
||||||
notifications:
|
notifications:
|
||||||
events:
|
events:
|
||||||
manifestlayers: true
|
includereferences: true
|
||||||
endpoints:
|
endpoints:
|
||||||
- name: local-8082
|
- name: local-8082
|
||||||
url: http://localhost:5003/callback
|
url: http://localhost:5003/callback
|
||||||
|
|
|
@ -48,7 +48,7 @@ redis:
|
||||||
writetimeout: 10ms
|
writetimeout: 10ms
|
||||||
notifications:
|
notifications:
|
||||||
events:
|
events:
|
||||||
manifestlayers: true
|
includereferences: true
|
||||||
endpoints:
|
endpoints:
|
||||||
- name: local-5003
|
- name: local-5003
|
||||||
url: http://localhost:5003/callback
|
url: http://localhost:5003/callback
|
||||||
|
|
|
@ -568,7 +568,7 @@ type Endpoint struct {
|
||||||
|
|
||||||
// Events configures notification events.
|
// Events configures notification events.
|
||||||
type Events struct {
|
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
|
//Ignore configures mediaTypes and actions of the event, that it won't be propagated
|
||||||
|
|
|
@ -227,7 +227,7 @@ http:
|
||||||
disabled: false
|
disabled: false
|
||||||
notifications:
|
notifications:
|
||||||
events:
|
events:
|
||||||
manifestlayers: true
|
includereferences: true
|
||||||
endpoints:
|
endpoints:
|
||||||
- name: alistener
|
- name: alistener
|
||||||
disabled: false
|
disabled: false
|
||||||
|
@ -856,7 +856,7 @@ settings for the registry.
|
||||||
```none
|
```none
|
||||||
notifications:
|
notifications:
|
||||||
events:
|
events:
|
||||||
manifestlayers: true
|
includereferences: true
|
||||||
endpoints:
|
endpoints:
|
||||||
- name: alistener
|
- name: alistener
|
||||||
disabled: false
|
disabled: false
|
||||||
|
@ -906,7 +906,7 @@ The `events` structure configures the information provided in event notification
|
||||||
|
|
||||||
| Parameter | Required | Description |
|
| Parameter | Required | Description |
|
||||||
|-----------|----------|-------------------------------------------------------|
|
|-----------|----------|-------------------------------------------------------|
|
||||||
| `manifestlayers` | no | If `true`, include layer information in manifest events. |
|
| `includereferences` | no | If `true`, include reference information in manifest events. |
|
||||||
|
|
||||||
## `redis`
|
## `redis`
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
|
|
||||||
type bridge struct {
|
type bridge struct {
|
||||||
ub URLBuilder
|
ub URLBuilder
|
||||||
manifestLayers bool
|
includeReferences bool
|
||||||
actor ActorRecord
|
actor ActorRecord
|
||||||
source SourceRecord
|
source SourceRecord
|
||||||
request RequestRecord
|
request RequestRecord
|
||||||
|
@ -32,10 +32,10 @@ type URLBuilder interface {
|
||||||
// using the actor and source. Any urls populated in the events created by
|
// using the actor and source. Any urls populated in the events created by
|
||||||
// this bridge will be created using the URLBuilder.
|
// this bridge will be created using the URLBuilder.
|
||||||
// TODO(stevvooe): Update this to simply take a context.Context object.
|
// 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{
|
return &bridge{
|
||||||
ub: ub,
|
ub: ub,
|
||||||
manifestLayers: manifestLayers,
|
includeReferences: includeReferences,
|
||||||
actor: actor,
|
actor: actor,
|
||||||
source: source,
|
source: source,
|
||||||
request: request,
|
request: request,
|
||||||
|
@ -146,8 +146,8 @@ func (b *bridge) createManifestEvent(action string, repo reference.Named, sm dis
|
||||||
event.Target.Length = desc.Size
|
event.Target.Length = desc.Size
|
||||||
event.Target.Size = desc.Size
|
event.Target.Size = desc.Size
|
||||||
event.Target.Digest = desc.Digest
|
event.Target.Digest = desc.Digest
|
||||||
if b.manifestLayers {
|
if b.includeReferences {
|
||||||
event.Target.Layers = append(event.Target.Layers, manifest.References()...)
|
event.Target.References = append(event.Target.References, manifest.References()...)
|
||||||
}
|
}
|
||||||
|
|
||||||
ref, err := reference.WithDigest(repo, event.Target.Digest)
|
ref, err := reference.WithDigest(repo, event.Target.Digest)
|
||||||
|
|
|
@ -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)
|
t.Fatalf("incorrect url passed: \n%q != \n%q", event.Target.URL, u)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(event.Target.Layers) != len(layers) {
|
if len(event.Target.References) != len(layers) {
|
||||||
t.Fatalf("unexpected number of layers %v != %v", len(event.Target.Layers), len(layers))
|
t.Fatalf("unexpected number of references %v != %v", len(event.Target.References), len(layers))
|
||||||
}
|
}
|
||||||
for i, layer := range event.Target.Layers {
|
for i, targetReference := range event.Target.References {
|
||||||
if layer.Digest != layers[i].BlobSum {
|
if targetReference.Digest != layers[i].BlobSum {
|
||||||
t.Fatalf("unexpected layer: %q != %q", layer.Digest, layers[i].BlobSum)
|
t.Fatalf("unexpected reference: %q != %q", targetReference.Digest, layers[i].BlobSum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,8 +72,8 @@ type Event struct {
|
||||||
// Tag provides the tag
|
// Tag provides the tag
|
||||||
Tag string `json:"tag,omitempty"`
|
Tag string `json:"tag,omitempty"`
|
||||||
|
|
||||||
// Layers provides the layers descriptors.
|
// References provides the references descriptors.
|
||||||
Layers []distribution.Descriptor `json:"layers,omitempty"`
|
References []distribution.Descriptor `json:"references,omitempty"`
|
||||||
} `json:"target,omitempty"`
|
} `json:"target,omitempty"`
|
||||||
|
|
||||||
// Request covers the request that generated the event.
|
// Request covers the request that generated the event.
|
||||||
|
|
|
@ -869,7 +869,7 @@ func (app *App) eventBridge(ctx *Context, r *http.Request) notifications.Listene
|
||||||
}
|
}
|
||||||
request := notifications.NewRequestRecord(dcontext.GetRequestID(ctx), r)
|
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.
|
// nameRequired returns true if the route requires a name.
|
||||||
|
|
Loading…
Reference in a new issue