From 0b4cbd94a7cb881f093c188174d5b97393bf61df Mon Sep 17 00:00:00 2001 From: Sharad Kesarwani <108344822+sharadkesarwani@users.noreply.github.com> Date: Thu, 28 Mar 2024 21:48:22 +0530 Subject: [PATCH] Added support for `ephemeralStorage` in `ocean-aws-k8s-launchspec`. (#289) --- .../providers/aws/launchSpec/create/main.go | 16 ++++++++++ service/ocean/providers/aws/launchspec.go | 31 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/examples/service/ocean/providers/aws/launchSpec/create/main.go b/examples/service/ocean/providers/aws/launchSpec/create/main.go index 618d495c..2a681e1b 100644 --- a/examples/service/ocean/providers/aws/launchSpec/create/main.go +++ b/examples/service/ocean/providers/aws/launchSpec/create/main.go @@ -54,6 +54,22 @@ func main() { RootDeviceTypes: []string{"ebs"}, MaxNetworkPerformance: spotinst.Int(20), MinNetworkPerformance: spotinst.Int(2), + }, + BlockDeviceMappings: []*aws.BlockDeviceMapping{ + &aws.BlockDeviceMapping{ + DeviceName: spotinst.String("/dev/xvdb"), + EBS: &aws.EBS{ + DeleteOnTermination: spotinst.Bool(true), + Encrypted: spotinst.Bool(false), + IOPS: spotinst.Int(100), + Throughput: spotinst.Int(125), + VolumeType: spotinst.String("gp3"), + SnapshotID: spotinst.String("snap-12345"), + VolumeSize: spotinst.Int(35), + }, + }}, + EphemeralStorage: &aws.EphemeralStorage{ + DeviceName: spotinst.String("/dev/xvdb"), }}, }) if err != nil { diff --git a/service/ocean/providers/aws/launchspec.go b/service/ocean/providers/aws/launchspec.go index 4d197b71..74b1490d 100644 --- a/service/ocean/providers/aws/launchspec.go +++ b/service/ocean/providers/aws/launchspec.go @@ -31,6 +31,7 @@ type LaunchSpec struct { AutoScale *AutoScale `json:"autoScale,omitempty"` ElasticIPPool *ElasticIPPool `json:"elasticIpPool,omitempty"` BlockDeviceMappings []*BlockDeviceMapping `json:"blockDeviceMappings,omitempty"` + EphemeralStorage *EphemeralStorage `json:"ephemeralStorage,omitempty"` Labels []*Label `json:"labels,omitempty"` Taints []*Taint `json:"taints,omitempty"` Tags []*Tag `json:"tags,omitempty"` @@ -299,6 +300,13 @@ type InstanceTypesFilters struct { nullFields []string } +type EphemeralStorage struct { + DeviceName *string `json:"deviceName,omitempty"` + + forceSendFields []string + nullFields []string +} + type ListLaunchSpecsInput struct { OceanID *string `json:"oceanId,omitempty"` } @@ -679,6 +687,12 @@ func (o *LaunchSpec) SetInstanceTypesFilters(v *InstanceTypesFilters) *LaunchSpe } return o } +func (o *LaunchSpec) SetEphemeralStorage(v *EphemeralStorage) *LaunchSpec { + if o.EphemeralStorage = v; o.EphemeralStorage == nil { + o.nullFields = append(o.nullFields, "EphemeralStorage") + } + return o +} // endregion @@ -1317,3 +1331,20 @@ func (o *InstanceTypesFilters) SetVirtualizationTypes(v []string) *InstanceTypes } // endregion + +// region EphemeralStorage + +func (o *EphemeralStorage) SetDeviceName(v *string) *EphemeralStorage { + if o.DeviceName = v; o.DeviceName == nil { + o.nullFields = append(o.nullFields, "DeviceName") + } + return o +} + +func (o EphemeralStorage) MarshalJSON() ([]byte, error) { + type noMethod EphemeralStorage + raw := noMethod(o) + return jsonutil.MarshalJSON(raw, o.forceSendFields, o.nullFields) +} + +// endregion