Skip to content

Commit

Permalink
fix: remove label instance image resolution to UUID
Browse files Browse the repository at this point in the history
  • Loading branch information
agirot committed Sep 27, 2024
1 parent 6c4fa29 commit c1e620d
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions api/instance/v1/server_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import (
"net/http"
"time"

"github.com/scaleway/scaleway-sdk-go/api/marketplace/v2"
"github.com/scaleway/scaleway-sdk-go/errors"
"github.com/scaleway/scaleway-sdk-go/internal/async"
"github.com/scaleway/scaleway-sdk-go/scw"
"github.com/scaleway/scaleway-sdk-go/validation"
)

const (
Expand All @@ -21,20 +19,6 @@ const (

// CreateServer creates a server.
func (s *API) CreateServer(req *CreateServerRequest, opts ...scw.RequestOption) (*CreateServerResponse, error) {
// If image is not a UUID we try to fetch it from marketplace.
if req.Image != "" && !validation.IsUUID(req.Image) {
apiMarketplace := marketplace.NewAPI(s.client)
image, err := apiMarketplace.GetLocalImageByLabel(&marketplace.GetLocalImageByLabelRequest{
ImageLabel: req.Image,
Zone: req.Zone,
CommercialType: req.CommercialType,
})
if err != nil {
return nil, err
}
req.Image = image.ID
}

return s.createServer(req, opts...)
}

Expand Down

0 comments on commit c1e620d

Please sign in to comment.