Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: comparison operator when sorting keys #805

Merged
merged 1 commit into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ integration with the kOps api:

... just **pure go code.**

Currently using kOps `v1.25.1` and compatible with terraform `0.15` and higher.
Currently using kOps `v1.25.2` and compatible with terraform `0.15` and higher.

**NOTES**
- For now, provisioning the network is not supported. The network must
Expand Down
2 changes: 2 additions & 0 deletions docs/data-sources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,8 @@ The following arguments are supported:
- `skip_nodes_with_local_storage` - (Computed) - Bool - SkipNodesWithLocalStorage makes cluster autoscaler skip scale-down of nodes with local storage.<br />Default: true.
- `new_pod_scale_up_delay` - (Computed) - String - NewPodScaleUpDelay causes cluster autoscaler to ignore unschedulable pods until they are a certain "age", regardless of the scan-interval<br />Default: 0s.
- `scale_down_delay_after_add` - (Computed) - String - ScaleDownDelayAfterAdd determines the time after scale up that scale down evaluation resumes<br />Default: 10m0s.
- `scale_down_unneeded_time` - (Computed) - String - scaleDownUnneededTime determines the time a node should be unneeded before it is eligible for scale down<br />Default: 10m0s.
- `scale_down_unready_time` - (Computed) - String - ScaleDownUnreadyTime determines the time an unready node should be unneeded before it is eligible for scale down<br />Default: 20m0s.
- `cordon_node_before_terminating` - (Computed) - Bool - CordonNodeBeforeTerminating should CA cordon nodes before terminating during downscale process<br />Default: false.
- `image` - (Computed) - String - Image is the docker container used.<br />Default: the latest supported image for the specified kubernetes version.
- `memory_request` - (Computed) - Quantity - MemoryRequest of cluster autoscaler container.<br />Default: 300Mi.
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ integration with the kOps api:

... just **pure go code.**

Currently using kOps `v1.25.1` and compatible with terraform `0.15` and higher.
Currently using kOps `v1.25.2` and compatible with terraform `0.15` and higher.

