Skip to content

Commit 1fa3e9b

Browse files
authored
fix: elastic indices datasource boolean parsing (#842)
* fix: Elastic Indices datasource boolean parsing * fix: Elastic Indices datasource boolean parsing
1 parent f4bd9a5 commit 1fa3e9b

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## [Unreleased]
22

3+
### Changes
4+
5+
- Fix boolean setting parsing for `elasticstack_elasticsearch_indices` data source. ([#842](https://github.com/elastic/terraform-provider-elasticstack/pull/842))
6+
37
## [0.11.9] - 2024-10-14
48

59
### Breaking changes

internal/elasticsearch/index/indices/models.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,20 @@ func setSettingsFromAPI(ctx context.Context, model *indexTfModel, apiModel model
284284
}
285285
tfValue = basetypes.NewStringValue(settingStr)
286286
case types.Bool:
287+
if settingStr, ok := settingsValue.(string); ok {
288+
settingBool, err := strconv.ParseBool(settingStr)
289+
if err != nil {
290+
return diag.Diagnostics{
291+
diag.NewErrorDiagnostic(
292+
"failed to convert setting to bool",
293+
fmt.Sprintf("expected setting to be a bool but it was a string. Attempted to parse it but got %s", err.Error()),
294+
),
295+
}
296+
}
297+
298+
settingsValue = settingBool
299+
}
300+
287301
settingBool, ok := settingsValue.(bool)
288302
if !ok {
289303
return diag.Diagnostics{
@@ -300,7 +314,7 @@ func setSettingsFromAPI(ctx context.Context, model *indexTfModel, apiModel model
300314
return diag.Diagnostics{
301315
diag.NewErrorDiagnostic(
302316
"failed to convert setting to int",
303-
fmt.Sprintf("expected setting to be an in but it was a string. Attempted to parse it but got %s", err.Error()),
317+
fmt.Sprintf("expected setting to be an int but it was a string. Attempted to parse it but got %s", err.Error()),
304318
),
305319
}
306320
}

0 commit comments

Comments
 (0)