Introduce Runtime.pullImageFromReference, call it in Runtime.FromImageReference

FINALLY, (podman load) can pass through an ImageReference directly from
loadCmd all the way to pullGoalNamesFromImageReference, making sure not
to trigger the docker-like reference parsing heuristics.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>

Closes: #1176
Approved by: rhatdan
This commit is contained in:
Miloslav Trmač
2018-07-28 08:18:57 +02:00
committed by Atomic Bot
parent 0d4a5549d6
commit 1c2d245c47
2 changed files with 12 additions and 1 deletions

View File

@ -167,7 +167,7 @@ func (ir *Runtime) LoadFromArchiveReference(ctx context.Context, srcRef types.Im
if signaturePolicyPath == "" { if signaturePolicyPath == "" {
signaturePolicyPath = ir.SignaturePolicyPath signaturePolicyPath = ir.SignaturePolicyPath
} }
imageNames, err := ir.pullImage(ctx, transports.ImageName(srcRef), writer, "", signaturePolicyPath, SigningOptions{}, &DockerRegistryOptions{}, false) imageNames, err := ir.pullImageFromReference(ctx, srcRef, writer, "", signaturePolicyPath, SigningOptions{}, &DockerRegistryOptions{}, false)
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "unable to pull %s", transports.ImageName(srcRef)) return nil, errors.Wrapf(err, "unable to pull %s", transports.ImageName(srcRef))
} }

View File

@ -201,6 +201,7 @@ func (ir *Runtime) pullGoalFromImageReference(ctx context.Context, srcRef types.
} }
// pullImage pulls an image based on input name, which may involve from configured registries. // pullImage pulls an image based on input name, which may involve from configured registries.
// Use pullImageFromReference if the source is known precisely.
func (ir *Runtime) pullImage(ctx context.Context, inputName string, writer io.Writer, authfile, signaturePolicyPath string, signingOptions SigningOptions, dockerOptions *DockerRegistryOptions, forceSecure bool) ([]string, error) { func (ir *Runtime) pullImage(ctx context.Context, inputName string, writer io.Writer, authfile, signaturePolicyPath string, signingOptions SigningOptions, dockerOptions *DockerRegistryOptions, forceSecure bool) ([]string, error) {
var goal pullGoal var goal pullGoal
sc := GetSystemContext(signaturePolicyPath, authfile, false) sc := GetSystemContext(signaturePolicyPath, authfile, false)
@ -220,6 +221,16 @@ func (ir *Runtime) pullImage(ctx context.Context, inputName string, writer io.Wr
return ir.doPullImage(ctx, sc, goal, writer, signingOptions, dockerOptions, forceSecure) return ir.doPullImage(ctx, sc, goal, writer, signingOptions, dockerOptions, forceSecure)
} }
// pullImageFromReference pulls an image from a types.imageReference.
func (ir *Runtime) pullImageFromReference(ctx context.Context, srcRef types.ImageReference, writer io.Writer, authfile, signaturePolicyPath string, signingOptions SigningOptions, dockerOptions *DockerRegistryOptions, forceSecure bool) ([]string, error) {
sc := GetSystemContext(signaturePolicyPath, authfile, false)
goal, err := ir.pullGoalFromImageReference(ctx, srcRef, transports.ImageName(srcRef), sc)
if err != nil {
return nil, errors.Wrapf(err, "error determining pull goal for image %q", transports.ImageName(srcRef))
}
return ir.doPullImage(ctx, sc, goal, writer, signingOptions, dockerOptions, forceSecure)
}
// doPullImage is an internal helper interpreting pullGoal. Almost everyone should call one of the callers of doPullImage instead. // doPullImage is an internal helper interpreting pullGoal. Almost everyone should call one of the callers of doPullImage instead.
func (ir *Runtime) doPullImage(ctx context.Context, sc *types.SystemContext, goal pullGoal, writer io.Writer, signingOptions SigningOptions, dockerOptions *DockerRegistryOptions, forceSecure bool) ([]string, error) { func (ir *Runtime) doPullImage(ctx context.Context, sc *types.SystemContext, goal pullGoal, writer io.Writer, signingOptions SigningOptions, dockerOptions *DockerRegistryOptions, forceSecure bool) ([]string, error) {
policyContext, err := getPolicyContext(sc) policyContext, err := getPolicyContext(sc)