diff --git a/go.mod b/go.mod index 664d97c8..626374cc 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/sirupsen/logrus v1.8.1 github.com/spf13/cobra v1.4.0 github.com/spf13/pflag v1.0.5 - github.com/spotinst/spotinst-sdk-go v1.125.0 + github.com/spotinst/spotinst-sdk-go v1.132.0 github.com/stretchr/testify v1.7.2 github.com/theckman/yacspin v0.13.12 golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect diff --git a/go.sum b/go.sum index dc8fa741..e3b64523 100644 --- a/go.sum +++ b/go.sum @@ -303,8 +303,8 @@ github.com/spf13/cobra v1.4.0 h1:y+wJpx64xcgO1V+RcnwW0LEHxTKRi2ZDPSBjWnrg88Q= github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spotinst/spotinst-sdk-go v1.125.0 h1:ahzSiFGf+4ZdQfFdpZ1mFZf4oLCX4vLEZAlw1zyiI0w= -github.com/spotinst/spotinst-sdk-go v1.125.0/go.mod h1:C6mrT7+mqOgPyabacjyYTvilu8Xm96mvTvrZQhj99WI= +github.com/spotinst/spotinst-sdk-go v1.132.0 h1:oQ9pZJTP6Z3NFjMhud0TuohSybc7V+qrzxrb9G82bI8= +github.com/spotinst/spotinst-sdk-go v1.132.0/go.mod h1:C6mrT7+mqOgPyabacjyYTvilu8Xm96mvTvrZQhj99WI= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= diff --git a/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/ocean.go b/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/ocean.go index 06d12633..64aeb51f 100644 --- a/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/ocean.go +++ b/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/ocean.go @@ -4,6 +4,7 @@ import ( "github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws" "github.com/spotinst/spotinst-sdk-go/service/ocean/providers/azure" "github.com/spotinst/spotinst-sdk-go/service/ocean/providers/gcp" + "github.com/spotinst/spotinst-sdk-go/service/ocean/spark" "github.com/spotinst/spotinst-sdk-go/spotinst" "github.com/spotinst/spotinst-sdk-go/spotinst/client" "github.com/spotinst/spotinst-sdk-go/spotinst/session" @@ -16,6 +17,7 @@ type Service interface { CloudProviderAWS() aws.Service CloudProviderGCP() gcp.Service CloudProviderAzure() azure.Service + Spark() spark.Service } type ServiceOp struct { @@ -51,3 +53,9 @@ func (s *ServiceOp) CloudProviderAzure() azure.Service { Client: s.Client, } } + +func (s *ServiceOp) Spark() spark.Service { + return &spark.ServiceOp{ + Client: s.Client, + } +} diff --git a/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/launchspec.go b/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/launchspec.go index 95665c9c..7b3da800 100644 --- a/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/launchspec.go +++ b/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/launchspec.go @@ -237,6 +237,7 @@ type UpdateLaunchSpecOutput struct { type DeleteLaunchSpecInput struct { LaunchSpecID *string `json:"launchSpecId,omitempty"` ForceDelete *bool `json:"-"` + DeleteNodes *bool `json:"-"` } type DeleteLaunchSpecOutput struct{} @@ -398,6 +399,9 @@ func (s *ServiceOp) DeleteLaunchSpec(ctx context.Context, input *DeleteLaunchSpe if input.ForceDelete != nil { r.Params.Set("forceDelete", strconv.FormatBool(spotinst.BoolValue(input.ForceDelete))) } + if input.DeleteNodes != nil { + r.Params.Set("deleteNodes", strconv.FormatBool(spotinst.BoolValue(input.DeleteNodes))) + } resp, err := client.RequireOK(s.Client.Do(ctx, r)) if err != nil { diff --git a/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/launchspec_ecs.go b/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/launchspec_ecs.go index fa67f1a9..381a5378 100644 --- a/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/launchspec_ecs.go +++ b/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/launchspec_ecs.go @@ -26,6 +26,8 @@ type ECSLaunchSpec struct { BlockDeviceMappings []*ECSBlockDeviceMapping `json:"blockDeviceMappings,omitempty"` Tags []*Tag `json:"tags,omitempty"` InstanceTypes []string `json:"instanceTypes,omitempty"` + PreferredSpotTypes []string `json:"preferredSpotTypes,omitempty"` + Strategy *ECSLaunchSpecStrategy `json:"strategy,omitempty"` RestrictScaleDown *bool `json:"restrictScaleDown,omitempty"` SubnetIDs []string `json:"subnetIds,omitempty"` LaunchSpecScheduling *ECSLaunchSpecScheduling `json:"scheduling,omitempty"` @@ -109,6 +111,13 @@ type ECSDynamicVolumeSize struct { nullFields []string } +type ECSLaunchSpecStrategy struct { + SpotPercentage *int `json:"spotPercentage,omitempty"` + + forceSendFields []string + nullFields []string +} + type ECSLaunchSpecScheduling struct { Tasks []*ECSLaunchSpecTask `json:"tasks,omitempty"` @@ -433,6 +442,13 @@ func (o *ECSLaunchSpec) SetInstanceTypes(v []string) *ECSLaunchSpec { return o } +func (o *ECSLaunchSpec) SetPreferredSpotTypes(v []string) *ECSLaunchSpec { + if o.PreferredSpotTypes = v; o.PreferredSpotTypes == nil { + o.nullFields = append(o.nullFields, "PreferredSpotTypes") + } + return o +} + func (o *ECSLaunchSpec) SetRestrictScaleDown(v *bool) *ECSLaunchSpec { if o.RestrictScaleDown = v; o.RestrictScaleDown == nil { o.nullFields = append(o.nullFields, "RestrictScaleDown") @@ -454,6 +470,13 @@ func (o *ECSLaunchSpec) SetScheduling(v *ECSLaunchSpecScheduling) *ECSLaunchSpec return o } +func (o *ECSLaunchSpec) SetStrategy(v *ECSLaunchSpecStrategy) *ECSLaunchSpec { + if o.Strategy = v; o.Strategy == nil { + o.nullFields = append(o.nullFields, "ECSLaunchSpecStrategy") + } + return o +} + // endregion // region Attributes @@ -670,6 +693,23 @@ func (o *ECSDynamicVolumeSize) SetSizePerResourceUnit(v *int) *ECSDynamicVolumeS // endregion +// region LaunchSpecStrategy + +func (o ECSLaunchSpecStrategy) MarshalJSON() ([]byte, error) { + type noMethod ECSLaunchSpecStrategy + raw := noMethod(o) + return jsonutil.MarshalJSON(raw, o.forceSendFields, o.nullFields) +} + +func (o *ECSLaunchSpecStrategy) SetSpotPercentage(v *int) *ECSLaunchSpecStrategy { + if o.SpotPercentage = v; o.SpotPercentage == nil { + o.nullFields = append(o.nullFields, "SpotPercentage") + } + return o +} + +// endregion + //region Scheduling func (o ECSLaunchSpecScheduling) MarshalJSON() ([]byte, error) { diff --git a/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/spark/cluster.go b/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/spark/cluster.go new file mode 100644 index 00000000..17fb0f86 --- /dev/null +++ b/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/spark/cluster.go @@ -0,0 +1,258 @@ +package spark + +import ( + "time" + + "github.com/spotinst/spotinst-sdk-go/spotinst/util/jsonutil" +) + +type Cluster struct { + Config *Config `json:"config,omitempty"` + + // Read-only fields. + ID *string `json:"id,omitempty"` + ControllerClusterID *string `json:"controllerClusterId,omitempty"` + OceanClusterID *string `json:"oceanClusterId,omitempty"` + Region *string `json:"region,omitempty"` + State *string `json:"state,omitempty"` + K8sVersion *string `json:"k8sVersion,omitempty"` + OperatorVersion *string `json:"operatorVersion,omitempty"` + OperatorLastHeartbeat *time.Time `json:"operatorLastHeartbeat,omitempty"` + CreatedAt *time.Time `json:"createdAt,omitempty"` + UpdatedAt *time.Time `json:"updatedAt,omitempty"` + + forceSendFields []string + nullFields []string +} + +type Config struct { + Ingress *IngressConfig `json:"ingress,omitempty"` + Webhook *WebhookConfig `json:"webhook,omitempty"` + Compute *ComputeConfig `json:"compute,omitempty"` + LogCollection *LogCollectionConfig `json:"logCollection,omitempty"` + + forceSendFields []string + nullFields []string +} + +type LogCollectionConfig struct { + CollectDriverLogs *bool `json:"collectDriverLogs,omitempty"` + + forceSendFields []string + nullFields []string +} + +type ComputeConfig struct { + UseTaints *bool `json:"useTaints,omitempty"` + CreateVngs *bool `json:"createVngs,omitempty"` + + forceSendFields []string + nullFields []string +} + +type WebhookConfig struct { + UseHostNetwork *bool `json:"useHostNetwork,omitempty"` + HostNetworkPorts []*int `json:"hostNetworkPorts,omitempty"` + + forceSendFields []string + nullFields []string +} + +type IngressConfig struct { + ServiceAnnotations map[string]string `json:"serviceAnnotations,omitempty"` + DeployIngress *bool `json:"deployIngress,omitempty"` + + forceSendFields []string + nullFields []string +} + +type ListClustersInput struct { + ControllerClusterID *string `json:"controllerClusterId,omitempty"` + ClusterState *string `json:"clusterState,omitempty"` +} + +type ListClustersOutput struct { + Clusters []*Cluster `json:"clusters,omitempty"` +} + +type ReadClusterInput struct { + ClusterID *string `json:"clusterId,omitempty"` +} + +type ReadClusterOutput struct { + Cluster *Cluster `json:"cluster,omitempty"` +} + +type CreateClusterInput struct { + Cluster *CreateClusterRequest `json:"cluster,omitempty"` +} + +type CreateClusterRequest struct { + OceanClusterID *string `json:"oceanClusterId,omitempty"` + Config *Config `json:"config,omitempty"` +} + +type CreateClusterOutput struct { + Cluster *Cluster `json:"cluster,omitempty"` +} + +type UpdateClusterInput struct { + ClusterID *string `json:"-"` + Cluster *UpdateClusterRequest `json:"cluster,omitempty"` +} + +type UpdateClusterRequest struct { + Config *Config `json:"config,omitempty"` +} + +type UpdateClusterOutput struct{} + +type DeleteClusterInput struct { + ClusterID *string `json:"clusterId,omitempty"` +} + +type DeleteClusterOutput struct{} + +// region Cluster + +func (c Cluster) MarshalJSON() ([]byte, error) { + type noMethod Cluster + raw := noMethod(c) + return jsonutil.MarshalJSON(raw, c.forceSendFields, c.nullFields) +} + +func (c *Cluster) SetConfig(v *Config) *Cluster { + if c.Config = v; c.Config == nil { + c.nullFields = append(c.nullFields, "Config") + } + return c +} + +// endregion + +// region Config + +func (c Config) MarshalJSON() ([]byte, error) { + type noMethod Config + raw := noMethod(c) + return jsonutil.MarshalJSON(raw, c.forceSendFields, c.nullFields) +} + +func (c *Config) SetIngress(v *IngressConfig) *Config { + if c.Ingress = v; c.Ingress == nil { + c.nullFields = append(c.nullFields, "Ingress") + } + return c +} + +func (c *Config) SetWebhook(v *WebhookConfig) *Config { + if c.Webhook = v; c.Webhook == nil { + c.nullFields = append(c.nullFields, "Webhook") + } + return c +} + +func (c *Config) SetCompute(v *ComputeConfig) *Config { + if c.Compute = v; c.Compute == nil { + c.nullFields = append(c.nullFields, "Compute") + } + return c +} + +func (c *Config) SetLogCollection(v *LogCollectionConfig) *Config { + if c.LogCollection = v; c.LogCollection == nil { + c.nullFields = append(c.nullFields, "LogCollection") + } + return c +} + +// endregion + +// region Ingress + +func (i IngressConfig) MarshalJSON() ([]byte, error) { + type noMethod IngressConfig + raw := noMethod(i) + return jsonutil.MarshalJSON(raw, i.forceSendFields, i.nullFields) +} + +func (i *IngressConfig) SetServiceAnnotations(v map[string]string) *IngressConfig { + if i.ServiceAnnotations = v; i.ServiceAnnotations == nil { + i.nullFields = append(i.nullFields, "ServiceAnnotations") + } + return i +} + +func (i *IngressConfig) SetDeployIngress(v *bool) *IngressConfig { + if i.DeployIngress = v; i.DeployIngress == nil { + i.nullFields = append(i.nullFields, "DeployIngress") + } + return i +} + +// endregion + +// region Webhook + +func (w WebhookConfig) MarshalJSON() ([]byte, error) { + type noMethod WebhookConfig + raw := noMethod(w) + return jsonutil.MarshalJSON(raw, w.forceSendFields, w.nullFields) +} + +func (w *WebhookConfig) SetUseHostNetwork(v *bool) *WebhookConfig { + if w.UseHostNetwork = v; w.UseHostNetwork == nil { + w.nullFields = append(w.nullFields, "UseHostNetwork") + } + return w +} + +func (w *WebhookConfig) SetHostNetworkPorts(v []*int) *WebhookConfig { + if w.HostNetworkPorts = v; w.HostNetworkPorts == nil { + w.nullFields = append(w.nullFields, "HostNetworkPorts") + } + return w +} + +// endregion + +// region Compute + +func (c ComputeConfig) MarshalJSON() ([]byte, error) { + type noMethod ComputeConfig + raw := noMethod(c) + return jsonutil.MarshalJSON(raw, c.forceSendFields, c.nullFields) +} + +func (c *ComputeConfig) SetUseTaints(v *bool) *ComputeConfig { + if c.UseTaints = v; c.UseTaints == nil { + c.nullFields = append(c.nullFields, "UseTaints") + } + return c +} + +func (c *ComputeConfig) SetCreateVNGs(v *bool) *ComputeConfig { + if c.CreateVngs = v; c.CreateVngs == nil { + c.nullFields = append(c.nullFields, "CreateVngs") + } + return c +} + +// endregion + +// region Log collection + +func (l LogCollectionConfig) MarshalJSON() ([]byte, error) { + type noMethod LogCollectionConfig + raw := noMethod(l) + return jsonutil.MarshalJSON(raw, l.forceSendFields, l.nullFields) +} + +func (l *LogCollectionConfig) SetCollectDriverLogs(v *bool) *LogCollectionConfig { + if l.CollectDriverLogs = v; l.CollectDriverLogs == nil { + l.nullFields = append(l.nullFields, "CollectDriverLogs") + } + return l +} + +// endregion diff --git a/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/spark/service.go b/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/spark/service.go new file mode 100644 index 00000000..9081a4c4 --- /dev/null +++ b/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/spark/service.go @@ -0,0 +1,41 @@ +package spark + +import ( + "context" + + "github.com/spotinst/spotinst-sdk-go/spotinst" + "github.com/spotinst/spotinst-sdk-go/spotinst/client" + "github.com/spotinst/spotinst-sdk-go/spotinst/session" +) + +// Service provides the API operation methods for making requests to endpoints +// of the Spotinst API. See this package's package overview docs for details on +// the service. +type Service interface { + ReadCluster(context.Context, *ReadClusterInput) (*ReadClusterOutput, error) + ListClusters(context.Context, *ListClustersInput) (*ListClustersOutput, error) + DeleteCluster(context.Context, *DeleteClusterInput) (*DeleteClusterOutput, error) + CreateCluster(context.Context, *CreateClusterInput) (*CreateClusterOutput, error) + UpdateCluster(context.Context, *UpdateClusterInput) (*UpdateClusterOutput, error) + DetachVirtualNodeGroup(context.Context, *DetachVngInput) (*DetachVngOutput, error) + AttachVirtualNodeGroup(context.Context, *AttachVngInput) (*AttachVngOutput, error) +} + +type ClusterManager interface { +} + +type ServiceOp struct { + Client *client.Client +} + +var _ Service = &ServiceOp{} + +func New(sess *session.Session, cfgs ...*spotinst.Config) *ServiceOp { + cfg := &spotinst.Config{} + cfg.Merge(sess.Config) + cfg.Merge(cfgs...) + + return &ServiceOp{ + Client: client.New(cfg), + } +} diff --git a/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/spark/spark.go b/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/spark/spark.go new file mode 100644 index 00000000..c14ebb9e --- /dev/null +++ b/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/spark/spark.go @@ -0,0 +1,272 @@ +package spark + +import ( + "context" + "encoding/json" + "fmt" + "github.com/spotinst/spotinst-sdk-go/spotinst" + "github.com/spotinst/spotinst-sdk-go/spotinst/client" + "github.com/spotinst/spotinst-sdk-go/spotinst/util/uritemplates" + "io/ioutil" + "net/http" +) + +//region Cluster +func (s *ServiceOp) ListClusters(ctx context.Context, input *ListClustersInput) (*ListClustersOutput, error) { + r := client.NewRequest(http.MethodGet, "/ocean/spark/cluster") + + if input != nil { + if input.ControllerClusterID != nil { + r.Params.Set("controllerClusterId", spotinst.StringValue(input.ControllerClusterID)) + } + + if input.ClusterState != nil { + r.Params.Set("state", spotinst.StringValue(input.ClusterState)) + } + } + + resp, err := client.RequireOK(s.Client.Do(ctx, r)) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + clusters, err := clustersFromHttpResponse(resp) + if err != nil { + return nil, err + } + + return &ListClustersOutput{Clusters: clusters}, nil +} + +func (s *ServiceOp) ReadCluster(ctx context.Context, input *ReadClusterInput) (*ReadClusterOutput, error) { + if input == nil { + return nil, fmt.Errorf("input is nil") + } + + path, err := uritemplates.Expand("/ocean/spark/cluster/{clusterId}", uritemplates.Values{ + "clusterId": spotinst.StringValue(input.ClusterID), + }) + if err != nil { + return nil, err + } + + r := client.NewRequest(http.MethodGet, path) + resp, err := client.RequireOK(s.Client.Do(ctx, r)) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + clusters, err := clustersFromHttpResponse(resp) + if err != nil { + return nil, err + } + + output := new(ReadClusterOutput) + if len(clusters) > 0 { + output.Cluster = clusters[0] + } + + return output, nil +} + +func (s *ServiceOp) DeleteCluster(ctx context.Context, input *DeleteClusterInput) (*DeleteClusterOutput, error) { + if input == nil { + return nil, fmt.Errorf("input is nil") + } + + path, err := uritemplates.Expand("/ocean/spark/cluster/{clusterId}", uritemplates.Values{ + "clusterId": spotinst.StringValue(input.ClusterID), + }) + if err != nil { + return nil, err + } + + r := client.NewRequest(http.MethodDelete, path) + + resp, err := client.RequireOK(s.Client.Do(ctx, r)) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + return &DeleteClusterOutput{}, nil +} + +func (s *ServiceOp) CreateCluster(ctx context.Context, input *CreateClusterInput) (*CreateClusterOutput, error) { + if input == nil { + return nil, fmt.Errorf("input is nil") + } + r := client.NewRequest(http.MethodPost, "/ocean/spark/cluster") + r.Obj = input + + resp, err := client.RequireOK(s.Client.Do(ctx, r)) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + gs, err := clustersFromHttpResponse(resp) + if err != nil { + return nil, err + } + + output := new(CreateClusterOutput) + if len(gs) > 0 { + output.Cluster = gs[0] + } + + return output, nil +} + +func (s *ServiceOp) UpdateCluster(ctx context.Context, input *UpdateClusterInput) (*UpdateClusterOutput, error) { + if input == nil { + return nil, fmt.Errorf("input is nil") + } + + path, err := uritemplates.Expand("/ocean/spark/cluster/{clusterId}", uritemplates.Values{ + "clusterId": spotinst.StringValue(input.ClusterID), + }) + if err != nil { + return nil, err + } + + r := client.NewRequest(http.MethodPut, path) + r.Obj = input + + resp, err := client.RequireOK(s.Client.Do(ctx, r)) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + return &UpdateClusterOutput{}, nil +} + +func clustersFromHttpResponse(resp *http.Response) ([]*Cluster, error) { + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, err + } + return clustersFromJSON(body) +} + +func clustersFromJSON(in []byte) ([]*Cluster, error) { + var rw client.Response + if err := json.Unmarshal(in, &rw); err != nil { + return nil, err + } + out := make([]*Cluster, len(rw.Response.Items)) + for i, rb := range rw.Response.Items { + b, err := clusterFromJSON(rb) + if err != nil { + return nil, err + } + out[i] = b + } + return out, nil +} + +func clusterFromJSON(in []byte) (*Cluster, error) { + b := new(Cluster) + if err := json.Unmarshal(in, b); err != nil { + return nil, err + } + return b, nil +} + +//endregion + +//region Virtual Node Group +func (s *ServiceOp) DetachVirtualNodeGroup(ctx context.Context, input *DetachVngInput) (*DetachVngOutput, error) { + if input == nil { + return nil, fmt.Errorf("input is nil") + } + + path, err := uritemplates.Expand("/ocean/spark/cluster/{clusterId}/virtualNodeGroup/{vngId}", uritemplates.Values{ + "clusterId": spotinst.StringValue(input.ClusterID), + "vngId": spotinst.StringValue(input.VngID), + }) + if err != nil { + return nil, err + } + + r := client.NewRequest(http.MethodDelete, path) + + resp, err := client.RequireOK(s.Client.Do(ctx, r)) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + return &DetachVngOutput{}, nil +} + +func (s *ServiceOp) AttachVirtualNodeGroup(ctx context.Context, input *AttachVngInput) (*AttachVngOutput, error) { + if input == nil { + return nil, fmt.Errorf("input is nil") + } + + path, err := uritemplates.Expand("/ocean/spark/cluster/{clusterId}/virtualNodeGroup", uritemplates.Values{ + "clusterId": spotinst.StringValue(input.ClusterID), + }) + if err != nil { + return nil, err + } + + r := client.NewRequest(http.MethodPost, path) + r.Obj = input + + resp, err := client.RequireOK(s.Client.Do(ctx, r)) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + gs, err := vngsFromHttpResponse(resp) + if err != nil { + return nil, err + } + + output := new(AttachVngOutput) + if len(gs) > 0 { + output.VirtualNodeGroup = gs[0] + } + + return output, nil +} + +func vngsFromHttpResponse(resp *http.Response) ([]*DedicatedVirtualNodeGroup, error) { + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, err + } + return vngsFromJSON(body) +} + +func vngsFromJSON(in []byte) ([]*DedicatedVirtualNodeGroup, error) { + var rw client.Response + if err := json.Unmarshal(in, &rw); err != nil { + return nil, err + } + out := make([]*DedicatedVirtualNodeGroup, len(rw.Response.Items)) + for i, rb := range rw.Response.Items { + b, err := vngFromJSON(rb) + if err != nil { + return nil, err + } + out[i] = b + } + return out, nil +} + +func vngFromJSON(in []byte) (*DedicatedVirtualNodeGroup, error) { + b := new(DedicatedVirtualNodeGroup) + if err := json.Unmarshal(in, b); err != nil { + return nil, err + } + return b, nil +} + +//endregion diff --git a/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/spark/vng.go b/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/spark/vng.go new file mode 100644 index 00000000..058a2e7a --- /dev/null +++ b/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/spark/vng.go @@ -0,0 +1,27 @@ +package spark + +type DedicatedVirtualNodeGroup struct { + OceanClusterID *string `json:"oceanClusterId,omitempty"` + OceanSparkClusterID *string `json:"oceanSparkClusterId,omitempty"` + VngID *string `json:"vngId,omitempty"` +} + +type AttachVirtualNodeGroupRequest struct { + VngID *string `json:"id,omitempty"` +} + +type AttachVngInput struct { + ClusterID *string `json:"-"` + VirtualNodeGroup *AttachVirtualNodeGroupRequest `json:"virtualNodeGroup,omitempty"` +} + +type AttachVngOutput struct { + VirtualNodeGroup *DedicatedVirtualNodeGroup `json:"virtualNodeGroup,omitempty"` +} + +type DetachVngInput struct { + ClusterID *string `json:"clusterId,omitempty"` + VngID *string `json:"vngId,omitempty"` +} + +type DetachVngOutput struct{} diff --git a/vendor/github.com/spotinst/spotinst-sdk-go/spotinst/version.go b/vendor/github.com/spotinst/spotinst-sdk-go/spotinst/version.go index e7d4d487..5b01a549 100644 --- a/vendor/github.com/spotinst/spotinst-sdk-go/spotinst/version.go +++ b/vendor/github.com/spotinst/spotinst-sdk-go/spotinst/version.go @@ -1,7 +1,7 @@ package spotinst // SDKVersion is the current version of the SDK. -const SDKVersion = "1.125.0" +const SDKVersion = "1.132.0" // SDKName is the name of the SDK. const SDKName = "spotinst-sdk-go" diff --git a/vendor/modules.txt b/vendor/modules.txt index 898c22aa..6b45d7ba 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -188,12 +188,13 @@ github.com/spf13/cobra # github.com/spf13/pflag v1.0.5 ## explicit github.com/spf13/pflag -# github.com/spotinst/spotinst-sdk-go v1.125.0 +# github.com/spotinst/spotinst-sdk-go v1.132.0 ## explicit github.com/spotinst/spotinst-sdk-go/service/ocean github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws github.com/spotinst/spotinst-sdk-go/service/ocean/providers/azure github.com/spotinst/spotinst-sdk-go/service/ocean/providers/gcp +github.com/spotinst/spotinst-sdk-go/service/ocean/spark github.com/spotinst/spotinst-sdk-go/spotinst github.com/spotinst/spotinst-sdk-go/spotinst/client github.com/spotinst/spotinst-sdk-go/spotinst/credentials