Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LXC: Fix lxc image list regression #14563

Merged
merged 1 commit into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ type ImageServer interface {
GetImages() (images []api.Image, err error)
GetImageFingerprints() (fingerprints []string, err error)
GetImagesWithFilter(filters []string) (images []api.Image, err error)
GetImagesAllProjects() (images []api.Image, err error)
GetImagesAllProjectsWithFilter(filters []string) (images []api.Image, err error)

GetImage(fingerprint string) (image *api.Image, ETag string, err error)
GetImageFile(fingerprint string, req ImageFileRequest) (resp *ImageFileResponse, err error)
Expand Down Expand Up @@ -243,8 +245,6 @@ type InstanceServer interface {
UpdateImageAlias(name string, alias api.ImageAliasesEntryPut, ETag string) (err error)
RenameImageAlias(name string, alias api.ImageAliasesEntryPost) (err error)
DeleteImageAlias(name string) (err error)
GetImagesAllProjects() (images []api.Image, err error)
GetImagesAllProjectsWithFilter(filters []string) (images []api.Image, err error)

// Network functions ("network" API extension)
GetNetworkNames() (names []string, err error)
Expand Down
10 changes: 10 additions & 0 deletions client/simplestreams_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ func (r *ProtocolSimpleStreams) GetImages() ([]api.Image, error) {
return r.ssClient.ListImages()
}

// GetImagesAllProjects returns a list of available images as Image structs.
func (r *ProtocolSimpleStreams) GetImagesAllProjects() ([]api.Image, error) {
return r.GetImages()
}

// GetImageFingerprints returns a list of available image fingerprints.
func (r *ProtocolSimpleStreams) GetImageFingerprints() ([]string, error) {
// Get all the images from simplestreams
Expand All @@ -45,6 +50,11 @@ func (r *ProtocolSimpleStreams) GetImagesWithFilter(filters []string) ([]api.Ima
return nil, fmt.Errorf("GetImagesWithFilter is not supported by the simplestreams protocol")
}

// GetImagesAllProjectsWithFilter returns an error indicating compatibility with the simplestreams protocol.
func (r *ProtocolSimpleStreams) GetImagesAllProjectsWithFilter(filters []string) ([]api.Image, error) {
return nil, fmt.Errorf("GetImagesAllProjectsWithFilter is not supported by the simplestreams protocol")
}

// GetImage returns an Image struct for the provided fingerprint.
func (r *ProtocolSimpleStreams) GetImage(fingerprint string) (*api.Image, string, error) {
image, err := r.ssClient.GetImage(fingerprint)
Expand Down
9 changes: 2 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,9 @@ func (c *cmdImageList) run(cmd *cobra.Command, args []string) error {

var allImages, images []api.Image
if c.flagAllProjects {
allImages, err = d.GetImagesAllProjectsWithFilter(serverFilters)
allImages, err = remoteServer.GetImagesAllProjectsWithFilter(serverFilters)
if err != nil {
allImages, err = d.GetImagesAllProjects()
allImages, err = remoteServer.GetImagesAllProjects()
if err != nil {
return err
}
Expand Down
Loading