Skip to content

Commit

Permalink
lxc/image: Add InstanceServer type assertion for --all-projects e…
Browse files Browse the repository at this point in the history
…rror handling

Signed-off-by: Kadin Sayani <[email protected]>
  • Loading branch information
kadinsayani committed Jan 22, 2025
1 parent a02b39f commit 0181755
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lxc/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -1353,11 +1353,6 @@ func (c *cmdImageList) run(cmd *cobra.Command, args []string) error {
return err
}

d, err := c.global.conf.GetInstanceServer(remoteName)
if err != nil {
return err
}

// Process the filters
filters := []string{}
if name != "" {
Expand All @@ -1378,9 +1373,14 @@ func (c *cmdImageList) run(cmd *cobra.Command, args []string) error {

var allImages []api.Image
if c.flagAllProjects {
allImages, err = d.GetImagesAllProjectsWithFilter(serverFilters)
instanceServer, ok := remoteServer.(lxd.InstanceServer)
if !ok {
return fmt.Errorf("--all-projects flag is not supported for this server")
}

allImages, err = instanceServer.GetImagesAllProjectsWithFilter(serverFilters)
if err != nil {
allImages, err = d.GetImagesAllProjects()
allImages, err = instanceServer.GetImagesAllProjects()
if err != nil {
return err
}
Expand Down

0 comments on commit 0181755

Please sign in to comment.