containerd: use mediatype helpers
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
This commit is contained in:
parent
9ca6fd9e6e
commit
f1cbc5f90c
@ -120,24 +120,24 @@ func WithImageConfigLabels(image Image) NewContainerOpts {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !images.IsConfigType(ic.MediaType) {
|
||||
return fmt.Errorf("unknown image config media type %s", ic.MediaType)
|
||||
}
|
||||
|
||||
var (
|
||||
ociimage v1.Image
|
||||
config v1.ImageConfig
|
||||
)
|
||||
switch ic.MediaType {
|
||||
case v1.MediaTypeImageConfig, images.MediaTypeDockerSchema2Config:
|
||||
p, err := content.ReadBlob(ctx, image.ContentStore(), ic)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(p, &ociimage); err != nil {
|
||||
if err = json.Unmarshal(p, &ociimage); err != nil {
|
||||
return err
|
||||
}
|
||||
config = ociimage.Config
|
||||
default:
|
||||
return fmt.Errorf("unknown image config media type %s", ic.MediaType)
|
||||
}
|
||||
|
||||
c.Labels = config.Labels
|
||||
return nil
|
||||
}
|
||||
|
11
signals.go
11
signals.go
@ -57,24 +57,23 @@ func GetOCIStopSignal(ctx context.Context, image Image, defaultSignal string) (s
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if !images.IsConfigType(ic.MediaType) {
|
||||
return "", fmt.Errorf("unknown image config media type %s", ic.MediaType)
|
||||
}
|
||||
|
||||
var (
|
||||
ociimage v1.Image
|
||||
config v1.ImageConfig
|
||||
)
|
||||
switch ic.MediaType {
|
||||
case v1.MediaTypeImageConfig, images.MediaTypeDockerSchema2Config:
|
||||
p, err := content.ReadBlob(ctx, image.ContentStore(), ic)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(p, &ociimage); err != nil {
|
||||
if err = json.Unmarshal(p, &ociimage); err != nil {
|
||||
return "", err
|
||||
}
|
||||
config = ociimage.Config
|
||||
default:
|
||||
return "", fmt.Errorf("unknown image config media type %s", ic.MediaType)
|
||||
}
|
||||
|
||||
if config.StopSignal == "" {
|
||||
return defaultSignal, nil
|
||||
|
Loading…
Reference in New Issue
Block a user