Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## [Unreleased]

### Changes

- Fix boolean setting parsing for `elasticstack_elasticsearch_indices` data source. ([#842](https://github.com/elastic/terraform-provider-elasticstack/pull/842))

## [0.11.9] - 2024-10-14

### Breaking changes
Expand Down
16 changes: 15 additions & 1 deletion internal/elasticsearch/index/indices/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,20 @@ func setSettingsFromAPI(ctx context.Context, model *indexTfModel, apiModel model
}
tfValue = basetypes.NewStringValue(settingStr)
case types.Bool:
if settingStr, ok := settingsValue.(string); ok {
settingBool, err := strconv.ParseBool(settingStr)
if err != nil {
return diag.Diagnostics{
diag.NewErrorDiagnostic(
"failed to convert setting to bool",
fmt.Sprintf("expected setting to be a bool but it was a string. Attempted to parse it but got %s", err.Error()),
),
}
}

settingsValue = settingBool
}

settingBool, ok := settingsValue.(bool)
if !ok {
return diag.Diagnostics{
Expand All @@ -300,7 +314,7 @@ func setSettingsFromAPI(ctx context.Context, model *indexTfModel, apiModel model
return diag.Diagnostics{
diag.NewErrorDiagnostic(
"failed to convert setting to int",
fmt.Sprintf("expected setting to be an in but it was a string. Attempted to parse it but got %s", err.Error()),
fmt.Sprintf("expected setting to be an int but it was a string. Attempted to parse it but got %s", err.Error()),
),
}
}
Expand Down
Loading