-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
Taken from mrunalp/ocid#22, part of mrunalp/ocid#6.
Depends on containers/image#63 but we could actually start playing with this. This also depends on containers/image#41 (wrt to have containers/image to receive an auth configuration to pull from registries), but not strictly, I'll work on that asap.
The way we get the image from the CRI API is hardcoding docker as the reference and docker registry as the transport, this is being worked on in kubernetes/kubernetes#7203.
Pseudo code re-arranged:
import (
"github.com/containers/image/copy"
"github.com/containers/storage"
)
func PullImage(imageName) error {
// imageName - as come from K8s API contains NAME+TAGORDIGEST
if storage.IsAlreadyPulled(imageName) {
return nil
}
src := // create an new ImageSource, probably from docker
dest := // create a new OCIStorageDestination
err := copy.Image(ctx, policyCtx, src, dest, options)
if err != nil {
return err
}
return nil
}
// then the image stored above is used to create a new container
func CreateContainerRootfs(id) error {
imageMetadata = storage.GetMetadata(imageIDorName)
storage.CreateContainer(imageID=..., optionalName=..., optionalID=..., metadata=...)
// [ ... ]
}Metadata
Metadata
Assignees
Labels
No labels