Skip to content

Commit 757b98f

Browse files
committed
fix(workers_script): Revert treating cloudflare_workers_script.bindings as a Set
This was originally intended to prevent diffs due to ordering inconsistency between API and Terraform config, but resulted in a loss of fidelity in diffs as the entire `bindings` attribute was now being shown in diffs as `(sensitive)` due to a nested attribute being as such.
1 parent b2e06b4 commit 757b98f

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

internal/services/workers_script/custom.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ func ValidateContentSHA256() validator.String {
184184

185185
func UpdateSecretTextsFromState[T any](
186186
ctx context.Context,
187-
refreshed customfield.NestedObjectSet[T],
188-
state customfield.NestedObjectSet[T],
189-
) (customfield.NestedObjectSet[T], diag.Diagnostics) {
187+
refreshed customfield.NestedObjectList[T],
188+
state customfield.NestedObjectList[T],
189+
) (customfield.NestedObjectList[T], diag.Diagnostics) {
190190
var diags diag.Diagnostics
191191

192192
refreshedElems := refreshed.Elements()
@@ -252,11 +252,11 @@ func UpdateSecretTextsFromState[T any](
252252
updatedElems[i] = refreshedObj
253253
}
254254

255-
setValue, d := types.SetValue(refreshed.ElementType(ctx), updatedElems)
255+
value, d := types.ListValue(refreshed.ElementType(ctx), updatedElems)
256256
diags.Append(d...)
257257

258-
return customfield.NestedObjectSet[T]{
259-
SetValue: setValue,
258+
return customfield.NestedObjectList[T]{
259+
ListValue: value,
260260
}, diags
261261
}
262262

internal/services/workers_script/model.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,18 @@ func (r WorkersScriptModel) MarshalMultipart() (data []byte, formDataContentType
8989
}
9090

9191
type WorkersScriptMetadataModel struct {
92-
Assets *WorkersScriptMetadataAssetsModel `tfsdk:"assets" json:"assets,optional"`
93-
Bindings customfield.NestedObjectSet[WorkersScriptMetadataBindingsModel] `tfsdk:"bindings" json:"bindings,computed_optional"`
94-
BodyPart types.String `tfsdk:"body_part" json:"body_part,optional"`
95-
CompatibilityDate types.String `tfsdk:"compatibility_date" json:"compatibility_date,computed_optional"`
96-
CompatibilityFlags customfield.Set[types.String] `tfsdk:"compatibility_flags" json:"compatibility_flags,computed_optional"`
97-
KeepAssets types.Bool `tfsdk:"keep_assets" json:"keep_assets,optional"`
98-
KeepBindings *[]types.String `tfsdk:"keep_bindings" json:"keep_bindings,optional"`
99-
Logpush types.Bool `tfsdk:"logpush" json:"logpush,computed_optional"`
100-
MainModule types.String `tfsdk:"main_module" json:"main_module,optional"`
101-
Migrations customfield.NestedObject[WorkersScriptMetadataMigrationsModel] `tfsdk:"migrations" json:"migrations,optional"`
102-
Observability *WorkersScriptMetadataObservabilityModel `tfsdk:"observability" json:"observability,optional"`
103-
Placement customfield.NestedObject[WorkersScriptMetadataPlacementModel] `tfsdk:"placement" json:"placement,computed_optional"`
92+
Assets *WorkersScriptMetadataAssetsModel `tfsdk:"assets" json:"assets,optional"`
93+
Bindings customfield.NestedObjectList[WorkersScriptMetadataBindingsModel] `tfsdk:"bindings" json:"bindings,computed_optional"`
94+
BodyPart types.String `tfsdk:"body_part" json:"body_part,optional"`
95+
CompatibilityDate types.String `tfsdk:"compatibility_date" json:"compatibility_date,computed_optional"`
96+
CompatibilityFlags customfield.Set[types.String] `tfsdk:"compatibility_flags" json:"compatibility_flags,computed_optional"`
97+
KeepAssets types.Bool `tfsdk:"keep_assets" json:"keep_assets,optional"`
98+
KeepBindings *[]types.String `tfsdk:"keep_bindings" json:"keep_bindings,optional"`
99+
Logpush types.Bool `tfsdk:"logpush" json:"logpush,computed_optional"`
100+
MainModule types.String `tfsdk:"main_module" json:"main_module,optional"`
101+
Migrations customfield.NestedObject[WorkersScriptMetadataMigrationsModel] `tfsdk:"migrations" json:"migrations,optional"`
102+
Observability *WorkersScriptMetadataObservabilityModel `tfsdk:"observability" json:"observability,optional"`
103+
Placement customfield.NestedObject[WorkersScriptMetadataPlacementModel] `tfsdk:"placement" json:"placement,computed_optional"`
104104
// Tags *[]types.String `tfsdk:"tags" json:"tags,optional"`
105105
TailConsumers customfield.NestedObjectSet[WorkersScriptMetadataTailConsumersModel] `tfsdk:"tail_consumers" json:"tail_consumers,computed_optional"`
106106
UsageModel types.String `tfsdk:"usage_model" json:"usage_model,computed_optional"`

internal/services/workers_script/schema.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ func ResourceSchema(ctx context.Context) schema.Schema {
145145
},
146146
},
147147
},
148-
"bindings": schema.SetNestedAttribute{
148+
"bindings": schema.ListNestedAttribute{
149149
Description: "List of bindings attached to a Worker. You can find more about bindings on our docs: https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/#bindings.",
150150
Computed: true,
151151
Optional: true,
152-
CustomType: customfield.NewNestedObjectSetType[WorkersScriptMetadataBindingsModel](ctx),
152+
CustomType: customfield.NewNestedObjectListType[WorkersScriptMetadataBindingsModel](ctx),
153153
NestedObject: schema.NestedAttributeObject{
154154
Attributes: map[string]schema.Attribute{
155155
"name": schema.StringAttribute{

internal/services/workers_script/testdata/module.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ resource "cloudflare_workers_script" "%[1]s" {
2828
type = "kv_namespace"
2929
namespace_id = cloudflare_workers_kv_namespace.%[1]s.id
3030
},
31-
{
32-
name = "SECRET"
33-
type = "secret_text"
34-
text = "shhh!!"
35-
},
3631
{
3732
name = "MY_QUEUE"
3833
type = "queue"
3934
queue_name = cloudflare_queue.%[1]s.queue_name
35+
},
36+
{
37+
name = "SECRET"
38+
type = "secret_text"
39+
text = "shhh!!"
4040
}
4141
]
4242
observability = {

0 commit comments

Comments
 (0)