forked from TrueCloudLab/distribution
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
|
||||
notifications:
|
||||
events:
|
||||
manifestlayers: true
|
||||
includereferences: true
|
||||
endpoints:
|
||||
- name: local-8082
|
||||
url: http://localhost:5003/callback
|
||||
|
|
|
@ -48,7 +48,7 @@ redis:
|
|||
writetimeout: 10ms
|
||||
notifications:
|
||||
events:
|
||||
manifestlayers: true
|
||||
includereferences: true
|
||||
endpoints:
|
||||
- name: local-5003
|
||||
url: http://localhost:5003/callback
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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`
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue