mirror of
https://github.com/containers/podman.git
synced 2025-06-29 23:22:40 +08:00
Move pullImage from Image to Runtime
pullImage (now) only uses Image.InputName; it is really used to _create_ an Image object, based on the pull results (as is most visible in the LoadFromArchive caller), so it should not be a method on it. This also simplifies a bit the number of different kids of uses of Image.InputName; still apparently not enough to clearly document the field, though. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1176 Approved by: rhatdan
This commit is contained in:

committed by
Atomic Bot

parent
dbe2395769
commit
2d5410d349
@ -145,7 +145,7 @@ func (ir *Runtime) New(ctx context.Context, name, signaturePolicyPath, authfile
|
|||||||
if signaturePolicyPath == "" {
|
if signaturePolicyPath == "" {
|
||||||
signaturePolicyPath = ir.SignaturePolicyPath
|
signaturePolicyPath = ir.SignaturePolicyPath
|
||||||
}
|
}
|
||||||
imageName, err := newImage.pullImage(ctx, writer, authfile, signaturePolicyPath, signingoptions, dockeroptions, forceSecure)
|
imageName, err := ir.pullImage(ctx, name, writer, authfile, signaturePolicyPath, signingoptions, dockeroptions, forceSecure)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "unable to pull %s", name)
|
return nil, errors.Wrapf(err, "unable to pull %s", name)
|
||||||
}
|
}
|
||||||
@ -163,16 +163,11 @@ func (ir *Runtime) New(ctx context.Context, name, signaturePolicyPath, authfile
|
|||||||
// This function is needed because it is possible for a tar archive to have multiple tags for one image
|
// This function is needed because it is possible for a tar archive to have multiple tags for one image
|
||||||
func (ir *Runtime) LoadFromArchive(ctx context.Context, name, signaturePolicyPath string, writer io.Writer) ([]*Image, error) {
|
func (ir *Runtime) LoadFromArchive(ctx context.Context, name, signaturePolicyPath string, writer io.Writer) ([]*Image, error) {
|
||||||
var newImages []*Image
|
var newImages []*Image
|
||||||
newImage := Image{
|
|
||||||
InputName: name,
|
|
||||||
Local: false,
|
|
||||||
imageruntime: ir,
|
|
||||||
}
|
|
||||||
|
|
||||||
if signaturePolicyPath == "" {
|
if signaturePolicyPath == "" {
|
||||||
signaturePolicyPath = ir.SignaturePolicyPath
|
signaturePolicyPath = ir.SignaturePolicyPath
|
||||||
}
|
}
|
||||||
imageNames, err := newImage.pullImage(ctx, writer, "", signaturePolicyPath, SigningOptions{}, &DockerRegistryOptions{}, false)
|
imageNames, err := ir.pullImage(ctx, name, writer, "", signaturePolicyPath, SigningOptions{}, &DockerRegistryOptions{}, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "unable to pull %s", name)
|
return nil, errors.Wrapf(err, "unable to pull %s", name)
|
||||||
}
|
}
|
||||||
|
@ -200,24 +200,24 @@ func (ir *Runtime) pullGoalFromImageReference(ctx context.Context, srcRef types.
|
|||||||
return ir.pullGoalFromGoalNames(goalNames)
|
return ir.pullGoalFromGoalNames(goalNames)
|
||||||
}
|
}
|
||||||
|
|
||||||
// pullImage pulls an image from configured registries
|
// pullImage pulls an image from configured registries based on inputName.
|
||||||
// By default, only the latest tag (or a specific tag if requested) will be
|
// By default, only the latest tag (or a specific tag if requested) will be
|
||||||
// pulled.
|
// pulled.
|
||||||
func (i *Image) pullImage(ctx context.Context, 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) {
|
||||||
// pullImage copies the image from the source to the destination
|
// pullImage copies the image from the source to the destination
|
||||||
var goal pullGoal
|
var goal pullGoal
|
||||||
sc := GetSystemContext(signaturePolicyPath, authfile, false)
|
sc := GetSystemContext(signaturePolicyPath, authfile, false)
|
||||||
srcRef, err := alltransports.ParseImageName(i.InputName)
|
srcRef, err := alltransports.ParseImageName(inputName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// could be trying to pull from registry with short name
|
// could be trying to pull from registry with short name
|
||||||
goal, err = i.pullGoalFromPossiblyUnqualifiedName()
|
goal, err = ir.pullGoalFromPossiblyUnqualifiedName(inputName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "error getting default registries to try")
|
return nil, errors.Wrap(err, "error getting default registries to try")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
goal, err = i.imageruntime.pullGoalFromImageReference(ctx, srcRef, i.InputName, sc)
|
goal, err = ir.pullGoalFromImageReference(ctx, srcRef, inputName, sc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "error determining pull goal for image %q", i.InputName)
|
return nil, errors.Wrapf(err, "error determining pull goal for image %q", inputName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
policyContext, err := getPolicyContext(sc)
|
policyContext, err := getPolicyContext(sc)
|
||||||
@ -338,14 +338,14 @@ func pullGoalNamesFromPossiblyUnqualifiedName(inputName string) (*pullGoalNames,
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// pullGoalFromPossiblyUnqualifiedName looks at a decomposed image and determines the possible
|
// pullGoalFromPossiblyUnqualifiedName looks at inputName and determines the possible
|
||||||
// image references to try pulling in combination with the registries.conf file as well
|
// image references to try pulling in combination with the registries.conf file as well
|
||||||
func (i *Image) pullGoalFromPossiblyUnqualifiedName() (pullGoal, error) {
|
func (ir *Runtime) pullGoalFromPossiblyUnqualifiedName(inputName string) (pullGoal, error) {
|
||||||
goalNames, err := pullGoalNamesFromPossiblyUnqualifiedName(i.InputName)
|
goalNames, err := pullGoalNamesFromPossiblyUnqualifiedName(inputName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return pullGoal{}, err
|
return pullGoal{}, err
|
||||||
}
|
}
|
||||||
return i.imageruntime.pullGoalFromGoalNames(goalNames)
|
return ir.pullGoalFromGoalNames(goalNames)
|
||||||
}
|
}
|
||||||
|
|
||||||
// pullGoalFromGoalNames converts a pullGoalNames to a pullGoal
|
// pullGoalFromGoalNames converts a pullGoalNames to a pullGoal
|
||||||
|
Reference in New Issue
Block a user