|
@@ -11,21 +11,25 @@ type builder struct {
|
|
// bs is a BlobService used to publish the configuration blob.
|
|
// bs is a BlobService used to publish the configuration blob.
|
|
bs distribution.BlobService
|
|
bs distribution.BlobService
|
|
|
|
|
|
|
|
+ // configMediaType is media type used to describe configuration
|
|
|
|
+ configMediaType string
|
|
|
|
+
|
|
// configJSON references
|
|
// configJSON references
|
|
configJSON []byte
|
|
configJSON []byte
|
|
|
|
|
|
- // layers is a list of layer descriptors that gets built by successive
|
|
|
|
- // calls to AppendReference.
|
|
|
|
- layers []distribution.Descriptor
|
|
|
|
|
|
+ // dependencies is a list of descriptors that gets built by successive
|
|
|
|
+ // calls to AppendReference. In case of image configuration these are layers.
|
|
|
|
+ dependencies []distribution.Descriptor
|
|
}
|
|
}
|
|
|
|
|
|
// NewManifestBuilder is used to build new manifests for the current schema
|
|
// NewManifestBuilder is used to build new manifests for the current schema
|
|
// version. It takes a BlobService so it can publish the configuration blob
|
|
// version. It takes a BlobService so it can publish the configuration blob
|
|
// as part of the Build process.
|
|
// as part of the Build process.
|
|
-func NewManifestBuilder(bs distribution.BlobService, configJSON []byte) distribution.ManifestBuilder {
|
|
|
|
|
|
+func NewManifestBuilder(bs distribution.BlobService, configMediaType string, configJSON []byte) distribution.ManifestBuilder {
|
|
mb := &builder{
|
|
mb := &builder{
|
|
- bs: bs,
|
|
|
|
- configJSON: make([]byte, len(configJSON)),
|
|
|
|
|
|
+ bs: bs,
|
|
|
|
+ configMediaType: configMediaType,
|
|
|
|
+ configJSON: make([]byte, len(configJSON)),
|
|
}
|
|
}
|
|
copy(mb.configJSON, configJSON)
|
|
copy(mb.configJSON, configJSON)
|
|
|
|
|
|
@@ -36,9 +40,9 @@ func NewManifestBuilder(bs distribution.BlobService, configJSON []byte) distribu
|
|
func (mb *builder) Build(ctx context.Context) (distribution.Manifest, error) {
|
|
func (mb *builder) Build(ctx context.Context) (distribution.Manifest, error) {
|
|
m := Manifest{
|
|
m := Manifest{
|
|
Versioned: SchemaVersion,
|
|
Versioned: SchemaVersion,
|
|
- Layers: make([]distribution.Descriptor, len(mb.layers)),
|
|
|
|
|
|
+ Layers: make([]distribution.Descriptor, len(mb.dependencies)),
|
|
}
|
|
}
|
|
- copy(m.Layers, mb.layers)
|
|
|
|
|
|
+ copy(m.Layers, mb.dependencies)
|
|
|
|
|
|
configDigest := digest.FromBytes(mb.configJSON)
|
|
configDigest := digest.FromBytes(mb.configJSON)
|
|
|
|
|
|
@@ -48,7 +52,7 @@ func (mb *builder) Build(ctx context.Context) (distribution.Manifest, error) {
|
|
case nil:
|
|
case nil:
|
|
// Override MediaType, since Put always replaces the specified media
|
|
// Override MediaType, since Put always replaces the specified media
|
|
// type with application/octet-stream in the descriptor it returns.
|
|
// type with application/octet-stream in the descriptor it returns.
|
|
- m.Config.MediaType = MediaTypeConfig
|
|
|
|
|
|
+ m.Config.MediaType = mb.configMediaType
|
|
return FromStruct(m)
|
|
return FromStruct(m)
|
|
case distribution.ErrBlobUnknown:
|
|
case distribution.ErrBlobUnknown:
|
|
// nop
|
|
// nop
|
|
@@ -57,10 +61,10 @@ func (mb *builder) Build(ctx context.Context) (distribution.Manifest, error) {
|
|
}
|
|
}
|
|
|
|
|
|
// Add config to the blob store
|
|
// Add config to the blob store
|
|
- m.Config, err = mb.bs.Put(ctx, MediaTypeConfig, mb.configJSON)
|
|
|
|
|
|
+ m.Config, err = mb.bs.Put(ctx, mb.configMediaType, mb.configJSON)
|
|
// Override MediaType, since Put always replaces the specified media
|
|
// Override MediaType, since Put always replaces the specified media
|
|
// type with application/octet-stream in the descriptor it returns.
|
|
// type with application/octet-stream in the descriptor it returns.
|
|
- m.Config.MediaType = MediaTypeConfig
|
|
|
|
|
|
+ m.Config.MediaType = mb.configMediaType
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, err
|
|
return nil, err
|
|
}
|
|
}
|
|
@@ -70,11 +74,11 @@ func (mb *builder) Build(ctx context.Context) (distribution.Manifest, error) {
|
|
|
|
|
|
// AppendReference adds a reference to the current ManifestBuilder.
|
|
// AppendReference adds a reference to the current ManifestBuilder.
|
|
func (mb *builder) AppendReference(d distribution.Describable) error {
|
|
func (mb *builder) AppendReference(d distribution.Describable) error {
|
|
- mb.layers = append(mb.layers, d.Descriptor())
|
|
|
|
|
|
+ mb.dependencies = append(mb.dependencies, d.Descriptor())
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
// References returns the current references added to this builder.
|
|
// References returns the current references added to this builder.
|
|
func (mb *builder) References() []distribution.Descriptor {
|
|
func (mb *builder) References() []distribution.Descriptor {
|
|
- return mb.layers
|
|
|
|
|
|
+ return mb.dependencies
|
|
}
|
|
}
|