Skip to content

Commit

Permalink
Fix filtering image list by type (#364)
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Kämmerling <[email protected]>
  • Loading branch information
LKaemmerling authored Sep 30, 2021
1 parent 4410fb4 commit cfaefab
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/cmd/image/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ var listCmd = base.ListCmd{
cmd.RegisterFlagCompletionFunc("type", cmpl.SuggestCandidates("backup", "snapshot", "system", "app"))
},
Fetch: func(ctx context.Context, client hcapi2.Client, cmd *cobra.Command, listOpts hcloud.ListOpts) ([]interface{}, error) {
images, err := client.Image().AllWithOpts(ctx, hcloud.ImageListOpts{ListOpts: listOpts, IncludeDeprecated: true})
opts := hcloud.ImageListOpts{ListOpts: listOpts, IncludeDeprecated: true}
imageType, _ := cmd.Flags().GetString("type")
if len(imageType) > 0 {
opts.Type = []hcloud.ImageType{hcloud.ImageType(imageType)}
}
images, err := client.Image().AllWithOpts(ctx, opts)

var resources []interface{}
for _, n := range images {
Expand Down

0 comments on commit cfaefab

Please sign in to comment.