38d914cc96
Move plugins to shared distribution stack with images.
Create immutable plugin config that matches schema2 requirements.
Ensure data being pushed is same as pulled/created.
Store distribution artifacts in a blobstore.
Run init layer setup for every plugin start.
Fix breakouts from unsafe file accesses.
Add support for `docker plugin install --alias`
Uses normalized references for default names to avoid collisions when using default hosts/tags.
Some refactoring of the plugin manager to support the change, like removing the singleton manager and adding manager config struct.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
(cherry picked from commit 3d86b0c79b
)
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
package metadata
|
|
|
|
import (
|
|
"github.com/docker/docker/image/v1"
|
|
"github.com/docker/docker/layer"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
// V1IDService maps v1 IDs to layers on disk.
|
|
type V1IDService struct {
|
|
store Store
|
|
}
|
|
|
|
// NewV1IDService creates a new V1 ID mapping service.
|
|
func NewV1IDService(store Store) *V1IDService {
|
|
return &V1IDService{
|
|
store: store,
|
|
}
|
|
}
|
|
|
|
// namespace returns the namespace used by this service.
|
|
func (idserv *V1IDService) namespace() string {
|
|
return "v1id"
|
|
}
|
|
|
|
// Get finds a layer by its V1 ID.
|
|
func (idserv *V1IDService) Get(v1ID, registry string) (layer.DiffID, error) {
|
|
if idserv.store == nil {
|
|
return "", errors.New("no v1IDService storage")
|
|
}
|
|
if err := v1.ValidateID(v1ID); err != nil {
|
|
return layer.DiffID(""), err
|
|
}
|
|
|
|
idBytes, err := idserv.store.Get(idserv.namespace(), registry+","+v1ID)
|
|
if err != nil {
|
|
return layer.DiffID(""), err
|
|
}
|
|
return layer.DiffID(idBytes), nil
|
|
}
|
|
|
|
// Set associates an image with a V1 ID.
|
|
func (idserv *V1IDService) Set(v1ID, registry string, id layer.DiffID) error {
|
|
if idserv.store == nil {
|
|
return nil
|
|
}
|
|
if err := v1.ValidateID(v1ID); err != nil {
|
|
return err
|
|
}
|
|
return idserv.store.Set(idserv.namespace(), registry+","+v1ID, []byte(id))
|
|
}
|