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

chore: Updates Atlas Go SDK #2380

Merged
merged 9 commits into from
Jul 2, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add LatestDefinition
lantoli committed Jul 2, 2024

Verified

This commit was signed with the committer’s verified signature.
lantoli Leo Antoli
commit b4dbaf6c406a5545eeba6cbe583091a445faf61c
18 changes: 9 additions & 9 deletions internal/service/searchindex/data_source_search_index.go
Original file line number Diff line number Diff line change
@@ -123,11 +123,11 @@
return diag.Errorf("error setting `index_id` for search index (%s): %s", d.Id(), err)
}

if err := d.Set("analyzer", searchIndex.Analyzer); err != nil {
if err := d.Set("analyzer", searchIndex.LatestDefinition.Analyzer); err != nil {
return diag.Errorf("error setting `analyzer` for search index (%s): %s", d.Id(), err)
}

if analyzers := searchIndex.GetAnalyzers(); len(analyzers) > 0 {
if analyzers := searchIndex.LatestDefinition.GetAnalyzers(); len(analyzers) > 0 {
searchIndexMappingFields, err := marshalSearchIndex(analyzers)
if err != nil {
return diag.FromErr(err)
@@ -150,21 +150,21 @@
return diag.Errorf("error setting `name` for search index (%s): %s", d.Id(), err)
}

if err := d.Set("search_analyzer", searchIndex.SearchAnalyzer); err != nil {
if err := d.Set("search_analyzer", searchIndex.LatestDefinition.SearchAnalyzer); err != nil {
return diag.Errorf("error setting `searchAnalyzer` for search index (%s): %s", d.Id(), err)
}

if err := d.Set("synonyms", flattenSearchIndexSynonyms(searchIndex.GetSynonyms())); err != nil {
if err := d.Set("synonyms", flattenSearchIndexSynonyms(searchIndex.LatestDefinition.GetSynonyms())); err != nil {
return diag.Errorf("error setting `synonyms` for search index (%s): %s", d.Id(), err)
}

if searchIndex.Mappings != nil {
if err := d.Set("mappings_dynamic", searchIndex.Mappings.Dynamic); err != nil {
if searchIndex.LatestDefinition.Mappings != nil {
if err := d.Set("mappings_dynamic", searchIndex.LatestDefinition.Mappings.Dynamic); err != nil {
return diag.Errorf("error setting `mappings_dynamic` for search index (%s): %s", d.Id(), err)
}

if len(searchIndex.Mappings.Fields) > 0 {
searchIndexMappingFields, err := marshalSearchIndex(searchIndex.Mappings.Fields)
if len(searchIndex.LatestDefinition.Mappings.Fields) > 0 {

Check failure on line 166 in internal/service/searchindex/data_source_search_index.go

GitHub Actions / tf-validate (1.9.x)

invalid argument: searchIndex.LatestDefinition.Mappings.Fields (variable of type interface{}) for len

Check failure on line 166 in internal/service/searchindex/data_source_search_index.go

GitHub Actions / build

invalid argument: searchIndex.LatestDefinition.Mappings.Fields (variable of type interface{}) for len

Check failure on line 166 in internal/service/searchindex/data_source_search_index.go

GitHub Actions / lint

invalid argument: searchIndex.LatestDefinition.Mappings.Fields (variable of type interface{}) for len
searchIndexMappingFields, err := marshalSearchIndex(searchIndex.LatestDefinition.Mappings.Fields)
if err != nil {
return diag.FromErr(err)
}
@@ -174,7 +174,7 @@
}
}

if fields := searchIndex.GetFields(); len(fields) > 0 {
if fields := searchIndex.LatestDefinition.GetFields(); len(fields) > 0 {
fieldsMarshaled, err := marshalSearchIndex(fields)
if err != nil {
return diag.FromErr(err)
40 changes: 20 additions & 20 deletions internal/service/searchindex/resource_search_index.go
Original file line number Diff line number Diff line change
@@ -198,63 +198,63 @@
}

if d.HasChange("analyzer") {
searchIndex.Analyzer = conversion.StringPtr(d.Get("analyzer").(string))
searchIndex.LatestDefinition.Analyzer = conversion.StringPtr(d.Get("analyzer").(string))
}

if d.HasChange("collection_name") {
searchIndex.CollectionName = d.Get("collection_name").(string)

Check failure on line 205 in internal/service/searchindex/resource_search_index.go

GitHub Actions / tf-validate (1.9.x)

cannot use d.Get("collection_name").(string) (comma, ok expression of type string) as *string value in assignment

Check failure on line 205 in internal/service/searchindex/resource_search_index.go

GitHub Actions / build

cannot use d.Get("collection_name").(string) (comma, ok expression of type string) as *string value in assignment

Check failure on line 205 in internal/service/searchindex/resource_search_index.go

GitHub Actions / lint

cannot use d.Get("collection_name").(string) (comma, ok expression of type string) as *string value in assignment
}

if d.HasChange("database") {
searchIndex.Database = d.Get("database").(string)

Check failure on line 209 in internal/service/searchindex/resource_search_index.go

GitHub Actions / tf-validate (1.9.x)

cannot use d.Get("database").(string) (comma, ok expression of type string) as *string value in assignment

Check failure on line 209 in internal/service/searchindex/resource_search_index.go

GitHub Actions / build

cannot use d.Get("database").(string) (comma, ok expression of type string) as *string value in assignment

Check failure on line 209 in internal/service/searchindex/resource_search_index.go

GitHub Actions / lint

cannot use d.Get("database").(string) (comma, ok expression of type string) as *string value in assignment
}

if d.HasChange("name") {
searchIndex.Name = d.Get("name").(string)

Check failure on line 213 in internal/service/searchindex/resource_search_index.go

GitHub Actions / tf-validate (1.9.x)

cannot use d.Get("name").(string) (comma, ok expression of type string) as *string value in assignment

Check failure on line 213 in internal/service/searchindex/resource_search_index.go

GitHub Actions / build

cannot use d.Get("name").(string) (comma, ok expression of type string) as *string value in assignment

Check failure on line 213 in internal/service/searchindex/resource_search_index.go

GitHub Actions / lint

cannot use d.Get("name").(string) (comma, ok expression of type string) as *string value in assignment
}

if d.HasChange("search_analyzer") {
searchIndex.SearchAnalyzer = conversion.StringPtr(d.Get("search_analyzer").(string))
searchIndex.LatestDefinition.SearchAnalyzer = conversion.StringPtr(d.Get("search_analyzer").(string))
}

if d.HasChange("analyzers") {
analyzers, err := unmarshalSearchIndexAnalyzersFields(d.Get("analyzers").(string))
if err != nil {
return err
}
searchIndex.Analyzers = &analyzers
searchIndex.LatestDefinition.Analyzers = &analyzers

Check failure on line 225 in internal/service/searchindex/resource_search_index.go

GitHub Actions / tf-validate (1.9.x)

cannot use &analyzers (value of type *[]admin.ApiAtlasFTSAnalyzers) as *[]admin.AtlasSearchAnalyzer value in assignment

Check failure on line 225 in internal/service/searchindex/resource_search_index.go

GitHub Actions / build

cannot use &analyzers (value of type *[]admin.ApiAtlasFTSAnalyzers) as *[]admin.AtlasSearchAnalyzer value in assignment

Check failure on line 225 in internal/service/searchindex/resource_search_index.go

GitHub Actions / lint

cannot use &analyzers (value of type *[]admin.ApiAtlasFTSAnalyzers) as *[]admin.AtlasSearchAnalyzer value in assignment
}

if d.HasChange("mappings_dynamic") {
dynamic := d.Get("mappings_dynamic").(bool)
if searchIndex.Mappings == nil {
searchIndex.Mappings = &admin.ApiAtlasFTSMappings{}
if searchIndex.LatestDefinition.Mappings == nil {
searchIndex.LatestDefinition.Mappings = &admin.ApiAtlasFTSMappings{}

Check failure on line 231 in internal/service/searchindex/resource_search_index.go

GitHub Actions / tf-validate (1.9.x)

cannot use &admin.ApiAtlasFTSMappings{} (value of type *admin.ApiAtlasFTSMappings) as *admin.SearchMappings value in assignment

Check failure on line 231 in internal/service/searchindex/resource_search_index.go

GitHub Actions / build

cannot use &admin.ApiAtlasFTSMappings{} (value of type *admin.ApiAtlasFTSMappings) as *admin.SearchMappings value in assignment

Check failure on line 231 in internal/service/searchindex/resource_search_index.go

GitHub Actions / lint

cannot use &admin.ApiAtlasFTSMappings{} (value of type *admin.ApiAtlasFTSMappings) as *admin.SearchMappings value in assignment
}
searchIndex.Mappings.Dynamic = &dynamic
searchIndex.LatestDefinition.Mappings.Dynamic = &dynamic
}

if d.HasChange("mappings_fields") {
mappingsFields, err := unmarshalSearchIndexMappingFields(d.Get("mappings_fields").(string))
if err != nil {
return err
}
if searchIndex.Mappings == nil {
searchIndex.Mappings = &admin.ApiAtlasFTSMappings{}
if searchIndex.LatestDefinition.Mappings == nil {
searchIndex.LatestDefinition.Mappings = &admin.ApiAtlasFTSMappings{}

Check failure on line 242 in internal/service/searchindex/resource_search_index.go

GitHub Actions / tf-validate (1.9.x)

cannot use &admin.ApiAtlasFTSMappings{} (value of type *admin.ApiAtlasFTSMappings) as *admin.SearchMappings value in assignment

Check failure on line 242 in internal/service/searchindex/resource_search_index.go

GitHub Actions / build

cannot use &admin.ApiAtlasFTSMappings{} (value of type *admin.ApiAtlasFTSMappings) as *admin.SearchMappings value in assignment

Check failure on line 242 in internal/service/searchindex/resource_search_index.go

GitHub Actions / lint

cannot use &admin.ApiAtlasFTSMappings{} (value of type *admin.ApiAtlasFTSMappings) as *admin.SearchMappings value in assignment
}
searchIndex.Mappings.Fields = mappingsFields
searchIndex.LatestDefinition.Mappings.Fields = mappingsFields
}

if d.HasChange("fields") {
fields, err := unmarshalSearchIndexFields(d.Get("fields").(string))
if err != nil {
return err
}
searchIndex.Fields = &fields
searchIndex.LatestDefinition.Fields = &fields

Check failure on line 252 in internal/service/searchindex/resource_search_index.go

GitHub Actions / tf-validate (1.9.x)

cannot use &fields (value of type *[]map[string]any) as *[]interface{} value in assignment

Check failure on line 252 in internal/service/searchindex/resource_search_index.go

GitHub Actions / build

cannot use &fields (value of type *[]map[string]any) as *[]interface{} value in assignment

Check failure on line 252 in internal/service/searchindex/resource_search_index.go

GitHub Actions / lint

cannot use &fields (value of type *[]map[string]any) as *[]interface{} value in assignment
}

if d.HasChange("synonyms") {
synonyms := expandSearchIndexSynonyms(d)
searchIndex.Synonyms = &synonyms
searchIndex.LatestDefinition.Synonyms = &synonyms
}

searchIndex.IndexID = conversion.StringPtr("")
@@ -313,11 +313,11 @@
return diag.Errorf("error setting `type` for search index (%s): %s", d.Id(), err)
}

if err := d.Set("analyzer", searchIndex.Analyzer); err != nil {
if err := d.Set("analyzer", searchIndex.LatestDefinition.Analyzer); err != nil {
return diag.Errorf("error setting `analyzer` for search index (%s): %s", d.Id(), err)
}

if analyzers := searchIndex.GetAnalyzers(); len(analyzers) > 0 {
if analyzers := searchIndex.LatestDefinition.GetAnalyzers(); len(analyzers) > 0 {
searchIndexMappingFields, err := marshalSearchIndex(analyzers)
if err != nil {
return diag.FromErr(err)
@@ -339,21 +339,21 @@
return diag.Errorf("error setting `name` for search index (%s): %s", d.Id(), err)
}

if err := d.Set("search_analyzer", searchIndex.SearchAnalyzer); err != nil {
if err := d.Set("search_analyzer", searchIndex.LatestDefinition.SearchAnalyzer); err != nil {
return diag.Errorf("error setting `searchAnalyzer` for search index (%s): %s", d.Id(), err)
}

if err := d.Set("synonyms", flattenSearchIndexSynonyms(searchIndex.GetSynonyms())); err != nil {
if err := d.Set("synonyms", flattenSearchIndexSynonyms(searchIndex.LatestDefinition.GetSynonyms())); err != nil {
return diag.Errorf("error setting `synonyms` for search index (%s): %s", d.Id(), err)
}

if searchIndex.Mappings != nil {
if err := d.Set("mappings_dynamic", searchIndex.Mappings.Dynamic); err != nil {
if searchIndex.LatestDefinition.Mappings != nil {
if err := d.Set("mappings_dynamic", searchIndex.LatestDefinition.Mappings.Dynamic); err != nil {
return diag.Errorf("error setting `mappings_dynamic` for search index (%s): %s", d.Id(), err)
}

if len(searchIndex.Mappings.Fields) > 0 {
searchIndexMappingFields, err := marshalSearchIndex(searchIndex.Mappings.Fields)
if len(searchIndex.LatestDefinition.Mappings.Fields) > 0 {
searchIndexMappingFields, err := marshalSearchIndex(searchIndex.LatestDefinition.Mappings.Fields)
if err != nil {
return diag.FromErr(err)
}
@@ -363,7 +363,7 @@
}
}

if fields := searchIndex.GetFields(); len(fields) > 0 {
if fields := searchIndex.LatestDefinition.GetFields(); len(fields) > 0 {
fieldsMarshaled, err := marshalSearchIndex(fields)
if err != nil {
return diag.FromErr(err)

Unchanged files with check annotations Beta

return diag.Errorf("error getting search indexes information: %s", err)
}
flattedSearchIndexes, err := flattenSearchIndexes(searchIndexes, projectID.(string), clusterName.(string))

Check failure on line 65 in internal/service/searchindex/data_source_search_indexes.go

GitHub Actions / tf-validate (1.9.x)

cannot use searchIndexes (variable of type []admin.SearchIndexResponse) as []admin.ClusterSearchIndex value in argument to flattenSearchIndexes

Check failure on line 65 in internal/service/searchindex/data_source_search_indexes.go

GitHub Actions / build

cannot use searchIndexes (variable of type []admin.SearchIndexResponse) as []admin.ClusterSearchIndex value in argument to flattenSearchIndexes

Check failure on line 65 in internal/service/searchindex/data_source_search_indexes.go

GitHub Actions / lint

cannot use searchIndexes (variable of type []admin.SearchIndexResponse) as []admin.ClusterSearchIndex value in argument to flattenSearchIndexes
if err != nil {
return diag.FromErr(err)
}
if searchIndexes[i].Mappings != nil {
searchIndexesMap[i]["mappings_dynamic"] = searchIndexes[i].Mappings.Dynamic
if len(searchIndexes[i].Mappings.Fields) > 0 {

Check failure on line 109 in internal/service/searchindex/data_source_search_indexes.go

GitHub Actions / tf-validate (1.9.x)

invalid argument: searchIndexes[i].Mappings.Fields (variable of type interface{}) for len

Check failure on line 109 in internal/service/searchindex/data_source_search_indexes.go

GitHub Actions / build

invalid argument: searchIndexes[i].Mappings.Fields (variable of type interface{}) for len

Check failure on line 109 in internal/service/searchindex/data_source_search_indexes.go

GitHub Actions / lint

invalid argument: searchIndexes[i].Mappings.Fields (variable of type interface{}) for len
searchIndexMappingFields, err := marshalSearchIndex(searchIndexes[i].Mappings.Fields)
if err != nil {
return nil, err