Skip to content

Commit a35a69a

Browse files
authored
fix: handle omni loc name tag deprecation (#638)
1 parent a57dc44 commit a35a69a

File tree

5 files changed

+32
-11
lines changed

5 files changed

+32
-11
lines changed

castai/resource_edge_location.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ type awsModel struct {
6161
VpcID types.String `tfsdk:"vpc_id"`
6262
SecurityGroupID types.String `tfsdk:"security_group_id"`
6363
SubnetIDs types.Map `tfsdk:"subnet_ids"`
64-
NameTag types.String `tfsdk:"name_tag"`
64+
// Deprecated. Should be removed with name_tag attribute removal.
65+
NameTag types.String `tfsdk:"name_tag"`
6566
}
6667

6768
type gcpModel struct {
@@ -94,8 +95,7 @@ func (m awsModel) Equal(other *awsModel) bool {
9495
return m.AccountID.Equal(other.AccountID) &&
9596
m.VpcID.Equal(other.VpcID) &&
9697
m.SecurityGroupID.Equal(other.SecurityGroupID) &&
97-
m.SubnetIDs.Equal(other.SubnetIDs) &&
98-
m.NameTag.Equal(other.NameTag)
98+
m.SubnetIDs.Equal(other.SubnetIDs)
9999
}
100100

101101
func (m gcpModel) credentials() types.String {
@@ -249,8 +249,9 @@ func (r *edgeLocationResource) Schema(_ context.Context, _ resource.SchemaReques
249249
Description: "Map of zone names to subnet IDs to be used in the selected region",
250250
},
251251
"name_tag": schema.StringAttribute{
252-
Required: true,
253-
Description: "The value of a 'Name' tag applied to VPC resources",
252+
Optional: true,
253+
Description: "The value of a 'Name' tag applied to VPC resources",
254+
DeprecationMessage: "Deprecated. Can be omitted",
254255
},
255256
},
256257
},
@@ -691,9 +692,11 @@ func (r *edgeLocationResource) toAWS(ctx context.Context, plan, config *awsModel
691692
VpcId: plan.VpcID.ValueString(),
692693
SecurityGroupId: plan.SecurityGroupID.ValueString(),
693694
SubnetIds: subnetMap,
694-
NameTag: plan.NameTag.ValueString(),
695695
},
696696
}
697+
if !plan.NameTag.IsNull() {
698+
out.Networking.NameTag = lo.ToPtr(plan.NameTag.ValueString())
699+
}
697700

698701
return out, diags
699702
}
@@ -717,7 +720,9 @@ func (r *edgeLocationResource) toAWSModel(ctx context.Context, config *omni.AWSP
717720
if config.Networking != nil {
718721
aws.VpcID = types.StringValue(config.Networking.VpcId)
719722
aws.SecurityGroupID = types.StringValue(config.Networking.SecurityGroupId)
720-
aws.NameTag = types.StringValue(config.Networking.NameTag)
723+
if config.Networking.NameTag != nil && *config.Networking.NameTag != "" {
724+
aws.NameTag = types.StringValue(*config.Networking.NameTag)
725+
}
721726

722727
if config.Networking.SubnetIds != nil {
723728
subnetMap, d := types.MapValueFrom(ctx, types.StringType, config.Networking.SubnetIds)

castai/resource_edge_location_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ resource "castai_edge_location" "test" {
220220
security_group_id = "sg-12345678"
221221
subnet_ids = {%[4]s
222222
}
223-
name_tag = "test-edge-location"
224223
}
225224
}
226225
`, rName, description, zonesConfig, subnetConfig, organizationID, awsCredentials))

castai/sdk/api.gen.go

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

castai/sdk/omni/api.gen.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/resources/edge_location.md

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)