Skip to content

Commit e875b98

Browse files
Merge pull request #195 from controlplane-com/majid/change-type-where-order-matters
Majid/change type where order matters
2 parents 7d8fc57 + 6cf8b4f commit e875b98

File tree

7 files changed

+34
-27
lines changed

7 files changed

+34
-27
lines changed

CHANGELOG.MD

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 1.2.13
2+
3+
- Fix order of values in command array in workload resource.
4+
- Deprecate 'default' endpoint_naming_format in gvc resource; add 'legacy' as replacement.
5+
- Fix order of values in deploy_role_chain in mk8s resource.
6+
- Fix order of values in container ports in workload resource.
7+
18
## 1.2.12
29

310
- Fix noisy diffs for `dictionary_as_envs` across runs in secret resource.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ HOSTNAME=controlplane.com
33
NAMESPACE=com
44
NAME=cpln
55
BINARY=terraform-provider-${NAME}
6-
VERSION=1.2.12
6+
VERSION=1.2.13
77
OS_ARCH=linux_amd64
88

99
default: install

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ terraform {
5656
required_providers {
5757
cpln = {
5858
source = "controlplane-com/cpln"
59-
version = "1.2.12"
59+
version = "1.2.13"
6060
}
6161
}
6262
}

internal/provider/models/mk8s/mk8s.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ type AwsProviderModel struct {
158158
PreInstallScript types.String `tfsdk:"pre_install_script"`
159159
Image types.List `tfsdk:"image"`
160160
DeployRoleArn types.String `tfsdk:"deploy_role_arn"`
161-
DeployRoleChain types.Set `tfsdk:"deploy_role_chain"`
161+
DeployRoleChain types.List `tfsdk:"deploy_role_chain"`
162162
VpcId types.String `tfsdk:"vpc_id"`
163163
KeyPair types.String `tfsdk:"key_pair"`
164164
DiskEncryptionKeyArn types.String `tfsdk:"disk_encryption_key_arn"`
@@ -178,7 +178,7 @@ func (a AwsProviderModel) AttributeTypes() attr.Type {
178178
"pre_install_script": types.StringType,
179179
"image": types.ListType{ElemType: AwsProviderAmiModel{}.AttributeTypes()},
180180
"deploy_role_arn": types.StringType,
181-
"deploy_role_chain": types.SetType{ElemType: AwsProviderAssumeRoleLinkModel{}.AttributeTypes()},
181+
"deploy_role_chain": types.ListType{ElemType: AwsProviderAssumeRoleLinkModel{}.AttributeTypes()},
182182
"vpc_id": types.StringType,
183183
"key_pair": types.StringType,
184184
"disk_encryption_key_arn": types.StringType,

internal/provider/models/workload/workload.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type ContainerModel struct {
1515
WorkingDirectory types.String `tfsdk:"working_directory"`
1616
Metrics types.List `tfsdk:"metrics"`
1717
Port types.Int32 `tfsdk:"port"`
18-
Ports types.Set `tfsdk:"ports"`
18+
Ports types.List `tfsdk:"ports"`
1919
Memory types.String `tfsdk:"memory"`
2020
ReadinessProbe types.List `tfsdk:"readiness_probe"`
2121
LivenessProbe types.List `tfsdk:"liveness_probe"`
@@ -40,7 +40,7 @@ func (c ContainerModel) AttributeTypes() attr.Type {
4040
"working_directory": types.StringType,
4141
"metrics": types.ListType{ElemType: ContainerMetricsModel{}.AttributeTypes()},
4242
"port": types.Int32Type,
43-
"ports": types.SetType{ElemType: ContainerPortModel{}.AttributeTypes()},
43+
"ports": types.ListType{ElemType: ContainerPortModel{}.AttributeTypes()},
4444
"memory": types.StringType,
4545
"readiness_probe": types.ListType{ElemType: ContainerHealthCheckModel{}.AttributeTypes()},
4646
"liveness_probe": types.ListType{ElemType: ContainerHealthCheckModel{}.AttributeTypes()},

internal/provider/resource_mk8s.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ func (mr *Mk8sResource) Schema(ctx context.Context, req resource.SchemaRequest,
354354
Blocks: map[string]schema.Block{
355355
"networking": mr.NetworkingSchema(),
356356
"image": mr.AwsAmiSchema(),
357-
"deploy_role_chain": schema.SetNestedBlock{
357+
"deploy_role_chain": schema.ListNestedBlock{
358358
Description: "",
359359
NestedObject: schema.NestedBlockObject{
360360
Attributes: map[string]schema.Attribute{
@@ -1958,11 +1958,11 @@ func (mro *Mk8sResourceOperator) buildAwsAmi(state types.List) *client.Mk8sAwsAm
19581958
}
19591959

19601960
// buildAwsAssumeRoleLink constructs a []client.Mk8sAwsAssumeRoleLink from the given Terraform state.
1961-
func (mro *Mk8sResourceOperator) buildAwsAssumeRoleLink(state types.Set) *[]client.Mk8sAwsAssumeRoleLink {
1962-
// Convert Terraform set into model blocks using generic helper
1963-
blocks, ok := BuildSet[models.AwsProviderAssumeRoleLinkModel](mro.Ctx, mro.Diags, state)
1961+
func (mro *Mk8sResourceOperator) buildAwsAssumeRoleLink(state types.List) *[]client.Mk8sAwsAssumeRoleLink {
1962+
// Convert Terraform list into model blocks using generic helper
1963+
blocks, ok := BuildList[models.AwsProviderAssumeRoleLinkModel](mro.Ctx, mro.Diags, state)
19641964

1965-
// Return nil if conversion failed or set was empty
1965+
// Return nil if conversion failed or List was empty
19661966
if !ok {
19671967
return nil
19681968
}
@@ -3212,15 +3212,15 @@ func (mro *Mk8sResourceOperator) flattenAwsAmi(input *client.Mk8sAwsAmi) types.L
32123212
return FlattenList(mro.Ctx, mro.Diags, []models.AwsProviderAmiModel{block})
32133213
}
32143214

3215-
// flattenAwsAssumeRoleLink transforms *[]client.Mk8sAwsAssumeRoleLink into a types.Set.
3216-
func (mro *Mk8sResourceOperator) flattenAwsAssumeRoleLink(input *[]client.Mk8sAwsAssumeRoleLink) types.Set {
3215+
// flattenAwsAssumeRoleLink transforms *[]client.Mk8sAwsAssumeRoleLink into a types.List.
3216+
func (mro *Mk8sResourceOperator) flattenAwsAssumeRoleLink(input *[]client.Mk8sAwsAssumeRoleLink) types.List {
32173217
// Get attribute types
32183218
elementType := models.AwsProviderAssumeRoleLinkModel{}.AttributeTypes()
32193219

32203220
// Check if the input is nil
32213221
if input == nil {
3222-
// Return a null set
3223-
return types.SetNull(elementType)
3222+
// Return a null List
3223+
return types.ListNull(elementType)
32243224
}
32253225

32263226
// Define the blocks slice
@@ -3239,8 +3239,8 @@ func (mro *Mk8sResourceOperator) flattenAwsAssumeRoleLink(input *[]client.Mk8sAw
32393239
blocks = append(blocks, block)
32403240
}
32413241

3242-
// Return the successfully created types.Set
3243-
return FlattenSet(mro.Ctx, mro.Diags, blocks)
3242+
// Return the successfully created types.List
3243+
return FlattenList(mro.Ctx, mro.Diags, blocks)
32443244
}
32453245

32463246
// flattenAwsProviderNodePools transforms *[]client.Mk8sAwsPool into a types.Set.

internal/provider/resource_workload.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ func (wr *WorkloadResource) Schema(ctx context.Context, req resource.SchemaReque
429429
listvalidator.SizeAtMost(1),
430430
},
431431
},
432-
"ports": schema.SetNestedBlock{
432+
"ports": schema.ListNestedBlock{
433433
Description: "Communication endpoints used by the workload to send and receive network traffic.",
434434
NestedObject: schema.NestedBlockObject{
435435
Attributes: map[string]schema.Attribute{
@@ -1689,7 +1689,7 @@ func (wr *WorkloadResource) ModifyContainers(ctx context.Context, diags *diag.Di
16891689
}
16901690

16911691
// Build ports from container
1692-
ports, ok := BuildSet[models.ContainerPortModel](ctx, diags, container.Ports)
1692+
ports, ok := BuildList[models.ContainerPortModel](ctx, diags, container.Ports)
16931693

16941694
// If the port number is still nil, extract the port number from the very first item of container ports
16951695
if ok && len(ports) != 0 {
@@ -1713,7 +1713,7 @@ func (wr *WorkloadResource) ModifyContainers(ctx context.Context, diags *diag.Di
17131713
}
17141714

17151715
// Set ports back to container
1716-
container.Ports = FlattenSet(ctx, diags, ports)
1716+
container.Ports = FlattenList(ctx, diags, ports)
17171717

17181718
// Set probes back to container
17191719
container.LivenessProbe = FlattenList(ctx, diags, livenessProbe)
@@ -2122,7 +2122,7 @@ func (wro *WorkloadResourceOperator) buildContainers(state types.List) *[]client
21222122
// Iterate over each block and construct an output item
21232123
for _, block := range blocks {
21242124
// Build block ports
2125-
ports, ok := BuildSet[models.ContainerPortModel](wro.Ctx, wro.Diags, block.Ports)
2125+
ports, ok := BuildList[models.ContainerPortModel](wro.Ctx, wro.Diags, block.Ports)
21262126

21272127
// Skip if ports are nil, this shouldn't happen but let's handle it anyway
21282128
if !block.Ports.IsNull() && !block.Ports.IsUnknown() && !ok {
@@ -3302,15 +3302,15 @@ func (wro *WorkloadResourceOperator) flattenContainerMetrics(input *client.Workl
33023302
return FlattenList(wro.Ctx, wro.Diags, []models.ContainerMetricsModel{block})
33033303
}
33043304

3305-
// flattenContainerPort transforms *[]client.WorkloadContainerPort into a types.Set.
3306-
func (wro *WorkloadResourceOperator) flattenContainerPort(input *[]client.WorkloadContainerPort) types.Set {
3305+
// flattenContainerPort transforms *[]client.WorkloadContainerPort into a types.List.
3306+
func (wro *WorkloadResourceOperator) flattenContainerPort(input *[]client.WorkloadContainerPort) types.List {
33073307
// Get attribute types
33083308
elementType := models.ContainerPortModel{}.AttributeTypes()
33093309

33103310
// Check if the input is nil
33113311
if input == nil {
3312-
// Return a null set
3313-
return types.SetNull(elementType)
3312+
// Return a null list
3313+
return types.ListNull(elementType)
33143314
}
33153315

33163316
// Define the blocks slice
@@ -3328,8 +3328,8 @@ func (wro *WorkloadResourceOperator) flattenContainerPort(input *[]client.Worklo
33283328
blocks = append(blocks, block)
33293329
}
33303330

3331-
// Return the successfully created types.Set
3332-
return FlattenSet(wro.Ctx, wro.Diags, blocks)
3331+
// Return the successfully created types.List
3332+
return FlattenList(wro.Ctx, wro.Diags, blocks)
33333333
}
33343334

33353335
// flattenHealthCheck transforms *client.WorkloadHealthCheck into a types.List.

0 commit comments

Comments
 (0)