~> For now, provisioning the network is not supported. The network must
be created separately and given to the provider through cluster attribute
Expand Down
2 changes: 2 additions & 0 deletions docs/resources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -1860,6 +1860,8 @@ The following arguments are supported:
- `skip_nodes_with_local_storage` - (Required) - Bool - SkipNodesWithLocalStorage makes cluster autoscaler skip scale-down of nodes with local storage.<br />Default: true.
- `new_pod_scale_up_delay` - (Optional) - String - NewPodScaleUpDelay causes cluster autoscaler to ignore unschedulable pods until they are a certain "age", regardless of the scan-interval<br />Default: 0s.
- `scale_down_delay_after_add` - (Optional) - String - ScaleDownDelayAfterAdd determines the time after scale up that scale down evaluation resumes<br />Default: 10m0s.
- `scale_down_unneeded_time` - (Optional) - String - scaleDownUnneededTime determines the time a node should be unneeded before it is eligible for scale down<br />Default: 10m0s.
- `scale_down_unready_time` - (Optional) - String - ScaleDownUnreadyTime determines the time an unready node should be unneeded before it is eligible for scale down<br />Default: 20m0s.
- `cordon_node_before_terminating` - (Optional) - Bool - CordonNodeBeforeTerminating should CA cordon nodes before terminating during downscale process<br />Default: false.
- `image` - (Optional) - String - Image is the docker container used.<br />Default: the latest supported image for the specified kubernetes version.
- `memory_request` - (Optional) - Quantity - MemoryRequest of cluster autoscaler container.<br />Default: 300Mi.
Expand Down
60 changes: 60 additions & 0 deletions pkg/schemas/kops/DataSource_ClusterAutoscalerConfig.generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ func DataSourceClusterAutoscalerConfig() *schema.Resource {
"skip_nodes_with_local_storage": ComputedBool(),
"new_pod_scale_up_delay": ComputedString(),
"scale_down_delay_after_add": ComputedString(),
"scale_down_unneeded_time": ComputedString(),
"scale_down_unready_time": ComputedString(),
"cordon_node_before_terminating": ComputedBool(),
"image": ComputedString(),
"memory_request": ComputedQuantity(),
Expand Down Expand Up @@ -211,6 +213,44 @@ func ExpandDataSourceClusterAutoscalerConfig(in map[string]interface{}) kops.Clu
}(string(ExpandString(in)))
}(in)
}(in["scale_down_delay_after_add"]),
ScaleDownUnneededTime: func(in interface{}) *string {
if in == nil {
return nil
}
if reflect.DeepEqual(in, reflect.Zero(reflect.TypeOf(in)).Interface()) {
return nil
}
return func(in interface{}) *string {
if in == nil {
return nil
}
if _, ok := in.([]interface{}); ok && len(in.([]interface{})) == 0 {
return nil
}
return func(in string) *string {
return &in
}(string(ExpandString(in)))
}(in)
}(in["scale_down_unneeded_time"]),
ScaleDownUnreadyTime: func(in interface{}) *string {
if in == nil {
return nil
}
if reflect.DeepEqual(in, reflect.Zero(reflect.TypeOf(in)).Interface()) {
return nil
}
return func(in interface{}) *string {
if in == nil {
return nil
}
if _, ok := in.([]interface{}); ok && len(in.([]interface{})) == 0 {
return nil
}
return func(in string) *string {
return &in
}(string(ExpandString(in)))
}(in)
}(in["scale_down_unready_time"]),
CordonNodeBeforeTerminating: func(in interface{}) *bool {
if in == nil {
return nil
Expand Down Expand Up @@ -401,6 +441,26 @@ func FlattenDataSourceClusterAutoscalerConfigInto(in kops.ClusterAutoscalerConfi
}(*in)
}(in)
}(in.ScaleDownDelayAfterAdd)
out["scale_down_unneeded_time"] = func(in *string) interface{} {
return func(in *string) interface{} {
if in == nil {
return nil
}
return func(in string) interface{} {
return FlattenString(string(in))
}(*in)
}(in)
}(in.ScaleDownUnneededTime)
out["scale_down_unready_time"] = func(in *string) interface{} {
return func(in *string) interface{} {
if in == nil {
return nil
}
return func(in string) interface{} {
return FlattenString(string(in))
}(*in)
}(in)
}(in.ScaleDownUnreadyTime)
out["cordon_node_before_terminating"] = func(in *bool) interface{} {
return func(in *bool) interface{} {
if in == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ func TestExpandDataSourceClusterAutoscalerConfig(t *testing.T) {
"skip_nodes_with_local_storage": nil,
"new_pod_scale_up_delay": nil,
"scale_down_delay_after_add": nil,
"scale_down_unneeded_time": nil,
"scale_down_unready_time": nil,
"cordon_node_before_terminating": nil,
"image": nil,
"memory_request": nil,
Expand Down Expand Up @@ -62,6 +64,8 @@ func TestFlattenDataSourceClusterAutoscalerConfigInto(t *testing.T) {
"skip_nodes_with_local_storage": nil,
"new_pod_scale_up_delay": nil,
"scale_down_delay_after_add": nil,
"scale_down_unneeded_time": nil,
"scale_down_unready_time": nil,
"cordon_node_before_terminating": nil,
"image": nil,
"memory_request": nil,
Expand Down Expand Up @@ -183,6 +187,28 @@ func TestFlattenDataSourceClusterAutoscalerConfigInto(t *testing.T) {
},
want: _default,
},
{
name: "ScaleDownUnneededTime - default",
args: args{
in: func() kops.ClusterAutoscalerConfig {
subject := kops.ClusterAutoscalerConfig{}
subject.ScaleDownUnneededTime = nil
return subject
}(),
},
want: _default,
},
{
name: "ScaleDownUnreadyTime - default",
args: args{
in: func() kops.ClusterAutoscalerConfig {
subject := kops.ClusterAutoscalerConfig{}
subject.ScaleDownUnreadyTime = nil
return subject
}(),
},
want: _default,
},
{
name: "CordonNodeBeforeTerminating - default",
args: args{
Expand Down Expand Up @@ -272,6 +298,8 @@ func TestFlattenDataSourceClusterAutoscalerConfig(t *testing.T) {
"skip_nodes_with_local_storage": nil,
"new_pod_scale_up_delay": nil,
"scale_down_delay_after_add": nil,
"scale_down_unneeded_time": nil,
"scale_down_unready_time": nil,
"cordon_node_before_terminating": nil,
"image": nil,
"memory_request": nil,
Expand Down Expand Up @@ -393,6 +421,28 @@ func TestFlattenDataSourceClusterAutoscalerConfig(t *testing.T) {
},
want: _default,
},
{
name: "ScaleDownUnneededTime - default",
args: args{
in: func() kops.ClusterAutoscalerConfig {
subject := kops.ClusterAutoscalerConfig{}
subject.ScaleDownUnneededTime = nil
return subject
}(),
},
want: _default,
},
{
name: "ScaleDownUnreadyTime - default",
args: args{
in: func() kops.ClusterAutoscalerConfig {
subject := kops.ClusterAutoscalerConfig{}
subject.ScaleDownUnreadyTime = nil
return subject
}(),
},
want: _default,
},
{
name: "CordonNodeBeforeTerminating - default",
args: args{
Expand Down
2 changes: 1 addition & 1 deletion pkg/schemas/kops/DataSource_ClusterSpec.generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ func FlattenDataSourceClusterSpecInto(in kops.ClusterSpec, out map[string]interf
keys = append(keys, key)
}
sort.SliceStable(keys, func(i, j int) bool {
return keys[i] > keys[j]
return keys[i] < keys[j]
})
var out []interface{}
for _, key := range keys {
Expand Down
2 changes: 1 addition & 1 deletion pkg/schemas/kops/DataSource_ContainerdConfig.generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func FlattenDataSourceContainerdConfigInto(in kops.ContainerdConfig, out map[str
keys = append(keys, key)
}
sort.SliceStable(keys, func(i, j int) bool {
return keys[i] > keys[j]
return keys[i] < keys[j]
})
var out []interface{}
for _, key := range keys {
Expand Down
2 changes: 1 addition & 1 deletion pkg/schemas/kops/DataSource_KubeDNSConfig.generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func FlattenDataSourceKubeDNSConfigInto(in kops.KubeDNSConfig, out map[string]in
keys = append(keys, key)
}
sort.SliceStable(keys, func(i, j int) bool {
return keys[i] > keys[j]
return keys[i] < keys[j]
})
var out []interface{}
for _, key := range keys {
Expand Down
60 changes: 60 additions & 0 deletions pkg/schemas/kops/Resource_ClusterAutoscalerConfig.generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ func ResourceClusterAutoscalerConfig() *schema.Resource {
"skip_nodes_with_local_storage": RequiredBool(),
"new_pod_scale_up_delay": OptionalString(),
"scale_down_delay_after_add": OptionalString(),
"scale_down_unneeded_time": OptionalString(),
"scale_down_unready_time": OptionalString(),
"cordon_node_before_terminating": OptionalBool(),
"image": OptionalString(),
"memory_request": OptionalQuantity(),
Expand Down Expand Up @@ -199,6 +201,44 @@ func ExpandResourceClusterAutoscalerConfig(in map[string]interface{}) kops.Clust
}(string(ExpandString(in)))
}(in)
}(in["scale_down_delay_after_add"]),
ScaleDownUnneededTime: func(in interface{}) *string {
if in == nil {
return nil
}
if reflect.DeepEqual(in, reflect.Zero(reflect.TypeOf(in)).Interface()) {
return nil
}
return func(in interface{}) *string {
if in == nil {
return nil
}
if _, ok := in.([]interface{}); ok && len(in.([]interface{})) == 0 {
return nil
}
return func(in string) *string {
return &in
}(string(ExpandString(in)))
}(in)
}(in["scale_down_unneeded_time"]),
ScaleDownUnreadyTime: func(in interface{}) *string {
if in == nil {
return nil
}
if reflect.DeepEqual(in, reflect.Zero(reflect.TypeOf(in)).Interface()) {
return nil
}
return func(in interface{}) *string {
if in == nil {
return nil
}
if _, ok := in.([]interface{}); ok && len(in.([]interface{})) == 0 {
return nil
}
return func(in string) *string {
return &in
}(string(ExpandString(in)))
}(in)
}(in["scale_down_unready_time"]),
CordonNodeBeforeTerminating: func(in interface{}) *bool {
if in == nil {
return nil
Expand Down Expand Up @@ -389,6 +429,26 @@ func FlattenResourceClusterAutoscalerConfigInto(in kops.ClusterAutoscalerConfig,
}(*in)
}(in)
}(in.ScaleDownDelayAfterAdd)
out["scale_down_unneeded_time"] = func(in *string) interface{} {
return func(in *string) interface{} {
if in == nil {
return nil
}
return func(in string) interface{} {
return FlattenString(string(in))
}(*in)
}(in)
}(in.ScaleDownUnneededTime)
out["scale_down_unready_time"] = func(in *string) interface{} {
return func(in *string) interface{} {
if in == nil {
return nil
}
return func(in string) interface{} {
return FlattenString(string(in))
}(*in)
}(in)
}(in.ScaleDownUnreadyTime)
out["cordon_node_before_terminating"] = func(in *bool) interface{} {
return func(in *bool) interface{} {
if in == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ func TestExpandResourceClusterAutoscalerConfig(t *testing.T) {
"skip_nodes_with_local_storage": nil,
"new_pod_scale_up_delay": nil,
"scale_down_delay_after_add": nil,
"scale_down_unneeded_time": nil,
"scale_down_unready_time": nil,
"cordon_node_before_terminating": nil,
"image": nil,
"memory_request": nil,
Expand Down Expand Up @@ -62,6 +64,8 @@ func TestFlattenResourceClusterAutoscalerConfigInto(t *testing.T) {
"skip_nodes_with_local_storage": nil,
"new_pod_scale_up_delay": nil,
"scale_down_delay_after_add": nil,
"scale_down_unneeded_time": nil,
"scale_down_unready_time": nil,
"cordon_node_before_terminating": nil,
"image": nil,
"memory_request": nil,
Expand Down Expand Up @@ -183,6 +187,28 @@ func TestFlattenResourceClusterAutoscalerConfigInto(t *testing.T) {
},
want: _default,
},
{
name: "ScaleDownUnneededTime - default",
args: args{
in: func() kops.ClusterAutoscalerConfig {
subject := kops.ClusterAutoscalerConfig{}
subject.ScaleDownUnneededTime = nil
return subject
}(),
},
want: _default,
},
{
name: "ScaleDownUnreadyTime - default",
args: args{
in: func() kops.ClusterAutoscalerConfig {
subject := kops.ClusterAutoscalerConfig{}
subject.ScaleDownUnreadyTime = nil
return subject
}(),
},
want: _default,
},
{
name: "CordonNodeBeforeTerminating - default",
args: args{
Expand Down Expand Up @@ -272,6 +298,8 @@ func TestFlattenResourceClusterAutoscalerConfig(t *testing.T) {
"skip_nodes_with_local_storage": nil,
"new_pod_scale_up_delay": nil,
"scale_down_delay_after_add": nil,
"scale_down_unneeded_time": nil,
"scale_down_unready_time": nil,
"cordon_node_before_terminating": nil,
"image": nil,
"memory_request": nil,
Expand Down Expand Up @@ -393,6 +421,28 @@ func TestFlattenResourceClusterAutoscalerConfig(t *testing.T) {
},
want: _default,
},
{
name: "ScaleDownUnneededTime - default",
args: args{
in: func() kops.ClusterAutoscalerConfig {
subject := kops.ClusterAutoscalerConfig{}
subject.ScaleDownUnneededTime = nil
return subject
}(),
},
want: _default,
},
{
name: "ScaleDownUnreadyTime - default",
args: args{
in: func() kops.ClusterAutoscalerConfig {
subject := kops.ClusterAutoscalerConfig{}
subject.ScaleDownUnreadyTime = nil
return subject
}(),
},
want: _default,
},
{
name: "CordonNodeBeforeTerminating - default",
args: args{
Expand Down
Loading