mirror of
https://github.com/containers/skopeo.git
synced 2025-08-27 10:39:06 +00:00
Inline contextsFromCopyOptions
It was not really any clearer when broken out. We already have a pair of trivial src/dest API calls before this, so adding a similar src/dest call for SystemContext follows the pattern. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
parent
1d1bf0d393
commit
958cafb2c0
@ -11,26 +11,10 @@ import (
|
||||
"github.com/containers/image/manifest"
|
||||
"github.com/containers/image/transports"
|
||||
"github.com/containers/image/transports/alltransports"
|
||||
"github.com/containers/image/types"
|
||||
imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
// contextsFromCopyOptions returns source and destionation types.SystemContext depending on opts.
|
||||
func contextsFromCopyOptions(opts *copyOptions) (*types.SystemContext, *types.SystemContext, error) {
|
||||
sourceCtx, err := opts.srcImage.newSystemContext()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
destinationCtx, err := opts.destImage.newSystemContext()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return sourceCtx, destinationCtx, nil
|
||||
}
|
||||
|
||||
type copyOptions struct {
|
||||
global *globalOptions
|
||||
srcImage *imageOptions
|
||||
@ -111,7 +95,11 @@ func (opts *copyOptions) run(c *cli.Context) error {
|
||||
return fmt.Errorf("Invalid destination name %s: %v", c.Args()[1], err)
|
||||
}
|
||||
|
||||
sourceCtx, destinationCtx, err := contextsFromCopyOptions(opts)
|
||||
sourceCtx, err := opts.srcImage.newSystemContext()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
destinationCtx, err := opts.destImage.newSystemContext()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user