Skip to content

Commit 4dc8154

Browse files
committed
workshop modification
1 parent ba3cec8 commit 4dc8154

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

v1/instancetype.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ func GetArchitecture(architecture string) Architecture {
5454

5555
type InstanceTypeID string
5656

57-
type Reservation struct {
58-
ID string
59-
}
60-
6157
type InstanceType struct {
6258
ID InstanceTypeID // this id should be unique across all regions and stable
6359
Location string
@@ -91,7 +87,7 @@ type InstanceType struct {
9187
Provider string
9288
Cloud string
9389
CanModifyFirewallRules bool
94-
Reservation *Reservation
90+
ReservedInstancePoolID string
9591
}
9692

9793
func MakeGenericInstanceTypeID(instanceType InstanceType) InstanceTypeID {

v1/providers/launchpad/instancetype.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import (
1515
openapi "github.com/brevdev/cloud/v1/providers/launchpad/gen/launchpad"
1616
)
1717

18+
const (
19+
brevDGXCWorkshopID = "brev-dgxc"
20+
)
21+
1822
func (c *LaunchpadClient) GetInstanceTypes(ctx context.Context, args v1.GetInstanceTypeArgs) ([]v1.InstanceType, error) {
1923
launchpadInstanceTypes, err := c.paginateInstanceTypes(ctx, 100)
2024
if err != nil {
@@ -208,20 +212,29 @@ func launchpadInstanceTypeToInstanceType(launchpadInstanceType openapi.InstanceT
208212
BasePrice: hourlyPrice,
209213
Provider: CloudProviderID,
210214
Cloud: launchpadInstanceType.Cloud,
211-
}
212-
213-
// Set the reservation this instance type is for, if relevant
214-
if info.workshopID != "" {
215-
it.Reservation = &v1.Reservation{
216-
ID: info.workshopID,
217-
}
215+
ReservedInstancePoolID: launchpadWorkshopIDToReservedInstancePoolID(info.workshopID),
218216
}
219217

220218
// Make the instance type ID
221219
it.ID = v1.MakeGenericInstanceTypeID(*it)
222220
return it, nil
223221
}
224222

223+
func launchpadWorkshopIDToReservedInstancePoolID(workshopID string) string {
224+
// If the workshop is empty, consider this to be a public instance type
225+
if workshopID == "" {
226+
return ""
227+
}
228+
229+
// If the workshop is the Brev DGXC workshop, consider this to be a public instance type
230+
if workshopID == brevDGXCWorkshopID {
231+
return ""
232+
}
233+
234+
// Otherwise, use the workshop ID as the reserved instance pool ID
235+
return workshopID
236+
}
237+
225238
func launchpadStorageToStorages(launchpadStorage []openapi.InstanceTypeStorage) []v1.Storage {
226239
if len(launchpadStorage) == 0 {
227240
return nil

0 commit comments

Comments
 (0)