Drop the *cli.Context argument from parseImage and parseImageSource

We no longer need it for handling flags.

Also, require the caller to explicitly pass an image name to parseImage
instead of, horribly nontransparently, using the first CLI option.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
Miloslav Trmač
2018-07-11 23:11:49 +02:00
parent 958cafb2c0
commit afa92d58f6
3 changed files with 5 additions and 6 deletions

View File

@@ -69,7 +69,7 @@ func (opts *inspectOptions) run(c *cli.Context) (retErr error) {
ctx, cancel := opts.global.commandTimeoutContext()
defer cancel()
img, err := parseImage(ctx, c, opts.image)
img, err := parseImage(ctx, opts.image, c.Args().First())
if err != nil {
return err
}

View File

@@ -51,7 +51,7 @@ func (opts *layersOptions) run(c *cli.Context) (retErr error) {
return err
}
cache := blobinfocache.DefaultCache(sys)
rawSource, err := parseImageSource(ctx, c, opts.image, c.Args()[0])
rawSource, err := parseImageSource(ctx, opts.image, c.Args()[0])
if err != nil {
return err
}

View File

@@ -182,9 +182,8 @@ func getDockerAuth(creds string) (*types.DockerAuthConfig, error) {
// parseImage converts image URL-like string to an initialized handler for that image.
// The caller must call .Close() on the returned ImageCloser.
func parseImage(ctx context.Context, c *cli.Context, opts *imageOptions) (types.ImageCloser, error) {
imgName := c.Args().First()
ref, err := alltransports.ParseImageName(imgName)
func parseImage(ctx context.Context, opts *imageOptions, name string) (types.ImageCloser, error) {
ref, err := alltransports.ParseImageName(name)
if err != nil {
return nil, err
}
@@ -197,7 +196,7 @@ func parseImage(ctx context.Context, c *cli.Context, opts *imageOptions) (types.
// parseImageSource converts image URL-like string to an ImageSource.
// The caller must call .Close() on the returned ImageSource.
func parseImageSource(ctx context.Context, c *cli.Context, opts *imageOptions, name string) (types.ImageSource, error) {
func parseImageSource(ctx context.Context, opts *imageOptions, name string) (types.ImageSource, error) {
ref, err := alltransports.ParseImageName(name)
if err != nil {
return nil, err