mirror of https://github.com/kubernetes/kops.git
chore(deps): upgrade spotinst-sdk-go to v1.43.0
This commit is contained in:
parent
a264f1d4d7
commit
1a8b99fca3
2
go.mod
2
go.mod
|
@ -115,7 +115,7 @@ require (
|
|||
github.com/spf13/cobra v0.0.5
|
||||
github.com/spf13/pflag v1.0.5
|
||||
github.com/spf13/viper v1.3.2
|
||||
github.com/spotinst/spotinst-sdk-go v1.36.1
|
||||
github.com/spotinst/spotinst-sdk-go v1.43.0
|
||||
github.com/stretchr/testify v1.4.0
|
||||
github.com/urfave/cli v1.20.0
|
||||
github.com/vmware/govmomi v0.20.1
|
||||
|
|
2
go.sum
2
go.sum
|
@ -455,6 +455,8 @@ github.com/spf13/viper v1.3.2 h1:VUFqw5KcqRf7i70GOzW7N+Q7+gxVBkSSqiXB12+JQ4M=
|
|||
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||
github.com/spotinst/spotinst-sdk-go v1.36.1 h1:3qTOIV+c0eCg/LDMchNCaeY3UOp2fRr90JtmkoXl624=
|
||||
github.com/spotinst/spotinst-sdk-go v1.36.1/go.mod h1:nWi2DyjUi1WUZclpsqZFXvImsU0T39ppqqHwC4/T5mw=
|
||||
github.com/spotinst/spotinst-sdk-go v1.43.0 h1:ba5LQrYHQaq6TeC2JR3Hau7pbymVFScj3zoDxhbRphs=
|
||||
github.com/spotinst/spotinst-sdk-go v1.43.0/go.mod h1:nWi2DyjUi1WUZclpsqZFXvImsU0T39ppqqHwC4/T5mw=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
|
|
95
vendor/github.com/spotinst/spotinst-sdk-go/service/elastigroup/providers/aws/aws.go
generated
vendored
95
vendor/github.com/spotinst/spotinst-sdk-go/service/elastigroup/providers/aws/aws.go
generated
vendored
|
@ -696,9 +696,21 @@ type Instance struct {
|
|||
}
|
||||
|
||||
type RollStrategy struct {
|
||||
Action *string `json:"action,omitempty"`
|
||||
ShouldDrainInstances *bool `json:"shouldDrainInstances,omitempty"`
|
||||
BatchMinHealthyPercentage *int `json:"batchMinHealthyPercentage,omitempty"`
|
||||
Action *string `json:"action,omitempty"`
|
||||
ShouldDrainInstances *bool `json:"shouldDrainInstances,omitempty"`
|
||||
BatchMinHealthyPercentage *int `json:"batchMinHealthyPercentage,omitempty"`
|
||||
OnFailure *OnFailure `json:"onFailure,omitempty"`
|
||||
|
||||
forceSendFields []string
|
||||
nullFields []string
|
||||
}
|
||||
|
||||
type OnFailure struct {
|
||||
ActionType *string `json:"actionType,omitempty"`
|
||||
ShouldHandleAllBatches *bool `json:"shouldHandleAllBatches,omitempty"`
|
||||
BatchNum *int `json:"batchNum,omitempty"`
|
||||
DrainingTimeout *int `json:"drainingTimeout,omitempty"`
|
||||
ShouldDecrementTargetCapacity *bool `json:"shouldDecrementTargetCapacity,omitempty"`
|
||||
|
||||
forceSendFields []string
|
||||
nullFields []string
|
||||
|
@ -1252,6 +1264,31 @@ func (s *ServiceOp) DeploymentStatus(ctx context.Context, input *DeploymentStatu
|
|||
return &RollGroupOutput{deployments}, nil
|
||||
}
|
||||
|
||||
func (s *ServiceOp) DeploymentStatusECS(ctx context.Context, input *DeploymentStatusInput) (*RollGroupOutput, error) {
|
||||
path, err := uritemplates.Expand("/aws/ec2/group/{groupId}/clusterRoll/{rollId}", uritemplates.Values{
|
||||
"groupId": spotinst.StringValue(input.GroupID),
|
||||
"rollId": spotinst.StringValue(input.RollID),
|
||||
})
|
||||
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()
|
||||
|
||||
deployments, err := deploymentStatusFromHttpResponse(resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &RollGroupOutput{deployments}, nil
|
||||
}
|
||||
|
||||
func (s *ServiceOp) StopDeployment(ctx context.Context, input *StopDeploymentInput) (*StopDeploymentOutput, error) {
|
||||
path, err := uritemplates.Expand("/aws/ec2/group/{groupId}/roll/{rollId}", uritemplates.Values{
|
||||
"groupId": spotinst.StringValue(input.GroupID),
|
||||
|
@ -3736,6 +3773,58 @@ func (o *RollStrategy) SetShouldDrainInstances(v *bool) *RollStrategy {
|
|||
return o
|
||||
}
|
||||
|
||||
func (o *RollStrategy) SetOnFailure(v *OnFailure) *RollStrategy {
|
||||
if o.OnFailure = v; o.OnFailure == nil {
|
||||
o.nullFields = append(o.nullFields, "OnFailure")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region RollStrategy
|
||||
|
||||
func (o OnFailure) MarshalJSON() ([]byte, error) {
|
||||
type noMethod OnFailure
|
||||
raw := noMethod(o)
|
||||
return jsonutil.MarshalJSON(raw, o.forceSendFields, o.nullFields)
|
||||
}
|
||||
|
||||
func (o *OnFailure) SetActionType(v *string) *OnFailure {
|
||||
if o.ActionType = v; o.ActionType == nil {
|
||||
o.nullFields = append(o.nullFields, "ActionType")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *OnFailure) SetShouldHandleAllBatches(v *bool) *OnFailure {
|
||||
if o.ShouldHandleAllBatches = v; o.ShouldHandleAllBatches == nil {
|
||||
o.nullFields = append(o.nullFields, "ShouldHandleAllBatches")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *OnFailure) SetBatchNum(v *int) *OnFailure {
|
||||
if o.BatchNum = v; o.BatchNum == nil {
|
||||
o.nullFields = append(o.nullFields, "BatchNum")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *OnFailure) SetDrainingTimeout(v *int) *OnFailure {
|
||||
if o.DrainingTimeout = v; o.DrainingTimeout == nil {
|
||||
o.nullFields = append(o.nullFields, "DrainingTimeout")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *OnFailure) SetShouldDecrementTargetCapacity(v *bool) *OnFailure {
|
||||
if o.ShouldDecrementTargetCapacity = v; o.ShouldDecrementTargetCapacity == nil {
|
||||
o.nullFields = append(o.nullFields, "ShouldDecrementTargetCapacity")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region CodeDeployIntegration
|
||||
|
|
|
@ -19,6 +19,7 @@ type Service interface {
|
|||
Delete(context.Context, *DeleteGroupInput) (*DeleteGroupOutput, error)
|
||||
Status(context.Context, *StatusGroupInput) (*StatusGroupOutput, error)
|
||||
DeploymentStatus(context.Context, *DeploymentStatusInput) (*RollGroupOutput, error)
|
||||
DeploymentStatusECS(context.Context, *DeploymentStatusInput) (*RollGroupOutput, error)
|
||||
StopDeployment(context.Context, *StopDeploymentInput) (*StopDeploymentOutput, error)
|
||||
Detach(context.Context, *DetachGroupInput) (*DetachGroupOutput, error)
|
||||
Roll(context.Context, *RollGroupInput) (*RollGroupOutput, error)
|
||||
|
|
1
vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/BUILD.bazel
generated
vendored
1
vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/BUILD.bazel
generated
vendored
|
@ -8,6 +8,7 @@ go_library(
|
|||
"launch_spec_ecs.go",
|
||||
"ocean.go",
|
||||
"ocean_ecs.go",
|
||||
"right_sizing.go",
|
||||
"service.go",
|
||||
"tag.go",
|
||||
],
|
||||
|
|
16
vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/launch_spec.go
generated
vendored
16
vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/launch_spec.go
generated
vendored
|
@ -19,12 +19,14 @@ type LaunchSpec struct {
|
|||
OceanID *string `json:"oceanId,omitempty"`
|
||||
ImageID *string `json:"imageId,omitempty"`
|
||||
UserData *string `json:"userData,omitempty"`
|
||||
RootVolumeSize *int `json:"rootVolumeSize,omitempty"`
|
||||
SecurityGroupIDs []string `json:"securityGroupIds,omitempty"`
|
||||
SubnetIDs []string `json:"subnetIds,omitempty"`
|
||||
IAMInstanceProfile *IAMInstanceProfile `json:"iamInstanceProfile,omitempty"`
|
||||
Labels []*Label `json:"labels,omitempty"`
|
||||
Taints []*Taint `json:"taints,omitempty"`
|
||||
AutoScale *AutoScale `json:"autoScale,omitempty"`
|
||||
Tags []*Tag `json:"tags,omitempty"`
|
||||
|
||||
// Read-only fields.
|
||||
CreatedAt *time.Time `json:"createdAt,omitempty"`
|
||||
|
@ -337,6 +339,13 @@ func (o *LaunchSpec) SetSubnetIDs(v []string) *LaunchSpec {
|
|||
return o
|
||||
}
|
||||
|
||||
func (o *LaunchSpec) SetRootVolumeSize(v *int) *LaunchSpec {
|
||||
if o.RootVolumeSize = v; o.RootVolumeSize == nil {
|
||||
o.nullFields = append(o.nullFields, "RootVolumeSize")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *LaunchSpec) SetIAMInstanceProfile(v *IAMInstanceProfile) *LaunchSpec {
|
||||
if o.IAMInstanceProfile = v; o.IAMInstanceProfile == nil {
|
||||
o.nullFields = append(o.nullFields, "IAMInstanceProfile")
|
||||
|
@ -475,4 +484,11 @@ func (o *AutoScaleHeadroom) SetNumOfUnits(v *int) *AutoScaleHeadroom {
|
|||
return o
|
||||
}
|
||||
|
||||
func (o *LaunchSpec) SetTags(v []*Tag) *LaunchSpec {
|
||||
if o.Tags = v; o.Tags == nil {
|
||||
o.nullFields = append(o.nullFields, "Tags")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
|
|
@ -23,6 +23,7 @@ type ECSLaunchSpec struct {
|
|||
IAMInstanceProfile *ECSIAMInstanceProfile `json:"iamInstanceProfile,omitempty"`
|
||||
Attributes []*ECSAttribute `json:"attributes,omitempty"`
|
||||
AutoScale *ECSAutoScale `json:"autoScale,omitempty"`
|
||||
Tags []*Tag `json:"tags,omitempty"`
|
||||
|
||||
// Read-only fields.
|
||||
CreatedAt *time.Time `json:"createdAt,omitempty"`
|
||||
|
@ -339,6 +340,13 @@ func (o *ECSLaunchSpec) SetAutoScale(v *ECSAutoScale) *ECSLaunchSpec {
|
|||
return o
|
||||
}
|
||||
|
||||
func (o *ECSLaunchSpec) SetTags(v []*Tag) *ECSLaunchSpec {
|
||||
if o.Tags = v; o.Tags == nil {
|
||||
o.nullFields = append(o.nullFields, "Tags")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Attributes
|
||||
|
|
175
vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/ocean.go
generated
vendored
175
vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/ocean.go
generated
vendored
|
@ -21,6 +21,7 @@ type Cluster struct {
|
|||
Strategy *Strategy `json:"strategy,omitempty"`
|
||||
Capacity *Capacity `json:"capacity,omitempty"`
|
||||
Compute *Compute `json:"compute,omitempty"`
|
||||
Scheduling *Scheduling `json:"scheduling,omitempty"`
|
||||
AutoScaler *AutoScaler `json:"autoScaler,omitempty"`
|
||||
|
||||
// Read-only fields.
|
||||
|
@ -72,6 +73,31 @@ type Compute struct {
|
|||
nullFields []string
|
||||
}
|
||||
|
||||
type Scheduling struct {
|
||||
ShutdownHours *ShutdownHours `json:"shutdownHours,omitempty"`
|
||||
Tasks []*Task `json:"tasks,omitempty"`
|
||||
|
||||
forceSendFields []string
|
||||
nullFields []string
|
||||
}
|
||||
|
||||
type ShutdownHours struct {
|
||||
IsEnabled *bool `json:"isEnabled,omitempty"`
|
||||
TimeWindows []string `json:"timeWindows,omitempty"`
|
||||
|
||||
forceSendFields []string
|
||||
nullFields []string
|
||||
}
|
||||
|
||||
type Task struct {
|
||||
IsEnabled *bool `json:"isEnabled,omitempty"`
|
||||
Type *string `json:"taskType,omitempty"`
|
||||
CronExpression *string `json:"cronExpression,omitempty"`
|
||||
|
||||
forceSendFields []string
|
||||
nullFields []string
|
||||
}
|
||||
|
||||
type InstanceTypes struct {
|
||||
Whitelist []string `json:"whitelist,omitempty"`
|
||||
Blacklist []string `json:"blacklist,omitempty"`
|
||||
|
@ -115,12 +141,13 @@ type LoadBalancer struct {
|
|||
}
|
||||
|
||||
type AutoScaler struct {
|
||||
IsEnabled *bool `json:"isEnabled,omitempty"`
|
||||
IsAutoConfig *bool `json:"isAutoConfig,omitempty"`
|
||||
Cooldown *int `json:"cooldown,omitempty"`
|
||||
Headroom *AutoScalerHeadroom `json:"headroom,omitempty"`
|
||||
ResourceLimits *AutoScalerResourceLimits `json:"resourceLimits,omitempty"`
|
||||
Down *AutoScalerDown `json:"down,omitempty"`
|
||||
IsEnabled *bool `json:"isEnabled,omitempty"`
|
||||
IsAutoConfig *bool `json:"isAutoConfig,omitempty"`
|
||||
Cooldown *int `json:"cooldown,omitempty"`
|
||||
AutoHeadroomPercentage *int `json:"autoHeadroomPercentage,omitempty"`
|
||||
Headroom *AutoScalerHeadroom `json:"headroom,omitempty"`
|
||||
ResourceLimits *AutoScalerResourceLimits `json:"resourceLimits,omitempty"`
|
||||
Down *AutoScalerDown `json:"down,omitempty"`
|
||||
|
||||
forceSendFields []string
|
||||
nullFields []string
|
||||
|
@ -145,7 +172,8 @@ type AutoScalerResourceLimits struct {
|
|||
}
|
||||
|
||||
type AutoScalerDown struct {
|
||||
EvaluationPeriods *int `json:"evaluationPeriods,omitempty"`
|
||||
EvaluationPeriods *int `json:"evaluationPeriods,omitempty"`
|
||||
MaxScaleDownPercentage *int `json:"maxScaleDownPercentage,omitempty"`
|
||||
|
||||
forceSendFields []string
|
||||
nullFields []string
|
||||
|
@ -253,19 +281,37 @@ func clustersFromHttpResponse(resp *http.Response) ([]*Cluster, error) {
|
|||
|
||||
func rollStatusFromJSON(in []byte) (*RollClusterStatus, error) {
|
||||
b := new(RollClusterStatus)
|
||||
|
||||
if err := json.Unmarshal(in, b); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func rollStatusFromHttpResponse(resp *http.Response) (*RollClusterStatus, error) {
|
||||
func rollStatusesFromJSON(in []byte) ([]*RollClusterStatus, error) {
|
||||
var rw client.Response
|
||||
if err := json.Unmarshal(in, &rw); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out := make([]*RollClusterStatus, len(rw.Response.Items))
|
||||
if len(out) == 0 {
|
||||
return out, nil
|
||||
}
|
||||
for i, rb := range rw.Response.Items {
|
||||
b, err := rollStatusFromJSON(rb)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out[i] = b
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func rollStatusesFromHttpResponse(resp *http.Response) ([]*RollClusterStatus, error) {
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rollStatusFromJSON(body)
|
||||
return rollStatusesFromJSON(body)
|
||||
}
|
||||
|
||||
func (s *ServiceOp) ListClusters(ctx context.Context, input *ListClustersInput) (*ListClustersOutput, error) {
|
||||
|
@ -407,12 +453,17 @@ func (s *ServiceOp) Roll(ctx context.Context, input *RollClusterInput) (*RollClu
|
|||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
_, err = rollStatusFromHttpResponse(resp)
|
||||
rs, err := rollStatusesFromHttpResponse(resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &RollClusterOutput{}, nil
|
||||
output := new(RollClusterOutput)
|
||||
if len(rs) > 0 {
|
||||
output.RollClusterStatus = rs[0]
|
||||
}
|
||||
|
||||
return output, nil
|
||||
}
|
||||
|
||||
// region Cluster
|
||||
|
@ -472,6 +523,13 @@ func (o *Cluster) SetCompute(v *Compute) *Cluster {
|
|||
return o
|
||||
}
|
||||
|
||||
func (o *Cluster) SetScheduling(v *Scheduling) *Cluster {
|
||||
if o.Scheduling = v; o.Scheduling == nil {
|
||||
o.nullFields = append(o.nullFields, "Scheduling")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *Cluster) SetAutoScaler(v *AutoScaler) *Cluster {
|
||||
if o.AutoScaler = v; o.AutoScaler == nil {
|
||||
o.nullFields = append(o.nullFields, "AutoScaler")
|
||||
|
@ -581,6 +639,85 @@ func (o *Compute) SetSubnetIDs(v []string) *Compute {
|
|||
|
||||
// endregion
|
||||
|
||||
// region Scheduling
|
||||
|
||||
func (o Scheduling) MarshalJSON() ([]byte, error) {
|
||||
type noMethod Scheduling
|
||||
raw := noMethod(o)
|
||||
return jsonutil.MarshalJSON(raw, o.forceSendFields, o.nullFields)
|
||||
}
|
||||
|
||||
func (o *Scheduling) SetShutdownHours(v *ShutdownHours) *Scheduling {
|
||||
if o.ShutdownHours = v; o.ShutdownHours == nil {
|
||||
o.nullFields = append(o.nullFields, "ShutdownHours")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *Scheduling) SetTasks(v []*Task) *Scheduling {
|
||||
if o.Tasks = v; o.Tasks == nil {
|
||||
o.nullFields = append(o.nullFields, "Tasks")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Tasks
|
||||
|
||||
func (o Task) MarshalJSON() ([]byte, error) {
|
||||
type noMethod Task
|
||||
raw := noMethod(o)
|
||||
return jsonutil.MarshalJSON(raw, o.forceSendFields, o.nullFields)
|
||||
}
|
||||
|
||||
func (o *Task) SetIsEnabled(v *bool) *Task {
|
||||
if o.IsEnabled = v; o.IsEnabled == nil {
|
||||
o.nullFields = append(o.nullFields, "IsEnabled")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *Task) SetType(v *string) *Task {
|
||||
if o.Type = v; o.Type == nil {
|
||||
o.nullFields = append(o.nullFields, "Type")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *Task) SetCronExpression(v *string) *Task {
|
||||
if o.CronExpression = v; o.CronExpression == nil {
|
||||
o.nullFields = append(o.nullFields, "CronExpression")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region ShutdownHours
|
||||
|
||||
func (o ShutdownHours) MarshalJSON() ([]byte, error) {
|
||||
type noMethod ShutdownHours
|
||||
raw := noMethod(o)
|
||||
return jsonutil.MarshalJSON(raw, o.forceSendFields, o.nullFields)
|
||||
}
|
||||
|
||||
func (o *ShutdownHours) SetIsEnabled(v *bool) *ShutdownHours {
|
||||
if o.IsEnabled = v; o.IsEnabled == nil {
|
||||
o.nullFields = append(o.nullFields, "IsEnabled")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *ShutdownHours) SetTimeWindows(v []string) *ShutdownHours {
|
||||
if o.TimeWindows = v; o.TimeWindows == nil {
|
||||
o.nullFields = append(o.nullFields, "TimeWindows")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region InstanceTypes
|
||||
|
||||
func (o InstanceTypes) MarshalJSON() ([]byte, error) {
|
||||
|
@ -770,6 +907,13 @@ func (o *AutoScaler) SetCooldown(v *int) *AutoScaler {
|
|||
return o
|
||||
}
|
||||
|
||||
func (o *AutoScaler) SetAutoHeadroomPercentage(v *int) *AutoScaler {
|
||||
if o.AutoHeadroomPercentage = v; o.AutoHeadroomPercentage == nil {
|
||||
o.nullFields = append(o.nullFields, "AutoHeadroomPercentage")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *AutoScaler) SetHeadroom(v *AutoScalerHeadroom) *AutoScaler {
|
||||
if o.Headroom = v; o.Headroom == nil {
|
||||
o.nullFields = append(o.nullFields, "Headroom")
|
||||
|
@ -870,4 +1014,11 @@ func (o *AutoScalerDown) SetEvaluationPeriods(v *int) *AutoScalerDown {
|
|||
return o
|
||||
}
|
||||
|
||||
func (o *AutoScalerDown) SetMaxScaleDownPercentage(v *int) *AutoScalerDown {
|
||||
if o.MaxScaleDownPercentage = v; o.MaxScaleDownPercentage == nil {
|
||||
o.nullFields = append(o.nullFields, "MaxScaleDownPercentage")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
|
145
vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/ocean_ecs.go
generated
vendored
145
vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/ocean_ecs.go
generated
vendored
|
@ -22,6 +22,7 @@ type ECSCluster struct {
|
|||
Compute *ECSCompute `json:"compute,omitempty"`
|
||||
AutoScaler *ECSAutoScaler `json:"autoScaler,omitempty"`
|
||||
Strategy *ECSStrategy `json:"strategy,omitempty"`
|
||||
Scheduling *ECSScheduling `json:"scheduling,omitempty"`
|
||||
|
||||
// Read-only fields.
|
||||
CreatedAt *time.Time `json:"createdAt,omitempty"`
|
||||
|
@ -52,6 +53,31 @@ type ECSStrategy struct {
|
|||
nullFields []string
|
||||
}
|
||||
|
||||
type ECSScheduling struct {
|
||||
Tasks []*ECSTask `json:"tasks,omitempty"`
|
||||
ShutdownHours *ECSShutdownHours `json:"shutdownHours,omitempty"`
|
||||
|
||||
forceSendFields []string
|
||||
nullFields []string
|
||||
}
|
||||
|
||||
type ECSShutdownHours struct {
|
||||
IsEnabled *bool `json:"isEnabled,omitempty"`
|
||||
TimeWindows []string `json:"timeWindows,omitempty"`
|
||||
|
||||
forceSendFields []string
|
||||
nullFields []string
|
||||
}
|
||||
|
||||
type ECSTask struct {
|
||||
IsEnabled *bool `json:"isEnabled,omitempty"`
|
||||
Type *string `json:"taskType,omitempty"`
|
||||
CronExpression *string `json:"cronExpression,omitempty"`
|
||||
|
||||
forceSendFields []string
|
||||
nullFields []string
|
||||
}
|
||||
|
||||
type ECSCapacity struct {
|
||||
Minimum *int `json:"minimum,omitempty"`
|
||||
Maximum *int `json:"maximum,omitempty"`
|
||||
|
@ -238,19 +264,37 @@ func ecsClustersFromHttpResponse(resp *http.Response) ([]*ECSCluster, error) {
|
|||
|
||||
func ecsRollStatusFromJSON(in []byte) (*ECSRollClusterStatus, error) {
|
||||
b := new(ECSRollClusterStatus)
|
||||
|
||||
if err := json.Unmarshal(in, b); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func ecsRollStatusFromHttpResponse(resp *http.Response) (*ECSRollClusterStatus, error) {
|
||||
func ecsRollStatusesFromJSON(in []byte) ([]*ECSRollClusterStatus, error) {
|
||||
var rw client.Response
|
||||
if err := json.Unmarshal(in, &rw); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out := make([]*ECSRollClusterStatus, len(rw.Response.Items))
|
||||
if len(out) == 0 {
|
||||
return out, nil
|
||||
}
|
||||
for i, rb := range rw.Response.Items {
|
||||
b, err := ecsRollStatusFromJSON(rb)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out[i] = b
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func ecsRollStatusesFromHttpResponse(resp *http.Response) ([]*ECSRollClusterStatus, error) {
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ecsRollStatusFromJSON(body)
|
||||
return ecsRollStatusesFromJSON(body)
|
||||
}
|
||||
|
||||
func (s *ServiceOp) ListECSClusters(ctx context.Context, input *ListECSClustersInput) (*ListECSClustersOutput, error) {
|
||||
|
@ -392,12 +436,17 @@ func (s *ServiceOp) RollECS(ctx context.Context, input *ECSRollClusterInput) (*E
|
|||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
_, err = ecsRollStatusFromHttpResponse(resp)
|
||||
rs, err := ecsRollStatusesFromHttpResponse(resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &ECSRollClusterOutput{}, nil
|
||||
output := new(ECSRollClusterOutput)
|
||||
if len(rs) > 0 {
|
||||
output.RollClusterStatus = rs[0]
|
||||
}
|
||||
|
||||
return output, nil
|
||||
}
|
||||
|
||||
// region Cluster
|
||||
|
@ -491,6 +540,92 @@ func (o *ECSCluster) SetAutoScaler(v *ECSAutoScaler) *ECSCluster {
|
|||
return o
|
||||
}
|
||||
|
||||
func (o *ECSCluster) SetScheduling(v *ECSScheduling) *ECSCluster {
|
||||
if o.Scheduling = v; o.Scheduling == nil {
|
||||
o.nullFields = append(o.nullFields, "Scheduling")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Scheduling
|
||||
|
||||
func (o ECSScheduling) MarshalJSON() ([]byte, error) {
|
||||
type noMethod ECSScheduling
|
||||
raw := noMethod(o)
|
||||
return jsonutil.MarshalJSON(raw, o.forceSendFields, o.nullFields)
|
||||
}
|
||||
|
||||
func (o *ECSScheduling) SetTasks(v []*ECSTask) *ECSScheduling {
|
||||
if o.Tasks = v; o.Tasks == nil {
|
||||
o.nullFields = append(o.nullFields, "Tasks")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *ECSScheduling) SetShutdownHours(v *ECSShutdownHours) *ECSScheduling {
|
||||
if o.ShutdownHours = v; o.ShutdownHours == nil {
|
||||
o.nullFields = append(o.nullFields, "ShutdownHours")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region ShutdownHours
|
||||
|
||||
func (o ECSShutdownHours) MarshalJSON() ([]byte, error) {
|
||||
type noMethod ECSShutdownHours
|
||||
raw := noMethod(o)
|
||||
return jsonutil.MarshalJSON(raw, o.forceSendFields, o.nullFields)
|
||||
}
|
||||
|
||||
func (o *ECSShutdownHours) SetIsEnabled(v *bool) *ECSShutdownHours {
|
||||
if o.IsEnabled = v; o.IsEnabled == nil {
|
||||
o.nullFields = append(o.nullFields, "IsEnabled")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *ECSShutdownHours) SetTimeWindows(v []string) *ECSShutdownHours {
|
||||
if o.TimeWindows = v; o.TimeWindows == nil {
|
||||
o.nullFields = append(o.nullFields, "TimeWindows")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Tasks
|
||||
|
||||
func (o ECSTask) MarshalJSON() ([]byte, error) {
|
||||
type noMethod ECSTask
|
||||
raw := noMethod(o)
|
||||
return jsonutil.MarshalJSON(raw, o.forceSendFields, o.nullFields)
|
||||
}
|
||||
|
||||
func (o *ECSTask) SetIsEnabled(v *bool) *ECSTask {
|
||||
if o.IsEnabled = v; o.IsEnabled == nil {
|
||||
o.nullFields = append(o.nullFields, "IsEnabled")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *ECSTask) SetType(v *string) *ECSTask {
|
||||
if o.Type = v; o.Type == nil {
|
||||
o.nullFields = append(o.nullFields, "Type")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *ECSTask) SetCronExpression(v *string) *ECSTask {
|
||||
if o.CronExpression = v; o.CronExpression == nil {
|
||||
o.nullFields = append(o.nullFields, "CronExpression")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Compute
|
||||
|
|
89
vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/right_sizing.go
generated
vendored
Normal file
89
vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/right_sizing.go
generated
vendored
Normal file
|
@ -0,0 +1,89 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"github.com/spotinst/spotinst-sdk-go/spotinst"
|
||||
"github.com/spotinst/spotinst-sdk-go/spotinst/client"
|
||||
"github.com/spotinst/spotinst-sdk-go/spotinst/util/uritemplates"
|
||||
)
|
||||
|
||||
// ResourceSuggestion represents a single resource suggestion.
|
||||
type ResourceSuggestion struct {
|
||||
DeploymentName *string `json:"deploymentName,omitempty"`
|
||||
Namespace *string `json:"namespace,omitempty"`
|
||||
SuggestedCPU *int `json:"suggestedCPU,omitempty"`
|
||||
RequestedCPU *int `json:"requestedCPU,omitempty"`
|
||||
SuggestedMemory *int `json:"suggestedMemory,omitempty"`
|
||||
RequestedMemory *int `json:"requestedMemory,omitempty"`
|
||||
}
|
||||
|
||||
// ListResourceSuggestionsInput represents the input of `ListResourceSuggestions` function.
|
||||
type ListResourceSuggestionsInput struct {
|
||||
OceanID *string `json:"oceanId,omitempty"`
|
||||
}
|
||||
|
||||
// ListResourceSuggestionsOutput represents the output of `ListResourceSuggestions` function.
|
||||
type ListResourceSuggestionsOutput struct {
|
||||
Suggestions []*ResourceSuggestion `json:"suggestions,omitempty"`
|
||||
}
|
||||
|
||||
func resourceSuggestionFromJSON(in []byte) (*ResourceSuggestion, error) {
|
||||
b := new(ResourceSuggestion)
|
||||
if err := json.Unmarshal(in, b); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func resourceSuggestionsFromJSON(in []byte) ([]*ResourceSuggestion, error) {
|
||||
var rw client.Response
|
||||
if err := json.Unmarshal(in, &rw); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out := make([]*ResourceSuggestion, len(rw.Response.Items))
|
||||
for i, rb := range rw.Response.Items {
|
||||
b, err := resourceSuggestionFromJSON(rb)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out[i] = b
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func resourceSuggestionsFromHTTPResponse(resp *http.Response) ([]*ResourceSuggestion, error) {
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resourceSuggestionsFromJSON(body)
|
||||
}
|
||||
|
||||
// ListResourceSuggestions returns a list of right-sizing resource suggestions
|
||||
// for an Ocean cluster.
|
||||
func (s *ServiceOp) ListResourceSuggestions(ctx context.Context, input *ListResourceSuggestionsInput) (*ListResourceSuggestionsOutput, error) {
|
||||
path, err := uritemplates.Expand("/ocean/aws/k8s/cluster/{oceanId}/rightSizing/resourceSuggestion", uritemplates.Values{
|
||||
"oceanId": spotinst.StringValue(input.OceanID),
|
||||
})
|
||||
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()
|
||||
|
||||
gs, err := resourceSuggestionsFromHTTPResponse(resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &ListResourceSuggestionsOutput{Suggestions: gs}, nil
|
||||
}
|
2
vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/service.go
generated
vendored
2
vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/service.go
generated
vendored
|
@ -41,6 +41,8 @@ type Service interface {
|
|||
DeleteECSLaunchSpec(context.Context, *DeleteECSLaunchSpecInput) (*DeleteECSLaunchSpecOutput, error)
|
||||
|
||||
RollECS(context.Context, *ECSRollClusterInput) (*ECSRollClusterOutput, error)
|
||||
|
||||
ListResourceSuggestions(context.Context, *ListResourceSuggestionsInput) (*ListResourceSuggestionsOutput, error)
|
||||
}
|
||||
|
||||
type ServiceOp struct {
|
||||
|
|
153
vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/gcp/ocean.go
generated
vendored
153
vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/gcp/ocean.go
generated
vendored
|
@ -3,24 +3,26 @@ package gcp
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/spotinst/spotinst-sdk-go/spotinst"
|
||||
"github.com/spotinst/spotinst-sdk-go/spotinst/client"
|
||||
"github.com/spotinst/spotinst-sdk-go/spotinst/util/jsonutil"
|
||||
"github.com/spotinst/spotinst-sdk-go/spotinst/util/uritemplates"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Cluster struct {
|
||||
ID *string `json:"id,omitempty"`
|
||||
ControllerClusterID *string `json:"controllerClusterId,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
Scheduling *Scheduling `json:"scheduling,omitempty"`
|
||||
AutoScaler *AutoScaler `json:"autoScaler,omitempty"`
|
||||
Capacity *Capacity `json:"capacity,omitempty"`
|
||||
Compute *Compute `json:"compute,omitempty"`
|
||||
Strategy *Strategy `json:"strategy,omitempty"`
|
||||
ControllerClusterID *string `json:"controllerClusterId,omitempty"`
|
||||
GKE *GKE `json:"gke,omitempty"`
|
||||
ID *string `json:"id,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
|
||||
// Read-only fields.
|
||||
CreatedAt *time.Time `json:"createdAt,omitempty"`
|
||||
|
@ -51,12 +53,13 @@ type Strategy struct {
|
|||
}
|
||||
|
||||
type AutoScaler struct {
|
||||
IsEnabled *bool `json:"isEnabled,omitempty"`
|
||||
IsAutoConfig *bool `json:"isAutoConfig,omitempty"`
|
||||
Cooldown *int `json:"cooldown,omitempty"`
|
||||
Headroom *AutoScalerHeadroom `json:"headroom,omitempty"`
|
||||
ResourceLimits *AutoScalerResourceLimits `json:"resourceLimits,omitempty"`
|
||||
Down *AutoScalerDown `json:"down,omitempty"`
|
||||
IsEnabled *bool `json:"isEnabled,omitempty"`
|
||||
IsAutoConfig *bool `json:"isAutoConfig,omitempty"`
|
||||
Cooldown *int `json:"cooldown,omitempty"`
|
||||
AutoHeadroomPercentage *int `json:"autoHeadroomPercentage,omitempty"`
|
||||
Headroom *AutoScalerHeadroom `json:"headroom,omitempty"`
|
||||
ResourceLimits *AutoScalerResourceLimits `json:"resourceLimits,omitempty"`
|
||||
Down *AutoScalerDown `json:"down,omitempty"`
|
||||
|
||||
forceSendFields []string
|
||||
nullFields []string
|
||||
|
@ -119,6 +122,32 @@ type Compute struct {
|
|||
nullFields []string
|
||||
}
|
||||
|
||||
type Scheduling struct {
|
||||
ShutdownHours *ShutdownHours `json:"shutdownHours,omitempty"`
|
||||
Tasks []*Task `json:"tasks,omitempty"`
|
||||
|
||||
forceSendFields []string
|
||||
nullFields []string
|
||||
}
|
||||
|
||||
type ShutdownHours struct {
|
||||
IsEnabled *bool `json:"isEnabled,omitempty"`
|
||||
TimeWindows []string `json:"timeWindows,omitempty"`
|
||||
|
||||
forceSendFields []string
|
||||
nullFields []string
|
||||
}
|
||||
|
||||
type Task struct {
|
||||
IsEnabled *bool `json:"isEnabled,omitempty"`
|
||||
Type *string `json:"taskType,omitempty"`
|
||||
CronExpression *string `json:"cronExpression,omitempty"`
|
||||
BatchSizePercentage *int `json:"batchSizePercentage,omitempty"`
|
||||
|
||||
forceSendFields []string
|
||||
nullFields []string
|
||||
}
|
||||
|
||||
type GKE struct {
|
||||
ClusterName *string `json:"clusterName,omitempty"`
|
||||
MasterLocation *string `json:"masterLocation,omitempty"`
|
||||
|
@ -506,6 +535,13 @@ func (o *Cluster) SetGKE(v *GKE) *Cluster {
|
|||
return o
|
||||
}
|
||||
|
||||
func (o *Cluster) SetScheduling(v *Scheduling) *Cluster {
|
||||
if o.Scheduling = v; o.Scheduling == nil {
|
||||
o.nullFields = append(o.nullFields, "Scheduling")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region GKE
|
||||
|
@ -587,6 +623,92 @@ func (o *Capacity) SetTarget(v *int) *Capacity {
|
|||
|
||||
// endregion
|
||||
|
||||
// region Scheduling
|
||||
|
||||
func (o Scheduling) MarshalJSON() ([]byte, error) {
|
||||
type noMethod Scheduling
|
||||
raw := noMethod(o)
|
||||
return jsonutil.MarshalJSON(raw, o.forceSendFields, o.nullFields)
|
||||
}
|
||||
|
||||
func (o *Scheduling) SetShutdownHours(v *ShutdownHours) *Scheduling {
|
||||
if o.ShutdownHours = v; o.ShutdownHours == nil {
|
||||
o.nullFields = append(o.nullFields, "ShutdownHours")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *Scheduling) SetTasks(v []*Task) *Scheduling {
|
||||
if o.Tasks = v; o.Tasks == nil {
|
||||
o.nullFields = append(o.nullFields, "Tasks")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Tasks
|
||||
|
||||
func (o Task) MarshalJSON() ([]byte, error) {
|
||||
type noMethod Task
|
||||
raw := noMethod(o)
|
||||
return jsonutil.MarshalJSON(raw, o.forceSendFields, o.nullFields)
|
||||
}
|
||||
|
||||
func (o *Task) SetIsEnabled(v *bool) *Task {
|
||||
if o.IsEnabled = v; o.IsEnabled == nil {
|
||||
o.nullFields = append(o.nullFields, "IsEnabled")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *Task) SetType(v *string) *Task {
|
||||
if o.Type = v; o.Type == nil {
|
||||
o.nullFields = append(o.nullFields, "Type")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *Task) SetCronExpression(v *string) *Task {
|
||||
if o.CronExpression = v; o.CronExpression == nil {
|
||||
o.nullFields = append(o.nullFields, "CronExpression")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *Task) SetBatchSizePercentage(v *int) *Task {
|
||||
if o.BatchSizePercentage = v; o.BatchSizePercentage == nil {
|
||||
o.nullFields = append(o.nullFields, "BatchSizePercentage")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region ShutdownHours
|
||||
|
||||
func (o ShutdownHours) MarshalJSON() ([]byte, error) {
|
||||
type noMethod ShutdownHours
|
||||
raw := noMethod(o)
|
||||
return jsonutil.MarshalJSON(raw, o.forceSendFields, o.nullFields)
|
||||
}
|
||||
|
||||
func (o *ShutdownHours) SetIsEnabled(v *bool) *ShutdownHours {
|
||||
if o.IsEnabled = v; o.IsEnabled == nil {
|
||||
o.nullFields = append(o.nullFields, "IsEnabled")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *ShutdownHours) SetTimeWindows(v []string) *ShutdownHours {
|
||||
if o.TimeWindows = v; o.TimeWindows == nil {
|
||||
o.nullFields = append(o.nullFields, "TimeWindows")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Strategy
|
||||
|
||||
func (o Strategy) MarshalJSON() ([]byte, error) {
|
||||
|
@ -927,6 +1049,13 @@ func (o *AutoScaler) SetCooldown(v *int) *AutoScaler {
|
|||
return o
|
||||
}
|
||||
|
||||
func (o *AutoScaler) SetAutoHeadroomPercentage(v *int) *AutoScaler {
|
||||
if o.AutoHeadroomPercentage = v; o.AutoHeadroomPercentage == nil {
|
||||
o.nullFields = append(o.nullFields, "AutoHeadroomPercentage")
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *AutoScaler) SetHeadroom(v *AutoScalerHeadroom) *AutoScaler {
|
||||
if o.Headroom = v; o.Headroom == nil {
|
||||
o.nullFields = append(o.nullFields, "Headroom")
|
||||
|
|
|
@ -13,5 +13,6 @@ go_library(
|
|||
deps = [
|
||||
"//vendor/github.com/spotinst/spotinst-sdk-go/spotinst/credentials:go_default_library",
|
||||
"//vendor/github.com/spotinst/spotinst-sdk-go/spotinst/log:go_default_library",
|
||||
"//vendor/github.com/spotinst/spotinst-sdk-go/spotinst/util/useragent:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
package spotinst
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/spotinst/spotinst-sdk-go/spotinst/credentials"
|
||||
"github.com/spotinst/spotinst-sdk-go/spotinst/log"
|
||||
"github.com/spotinst/spotinst-sdk-go/spotinst/util/useragent"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -18,9 +20,6 @@ const (
|
|||
|
||||
// defaultContentType is the default content type to use when making HTTP calls.
|
||||
defaultContentType = "application/json"
|
||||
|
||||
// defaultUserAgent is the default user agent to use when making HTTP calls.
|
||||
defaultUserAgent = SDKName + "/" + SDKVersion
|
||||
)
|
||||
|
||||
// A Config provides Configuration to a service client instance.
|
||||
|
@ -29,33 +28,52 @@ type Config struct {
|
|||
BaseURL *url.URL
|
||||
|
||||
// The HTTP Client the SDK's API clients will use to invoke HTTP requests.
|
||||
// The SDK defaults to a DefaultHTTPClient allowing API clients to create
|
||||
// copies of the HTTP client for service specific customizations.
|
||||
//
|
||||
// Defaults to a DefaultHTTPClient allowing API clients to create copies of
|
||||
// the HTTP client for service specific customizations.
|
||||
HTTPClient *http.Client
|
||||
|
||||
// The credentials object to use when signing requests. Defaults to a
|
||||
// chain of credential providers to search for credentials in environment
|
||||
// variables and shared credential file.
|
||||
// The credentials object to use when signing requests.
|
||||
//
|
||||
// Defaults to a chain of credential providers to search for credentials in
|
||||
// environment variables and shared credential file.
|
||||
Credentials *credentials.Credentials
|
||||
|
||||
// The logger writer interface to write logging messages to. Defaults to
|
||||
// standard out.
|
||||
// The logger writer interface to write logging messages to.
|
||||
//
|
||||
// Defaults to standard out.
|
||||
Logger log.Logger
|
||||
|
||||
// The User-Agent and Content-Type HTTP headers to set when invoking
|
||||
// HTTP requests.
|
||||
// The User-Agent and Content-Type HTTP headers to set when invoking HTTP
|
||||
// requests.
|
||||
UserAgent, ContentType string
|
||||
}
|
||||
|
||||
// DefaultBaseURL returns the default base URL.
|
||||
func DefaultBaseURL() *url.URL {
|
||||
baseURL, _ := url.Parse(defaultBaseURL)
|
||||
return baseURL
|
||||
}
|
||||
|
||||
// DefaultTransport returns a new http.Transport with similar default
|
||||
// values to http.DefaultTransport. Do not use this for transient transports as
|
||||
// it can leak file descriptors over time. Only use this for transports that
|
||||
// will be re-used for the same host(s).
|
||||
// DefaultUserAgent returns the default User-Agent header.
|
||||
func DefaultUserAgent() string {
|
||||
return useragent.New(
|
||||
SDKName,
|
||||
SDKVersion,
|
||||
runtime.Version(),
|
||||
runtime.GOOS,
|
||||
runtime.GOARCH).String()
|
||||
}
|
||||
|
||||
// DefaultContentType returns the default Content-Type header.
|
||||
func DefaultContentType() string {
|
||||
return defaultContentType
|
||||
}
|
||||
|
||||
// DefaultTransport returns a new http.Transport with similar default values to
|
||||
// http.DefaultTransport. Do not use this for transient transports as it can
|
||||
// leak file descriptors over time. Only use this for transports that will be
|
||||
// re-used for the same host(s).
|
||||
func DefaultTransport() *http.Transport {
|
||||
return &http.Transport{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
|
@ -79,15 +97,15 @@ func DefaultHTTPClient() *http.Client {
|
|||
}
|
||||
|
||||
// DefaultConfig returns a default configuration for the client. By default this
|
||||
// will pool and reuse idle connections to API. If you have a long-lived
|
||||
// client object, this is the desired behavior and should make the most efficient
|
||||
// use of the connections to API.
|
||||
// will pool and reuse idle connections to API. If you have a long-lived client
|
||||
// object, this is the desired behavior and should make the most efficient use
|
||||
// of the connections to API.
|
||||
func DefaultConfig() *Config {
|
||||
return &Config{
|
||||
BaseURL: DefaultBaseURL(),
|
||||
HTTPClient: DefaultHTTPClient(),
|
||||
UserAgent: defaultUserAgent,
|
||||
ContentType: defaultContentType,
|
||||
UserAgent: DefaultUserAgent(),
|
||||
ContentType: DefaultContentType(),
|
||||
Credentials: credentials.NewChainCredentials(
|
||||
new(credentials.EnvProvider),
|
||||
new(credentials.FileProvider),
|
||||
|
@ -116,7 +134,7 @@ func (c *Config) WithCredentials(creds *credentials.Credentials) *Config {
|
|||
|
||||
// WithUserAgent defines the user agent.
|
||||
func (c *Config) WithUserAgent(ua string) *Config {
|
||||
c.UserAgent = fmt.Sprintf("%s,%s", ua, c.UserAgent)
|
||||
c.UserAgent = strings.TrimSpace(strings.Join([]string{ua, c.UserAgent}, " "))
|
||||
return c
|
||||
}
|
||||
|
||||
|
@ -135,31 +153,31 @@ func (c *Config) WithLogger(logger log.Logger) *Config {
|
|||
|
||||
// Merge merges the passed in configs into the existing config object.
|
||||
func (c *Config) Merge(cfgs ...*Config) {
|
||||
for _, other := range cfgs {
|
||||
mergeConfig(c, other)
|
||||
for _, cfg := range cfgs {
|
||||
mergeConfig(c, cfg)
|
||||
}
|
||||
}
|
||||
|
||||
func mergeConfig(dst *Config, other *Config) {
|
||||
if other == nil {
|
||||
func mergeConfig(c1, c2 *Config) {
|
||||
if c2 == nil {
|
||||
return
|
||||
}
|
||||
if other.BaseURL != nil {
|
||||
dst.BaseURL = other.BaseURL
|
||||
if c2.BaseURL != nil {
|
||||
c1.BaseURL = c2.BaseURL
|
||||
}
|
||||
if other.Credentials != nil {
|
||||
dst.Credentials = other.Credentials
|
||||
if c2.Credentials != nil {
|
||||
c1.Credentials = c2.Credentials
|
||||
}
|
||||
if other.HTTPClient != nil {
|
||||
dst.HTTPClient = other.HTTPClient
|
||||
if c2.HTTPClient != nil {
|
||||
c1.HTTPClient = c2.HTTPClient
|
||||
}
|
||||
if other.UserAgent != "" {
|
||||
dst.UserAgent = other.UserAgent
|
||||
if c2.UserAgent != "" {
|
||||
c1.UserAgent = c2.UserAgent
|
||||
}
|
||||
if other.ContentType != "" {
|
||||
dst.ContentType = other.ContentType
|
||||
if c2.ContentType != "" {
|
||||
c1.ContentType = c2.ContentType
|
||||
}
|
||||
if other.Logger != nil {
|
||||
dst.Logger = other.Logger
|
||||
if c2.Logger != nil {
|
||||
c1.Logger = c2.Logger
|
||||
}
|
||||
}
|
||||
|
|
9
vendor/github.com/spotinst/spotinst-sdk-go/spotinst/util/useragent/BUILD.bazel
generated
vendored
Normal file
9
vendor/github.com/spotinst/spotinst-sdk-go/spotinst/util/useragent/BUILD.bazel
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["useragent.go"],
|
||||
importmap = "k8s.io/kops/vendor/github.com/spotinst/spotinst-sdk-go/spotinst/util/useragent",
|
||||
importpath = "github.com/spotinst/spotinst-sdk-go/spotinst/util/useragent",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
50
vendor/github.com/spotinst/spotinst-sdk-go/spotinst/util/useragent/useragent.go
generated
vendored
Normal file
50
vendor/github.com/spotinst/spotinst-sdk-go/spotinst/util/useragent/useragent.go
generated
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
package useragent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// UserAgent represents a User-Agent header.
|
||||
type UserAgent struct {
|
||||
// Product identifier; its name or development codename.
|
||||
Product string `json:"product"`
|
||||
// Version number of the product.
|
||||
Version string `json:"version"`
|
||||
// Zero or more comments containing more details.
|
||||
Comment []string `json:"comment"`
|
||||
}
|
||||
|
||||
// UserAgents represents one or more UserAgents.
|
||||
type UserAgents []UserAgent
|
||||
|
||||
// New returns a UserAgent.
|
||||
func New(product, version string, comment ...string) UserAgent {
|
||||
return UserAgent{
|
||||
Product: product,
|
||||
Version: version,
|
||||
Comment: comment,
|
||||
}
|
||||
}
|
||||
|
||||
// String returns the string representation of UserAgent.
|
||||
func (ua UserAgent) String() string {
|
||||
s := fmt.Sprintf("%s/%s", ua.Product, ua.Version)
|
||||
|
||||
if len(ua.Comment) > 0 {
|
||||
s += fmt.Sprintf(" (%s)", strings.Join(ua.Comment, "; "))
|
||||
}
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
// String concatenates all the user-defined UserAgents.
|
||||
func (uas UserAgents) String() string {
|
||||
ss := make([]string, len(uas))
|
||||
|
||||
for i, ua := range uas {
|
||||
ss[i] = ua.String()
|
||||
}
|
||||
|
||||
return strings.Join(ss, " ")
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package spotinst
|
||||
|
||||
// SDKVersion is the current version of the SDK.
|
||||
const SDKVersion = "1.36.1"
|
||||
const SDKVersion = "1.43.0"
|
||||
|
||||
// SDKName is the name of the SDK.
|
||||
const SDKName = "spotinst-sdk-go"
|
||||
|
|
|
@ -409,7 +409,7 @@ github.com/spf13/jwalterweatherman
|
|||
github.com/spf13/pflag
|
||||
# github.com/spf13/viper v1.3.2
|
||||
github.com/spf13/viper
|
||||
# github.com/spotinst/spotinst-sdk-go v1.36.1
|
||||
# github.com/spotinst/spotinst-sdk-go v1.43.0
|
||||
github.com/spotinst/spotinst-sdk-go/service/elastigroup
|
||||
github.com/spotinst/spotinst-sdk-go/service/elastigroup/providers/aws
|
||||
github.com/spotinst/spotinst-sdk-go/service/elastigroup/providers/azure
|
||||
|
@ -425,6 +425,7 @@ github.com/spotinst/spotinst-sdk-go/spotinst/session
|
|||
github.com/spotinst/spotinst-sdk-go/spotinst/util/jsonutil
|
||||
github.com/spotinst/spotinst-sdk-go/spotinst/util/stringutil
|
||||
github.com/spotinst/spotinst-sdk-go/spotinst/util/uritemplates
|
||||
github.com/spotinst/spotinst-sdk-go/spotinst/util/useragent
|
||||
# github.com/stretchr/testify v1.4.0
|
||||
github.com/stretchr/testify/assert
|
||||
github.com/stretchr/testify/require
|
||||
|
|
Loading…
Reference in New Issue