Skip to content

Commit b15c1c7

Browse files
committed
LXC: Add GetImagesAllProjects and GetImagesAllProjectsWithFilter client functions and interfaces to simplestreams_images.go
This commit fixes a regression introduced with support for fetching images across all projects by adding `GetImagesAllProjects` and `GetImagesAllProjectsWithFilter` functions to `client/simplestreams_images.go`, and moving their method signatures to the ImageServer interface. Signed-off-by: Kadin Sayani <kadin.sayani@canonical.com>
1 parent 4a3c4a3 commit b15c1c7

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

client/interfaces.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ type ImageServer interface {
5050
GetImages() (images []api.Image, err error)
5151
GetImageFingerprints() (fingerprints []string, err error)
5252
GetImagesWithFilter(filters []string) (images []api.Image, err error)
53+
GetImagesAllProjects() (images []api.Image, err error)
54+
GetImagesAllProjectsWithFilter(filters []string) (images []api.Image, err error)
5355

5456
GetImage(fingerprint string) (image *api.Image, ETag string, err error)
5557
GetImageFile(fingerprint string, req ImageFileRequest) (resp *ImageFileResponse, err error)
@@ -243,8 +245,6 @@ type InstanceServer interface {
243245
UpdateImageAlias(name string, alias api.ImageAliasesEntryPut, ETag string) (err error)
244246
RenameImageAlias(name string, alias api.ImageAliasesEntryPost) (err error)
245247
DeleteImageAlias(name string) (err error)
246-
GetImagesAllProjects() (images []api.Image, err error)
247-
GetImagesAllProjectsWithFilter(filters []string) (images []api.Image, err error)
248248

249249
// Network functions ("network" API extension)
250250
GetNetworkNames() (names []string, err error)

client/simplestreams_images.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ func (r *ProtocolSimpleStreams) GetImages() ([]api.Image, error) {
2323
return r.ssClient.ListImages()
2424
}
2525

26+
// GetImagesAllProjects returns a list of available images as Image structs.
27+
func (r *ProtocolSimpleStreams) GetImagesAllProjects() ([]api.Image, error) {
28+
return r.GetImages()
29+
}
30+
2631
// GetImageFingerprints returns a list of available image fingerprints.
2732
func (r *ProtocolSimpleStreams) GetImageFingerprints() ([]string, error) {
2833
// Get all the images from simplestreams
@@ -45,6 +50,11 @@ func (r *ProtocolSimpleStreams) GetImagesWithFilter(filters []string) ([]api.Ima
4550
return nil, fmt.Errorf("GetImagesWithFilter is not supported by the simplestreams protocol")
4651
}
4752

53+
// GetImagesAllProjectsWithFilter returns an error indicating compatibility with the simplestreams protocol.
54+
func (r *ProtocolSimpleStreams) GetImagesAllProjectsWithFilter(filters []string) ([]api.Image, error) {
55+
return nil, fmt.Errorf("GetImagesAllProjectsWithFilter is not supported by the simplestreams protocol")
56+
}
57+
4858
// GetImage returns an Image struct for the provided fingerprint.
4959
func (r *ProtocolSimpleStreams) GetImage(fingerprint string) (*api.Image, string, error) {
5060
image, err := r.ssClient.GetImage(fingerprint)

lxc/image.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,11 +1353,6 @@ func (c *cmdImageList) run(cmd *cobra.Command, args []string) error {
13531353
return err
13541354
}
13551355

1356-
d, err := c.global.conf.GetInstanceServer(remoteName)
1357-
if err != nil {
1358-
return err
1359-
}
1360-
13611356
// Process the filters
13621357
filters := []string{}
13631358
if name != "" {
@@ -1378,9 +1373,9 @@ func (c *cmdImageList) run(cmd *cobra.Command, args []string) error {
13781373

13791374
var allImages, images []api.Image
13801375
if c.flagAllProjects {
1381-
allImages, err = d.GetImagesAllProjectsWithFilter(serverFilters)
1376+
allImages, err = remoteServer.GetImagesAllProjectsWithFilter(serverFilters)
13821377
if err != nil {
1383-
allImages, err = d.GetImagesAllProjects()
1378+
allImages, err = remoteServer.GetImagesAllProjects()
13841379
if err != nil {
13851380
return err
13861381
}

0 commit comments

Comments
 (0)