Skip to content

Commit 6a362c7

Browse files
Copilottobio
andcommitted
Complete script resource migration with lint fixes and changelog update
Co-authored-by: tobio <[email protected]>
1 parent 190e627 commit 6a362c7

File tree

12 files changed

+16
-16
lines changed

12 files changed

+16
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- Migrate `elasticstack_kibana_action_connector` to the Terraform plugin framework ([#1269](https://github.com/elastic/terraform-provider-elasticstack/pull/1269))
1414
- Migrate `elasticstack_elasticsearch_security_role_mapping` resource and data source to Terraform Plugin Framework ([#1279](https://github.com/elastic/terraform-provider-elasticstack/pull/1279))
1515
- Add support for `inactivity_timeout` in `elasticstack_fleet_agent_policy` ([#641](https://github.com/elastic/terraform-provider-elasticstack/issues/641))
16+
- Migrate `elasticstack_elasticsearch_script` resource to Terraform Plugin Framework ([#1297](https://github.com/elastic/terraform-provider-elasticstack/pull/1297))
1617

1718
## [0.11.17] - 2025-07-21
1819

internal/elasticsearch/cluster/script/acc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,4 @@ func checkScriptDestroy(s *terraform.State) error {
217217
}
218218
}
219219
return nil
220-
}
220+
}

internal/elasticsearch/cluster/script/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ func (r *scriptResource) Create(ctx context.Context, req resource.CreateRequest,
1212
if resp.Diagnostics.HasError() {
1313
return
1414
}
15-
}
15+
}

internal/elasticsearch/cluster/script/delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ func (r *scriptResource) Delete(ctx context.Context, req resource.DeleteRequest,
3030

3131
sdkDiags := elasticsearch.DeleteScript(ctx, client, compId.ResourceId)
3232
resp.Diagnostics.Append(utils.FrameworkDiagsFromSDK(sdkDiags)...)
33-
}
33+
}

internal/elasticsearch/cluster/script/models.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ type ScriptData struct {
1212
Source types.String `tfsdk:"source"`
1313
Params types.String `tfsdk:"params"`
1414
Context types.String `tfsdk:"context"`
15-
}
15+
}

internal/elasticsearch/cluster/script/read.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,20 @@ func (r *scriptResource) Read(ctx context.Context, req resource.ReadRequest, res
5050
data.Source = types.StringValue(script.Source)
5151

5252
// Handle params if returned by the API
53-
if script.Params != nil && len(script.Params) > 0 {
53+
if len(script.Params) > 0 {
5454
paramsBytes, err := json.Marshal(script.Params)
5555
if err != nil {
5656
resp.Diagnostics.AddError("Error marshaling script params", err.Error())
5757
return
5858
}
5959
data.Params = types.StringValue(string(paramsBytes))
60-
} else if !data.Params.IsNull() {
61-
// If params were set but API doesn't return them, preserve from state
62-
// This maintains backwards compatibility
6360
}
61+
// Note: If params were set but API doesn't return them, they are preserved from state
62+
// This maintains backwards compatibility
6463

6564
// Note: context is not returned by the Elasticsearch API (json:"-" in model)
6665
// It's only used during script creation, so we preserve it from state
6766
// This is consistent with the SDKv2 implementation
6867

6968
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
70-
}
69+
}

internal/elasticsearch/cluster/script/resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ func (r *scriptResource) Configure(_ context.Context, req resource.ConfigureRequ
2323
client, diags := clients.ConvertProviderData(req.ProviderData)
2424
resp.Diagnostics.Append(diags...)
2525
r.client = client
26-
}
26+
}

internal/elasticsearch/cluster/script/schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ func GetSchema() schema.Schema {
6060
},
6161
},
6262
}
63-
}
63+
}

internal/elasticsearch/cluster/script/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ func (r *scriptResource) Update(ctx context.Context, req resource.UpdateRequest,
7272
if resp.Diagnostics.HasError() {
7373
return
7474
}
75-
}
75+
}

internal/utils/validators/string_is_json.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ func (s StringIsJSON) ValidateString(_ context.Context, req validator.StringRequ
3232
)
3333
return
3434
}
35-
}
35+
}

0 commit comments

Comments
 (0)