Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/aws_cloudsearch_domain: fix index_field crash on read #35900

Merged
merged 2 commits into from
Feb 21, 2024
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
3 changes: 3 additions & 0 deletions .changelog/35900.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_cloudsearch_domain: Prevent panic when reading nil `index_field` options response values
```
33 changes: 33 additions & 0 deletions internal/service/cloudsearch/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,9 @@ func flattenIndexFieldStatus(apiObject types.IndexFieldStatus) (map[string]inter
switch fieldType {
case types.IndexFieldTypeDate:
options := field.DateOptions
if options == nil {
break
}

if v := options.DefaultValue; v != nil {
tfMap["default_value"] = aws.ToString(v)
Expand Down Expand Up @@ -1080,6 +1083,9 @@ func flattenIndexFieldStatus(apiObject types.IndexFieldStatus) (map[string]inter

case types.IndexFieldTypeDateArray:
options := field.DateArrayOptions
if options == nil {
break
}

if v := options.DefaultValue; v != nil {
tfMap["default_value"] = aws.ToString(v)
Expand Down Expand Up @@ -1108,6 +1114,9 @@ func flattenIndexFieldStatus(apiObject types.IndexFieldStatus) (map[string]inter

case types.IndexFieldTypeDouble:
options := field.DoubleOptions
if options == nil {
break
}

if v := options.DefaultValue; v != nil {
tfMap["default_value"] = flex.Float64ToStringValue(v)
Expand Down Expand Up @@ -1139,6 +1148,9 @@ func flattenIndexFieldStatus(apiObject types.IndexFieldStatus) (map[string]inter

case types.IndexFieldTypeDoubleArray:
options := field.DoubleArrayOptions
if options == nil {
break
}

if v := options.DefaultValue; v != nil {
tfMap["default_value"] = flex.Float64ToStringValue(v)
Expand Down Expand Up @@ -1167,6 +1179,9 @@ func flattenIndexFieldStatus(apiObject types.IndexFieldStatus) (map[string]inter

case types.IndexFieldTypeInt:
options := field.IntOptions
if options == nil {
break
}

if v := options.DefaultValue; v != nil {
tfMap["default_value"] = flex.Int64ToStringValue(v)
Expand Down Expand Up @@ -1198,6 +1213,9 @@ func flattenIndexFieldStatus(apiObject types.IndexFieldStatus) (map[string]inter

case types.IndexFieldTypeIntArray:
options := field.IntArrayOptions
if options == nil {
break
}

if v := options.DefaultValue; v != nil {
tfMap["default_value"] = flex.Int64ToStringValue(v)
Expand Down Expand Up @@ -1226,6 +1244,9 @@ func flattenIndexFieldStatus(apiObject types.IndexFieldStatus) (map[string]inter

case types.IndexFieldTypeLatlon:
options := field.LatLonOptions
if options == nil {
break
}

if v := options.DefaultValue; v != nil {
tfMap["default_value"] = aws.ToString(v)
Expand Down Expand Up @@ -1257,6 +1278,9 @@ func flattenIndexFieldStatus(apiObject types.IndexFieldStatus) (map[string]inter

case types.IndexFieldTypeLiteral:
options := field.LiteralOptions
if options == nil {
break
}

if v := options.DefaultValue; v != nil {
tfMap["default_value"] = aws.ToString(v)
Expand Down Expand Up @@ -1288,6 +1312,9 @@ func flattenIndexFieldStatus(apiObject types.IndexFieldStatus) (map[string]inter

case types.IndexFieldTypeLiteralArray:
options := field.LiteralArrayOptions
if options == nil {
break
}

if v := options.DefaultValue; v != nil {
tfMap["default_value"] = aws.ToString(v)
Expand Down Expand Up @@ -1316,6 +1343,9 @@ func flattenIndexFieldStatus(apiObject types.IndexFieldStatus) (map[string]inter

case types.IndexFieldTypeText:
options := field.TextOptions
if options == nil {
break
}

if v := options.AnalysisScheme; v != nil {
tfMap["analysis_scheme"] = aws.ToString(v)
Expand Down Expand Up @@ -1347,6 +1377,9 @@ func flattenIndexFieldStatus(apiObject types.IndexFieldStatus) (map[string]inter

case types.IndexFieldTypeTextArray:
options := field.TextArrayOptions
if options == nil {
break
}

if v := options.AnalysisScheme; v != nil {
tfMap["analysis_scheme"] = aws.ToString(v)
Expand Down
Loading