Skip to content

Commit dd54eba

Browse files
committed
cmd/completion, cmd/list, cmd/rmi: Remove getImages()
#1772
1 parent 0802dd1 commit dd54eba

3 files changed

Lines changed: 22 additions & 18 deletions

File tree

src/cmd/completion.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,13 @@ func completionImageNames(cmd *cobra.Command, _ []string, _ string) ([]string, c
129129
return nil, cobra.ShellCompDirectiveNoFileComp
130130
}
131131

132+
logrus.Debug("Getting all images")
133+
132134
var imageNames []string
133-
if images, err := getImages(true); err == nil {
135+
136+
if images, err := podman.GetImages(true); err != nil {
137+
logrus.Debugf("Getting all images failed: %s", err)
138+
} else {
134139
for _, image := range images {
135140
if len(image.Names) != 1 {
136141
panic("cannot complete unflattened Image")
@@ -144,8 +149,13 @@ func completionImageNames(cmd *cobra.Command, _ []string, _ string) ([]string, c
144149
}
145150

146151
func completionImageNamesFiltered(_ *cobra.Command, args []string, _ string) ([]string, cobra.ShellCompDirective) {
152+
logrus.Debug("Getting all images")
153+
147154
var imageNames []string
148-
if images, err := getImages(true); err == nil {
155+
156+
if images, err := podman.GetImages(true); err != nil {
157+
logrus.Debugf("Getting all images failed: %s", err)
158+
} else {
149159
for _, image := range images {
150160
skip := false
151161

src/cmd/list.go

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,12 @@ func list(cmd *cobra.Command, args []string) error {
8686
var err error
8787

8888
if lsImages {
89-
images, err = getImages(false)
89+
logrus.Debug("Getting all images")
90+
91+
images, err = podman.GetImages(false)
9092
if err != nil {
91-
return err
93+
logrus.Debugf("Getting all images failed: %s", err)
94+
return errors.New("failed to get images")
9295
}
9396
}
9497

@@ -144,18 +147,6 @@ func listHelp(cmd *cobra.Command, args []string) {
144147
}
145148
}
146149

147-
func getImages(fillNameWithID bool) ([]podman.Image, error) {
148-
logrus.Debug("Fetching all images")
149-
150-
images, err := podman.GetImages(fillNameWithID)
151-
if err != nil {
152-
logrus.Debugf("Fetching all images failed: %s", err)
153-
return nil, errors.New("failed to get images")
154-
}
155-
156-
return images, nil
157-
}
158-
159150
func listOutput(images []podman.Image, containers []podman.Container) {
160151
if len(images) != 0 {
161152
writer := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)

src/cmd/rmi.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,12 @@ func rmi(cmd *cobra.Command, args []string) error {
6767
}
6868

6969
if rmiFlags.deleteAll {
70-
toolboxImages, err := getImages(false)
70+
logrus.Debug("Getting all images")
71+
72+
toolboxImages, err := podman.GetImages(false)
7173
if err != nil {
72-
return err
74+
logrus.Debugf("Getting all images failed: %s", err)
75+
return errors.New("failed to get images")
7376
}
7477

7578
for _, image := range toolboxImages {

0 commit comments

Comments
 (0)