Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 62c2e00

Browse files
committed
ref: get pulled image
Signed-off-by: Yves Brissaud <yves.brissaud@docker.com>
1 parent 635db3c commit 62c2e00

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

cli/mobycli/exec.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,7 @@ func Exec(_ *cobra.Command) {
114114
if (command == "build" || command == "pull") && !metrics.HasQuietFlag(commandArgs) {
115115
var image string
116116
if command == "pull" {
117-
for _, a := range commandArgs[1:] {
118-
if !strings.HasPrefix(a, "--") {
119-
image = a
120-
break
121-
}
122-
}
117+
image = pulledImageFromArgs(commandArgs)
123118
}
124119
displayScoutQuickViewSuggestMsg(image)
125120
}

cli/mobycli/scout_suggest.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121
"os"
2222
"strconv"
23+
"strings"
2324

2425
"github.com/fatih/color"
2526
)
@@ -47,3 +48,19 @@ func displayScoutQuickViewSuggestMsg(image string) {
4748
_, _ = fmt.Fprintf(out, " View summary of image vulnerabilities and recommendations → %s", color.CyanString("docker scout quickview%s", image))
4849
_, _ = fmt.Fprintln(out)
4950
}
51+
52+
func pulledImageFromArgs(args []string) string {
53+
var image string
54+
var pull bool
55+
for _, a := range args {
56+
if a == "pull" {
57+
pull = true
58+
continue
59+
}
60+
if pull && !strings.HasPrefix(a, "--") {
61+
image = a
62+
break
63+
}
64+
}
65+
return image
66+
}

0 commit comments

Comments
 (0)