Skip to content

Commit e60c1d4

Browse files
feat(marketplace): uppercase commercial type in GetLocalImageIDByLabel (#205)
1 parent ded5570 commit e60c1d4

File tree

4 files changed

+927
-42
lines changed

4 files changed

+927
-42
lines changed

api/marketplace/v1/marketplace_utils.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ func (s *API) GetLocalImageIDByLabel(req *GetLocalImageIDByLabelRequest) (string
6868

6969
images := listImageResponse.Images
7070
label := strings.Replace(req.ImageLabel, "-", "_", -1)
71+
commercialType := strings.ToUpper(req.CommercialType)
7172

7273
for _, image := range images {
7374

@@ -79,7 +80,7 @@ func (s *API) GetLocalImageIDByLabel(req *GetLocalImageIDByLabelRequest) (string
7980
return "", errors.Wrap(err, "couldn't find a matching image for the given label (%s), zone (%s) and commercial type (%s)", req.ImageLabel, req.Zone, req.CommercialType)
8081
}
8182

82-
localImage, err := latestVersion.getLocalImage(req.Zone, req.CommercialType)
83+
localImage, err := latestVersion.getLocalImage(req.Zone, commercialType)
8384
if err != nil {
8485
return "", errors.Wrap(err, "couldn't find a matching image for the given label (%s), zone (%s) and commercial type (%s)", req.ImageLabel, req.Zone, req.CommercialType)
8586
}

api/marketplace/v1/marketplace_utils_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,23 @@ func TestGetImageByLabel(t *testing.T) {
3333

3434
})
3535

36+
t.Run("matching input for GetLocalImageIDByLabel with lowercase image label", func(t *testing.T) {
37+
38+
// Create SDK objects for Scaleway Instance product
39+
marketplaceAPI := NewAPI(client)
40+
41+
imageID, err := marketplaceAPI.GetLocalImageIDByLabel(&GetLocalImageIDByLabelRequest{
42+
Zone: scw.ZoneFrPar1,
43+
CommercialType: "dev1-s",
44+
ImageLabel: "ubuntu-bionic",
45+
})
46+
testhelpers.AssertNoError(t, err)
47+
48+
// ubuntu-bionic DEV1-S at par1: f974feac-abae-4365-b988-8ec7d1cec10d
49+
testhelpers.Equals(t, "f974feac-abae-4365-b988-8ec7d1cec10d", imageID)
50+
51+
})
52+
3653
t.Run("non-matching label for GetLocalImageIDByLabel", func(t *testing.T) {
3754

3855
// Create SDK objects for Scaleway Instance product

0 commit comments

Comments
 (0)