Skip to content

Commit 8419486

Browse files
jkoe-cfajhollandstainless-app[bot]
authored
fix(queue_consumer): id population (#6181)
* resolves #5652 * Unifying queue consumer script and script_name in terraform state * Populate queue consumer info in queue resource * Modify mtls resource and mtls, org, and app tests * feat(api): api update * fixing bad merge * Marking consumer_id as computed because it is generated from the create consumer response * Adding tests for queue_consumer * Refactoring tests to have test configs in files * Adding more tests for different config cases * Updating queue consumer tests --------- Co-authored-by: Alex Holland <[email protected]> Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
1 parent 42834a9 commit 8419486

18 files changed

+734
-6
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package queue_consumer
2+
3+
func FixInconsistentCRUDResponses(data *QueueConsumerModel) {
4+
if data.ScriptName.IsNull() && !data.Script.IsNull() {
5+
data.ScriptName = data.Script
6+
}
7+
if data.Script.IsNull() && !data.ScriptName.IsNull() {
8+
data.Script = data.ScriptName
9+
}
10+
}

internal/services/queue_consumer/data_source_model.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type QueueConsumerResultDataSourceEnvelope struct {
1818

1919
type QueueConsumerDataSourceModel struct {
2020
AccountID types.String `tfsdk:"account_id" path:"account_id,required"`
21-
ConsumerID types.String `tfsdk:"consumer_id" path:"consumer_id,required"`
21+
ConsumerID types.String `tfsdk:"consumer_id" json:"consumer_id,computed"`
2222
QueueID types.String `tfsdk:"queue_id" path:"queue_id,required"`
2323
CreatedOn types.String `tfsdk:"created_on" json:"created_on,computed"`
2424
Script types.String `tfsdk:"script" json:"script,computed"`

internal/services/queue_consumer/data_source_schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func DataSourceSchema(ctx context.Context) schema.Schema {
2323
},
2424
"consumer_id": schema.StringAttribute{
2525
Description: "A Resource identifier.",
26-
Required: true,
26+
Computed: true,
2727
},
2828
"queue_id": schema.StringAttribute{
2929
Description: "A Resource identifier.",

internal/services/queue_consumer/model.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type QueueConsumerResultEnvelope struct {
1414
type QueueConsumerModel struct {
1515
AccountID types.String `tfsdk:"account_id" path:"account_id,required"`
1616
QueueID types.String `tfsdk:"queue_id" path:"queue_id,required"`
17-
ConsumerID types.String `tfsdk:"consumer_id" path:"consumer_id,optional"`
17+
ConsumerID types.String `tfsdk:"consumer_id" json:"consumer_id,computed"`
1818
DeadLetterQueue types.String `tfsdk:"dead_letter_queue" json:"dead_letter_queue,optional,no_refresh"`
1919
ScriptName types.String `tfsdk:"script_name" json:"script_name,optional"`
2020
Type types.String `tfsdk:"type" json:"type,optional"`

internal/services/queue_consumer/resource.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (r *QueueConsumerResource) Create(ctx context.Context, req resource.CreateR
8989
return
9090
}
9191
data = &env.Result
92-
92+
FixInconsistentCRUDResponses(data)
9393
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
9494
}
9595

@@ -140,6 +140,7 @@ func (r *QueueConsumerResource) Update(ctx context.Context, req resource.UpdateR
140140
}
141141
data = &env.Result
142142

143+
FixInconsistentCRUDResponses(data)
143144
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
144145
}
145146

@@ -180,7 +181,7 @@ func (r *QueueConsumerResource) Read(ctx context.Context, req resource.ReadReque
180181
return
181182
}
182183
data = &env.Result
183-
184+
FixInconsistentCRUDResponses(data)
184185
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
185186
}
186187

0 commit comments

Comments
 (0)