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: Upgrades Atlas SDK to v20231115012 #2211

Merged
merged 3 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/stretchr/testify v1.9.0
github.com/zclconf/go-cty v1.14.4
go.mongodb.org/atlas v0.36.0
go.mongodb.org/atlas-sdk/v20231115010 v20231115010.1.0
go.mongodb.org/atlas-sdk/v20231115012 v20231115012.0.0
go.mongodb.org/realm v0.1.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -777,8 +777,8 @@ go.mongodb.org/atlas v0.36.0 h1:m05S3AO7zkl+bcG1qaNsEKBnAqnKx2FDwLooHpIG3j4=
go.mongodb.org/atlas v0.36.0/go.mod h1:nfPldE9dSama6G2IbIzmEza02Ly7yFZjMMVscaM0uEc=
go.mongodb.org/atlas-sdk/v20231115008 v20231115008.5.0 h1:OuV1HfIpZUZa4+BKvtrvDlNqnilkCkdHspuZok6KAbM=
go.mongodb.org/atlas-sdk/v20231115008 v20231115008.5.0/go.mod h1:0707RpWIrNFZ6Msy/dwRDCzC5JVDon61JoOqcbfCujg=
go.mongodb.org/atlas-sdk/v20231115010 v20231115010.1.0 h1:++ZXml+foSkFymb7/5LsW09zRM1gjqyhMZmPkVjhxcM=
go.mongodb.org/atlas-sdk/v20231115010 v20231115010.1.0/go.mod h1:jfwDhrkj8OyLIn0qQ8SdcwqmALow1G/njEOtPyQgoSM=
go.mongodb.org/atlas-sdk/v20231115012 v20231115012.0.0 h1:W9UBXxf+/honL2H8W0/GizUWa9kJ2Ge0H6gsexPTU6c=
go.mongodb.org/atlas-sdk/v20231115012 v20231115012.0.0/go.mod h1:8Mjf7v7mtjTcwF8NLsKjb1aqFAyf1bmsjzBoykjWdUw=
go.mongodb.org/realm v0.1.0 h1:zJiXyLaZrznQ+Pz947ziSrDKUep39DO4SfA0Fzx8M4M=
go.mongodb.org/realm v0.1.0/go.mod h1:4Vj6iy+Puo1TDERcoh4XZ+pjtwbOzPpzqy3Cwe8ZmDM=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
Expand Down
2 changes: 1 addition & 1 deletion internal/common/conversion/flatten_expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package conversion
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

func FlattenLinks(links []admin.Link) []map[string]string {
Expand Down
2 changes: 1 addition & 1 deletion internal/config/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"

admin20231115008 "go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
matlasClient "go.mongodb.org/atlas/mongodbatlas"
realmAuth "go.mongodb.org/realm/auth"
"go.mongodb.org/realm/realm"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"

"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

func PluralDataSource() *schema.Resource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

func Resource() *schema.Resource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

func PluralDataSource() *schema.Resource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/spf13/cast"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115010/mockadmin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
"go.mongodb.org/atlas-sdk/v20231115012/mockadmin"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/validate"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
"github.com/spf13/cast"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
"github.com/zclconf/go-cty/cty"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

var _ datasource.DataSource = &alertConfigurationDS{}
Expand Down Expand Up @@ -343,14 +343,11 @@ func outputAlertConfigurationResourceImport(label string, alert *admin.GroupAler
return fmt.Sprintf("terraform import mongodbatlas_alert_configuration.%s %s-%s\n", label, *alert.GroupId, *alert.Id)
}

func convertMatcherToCtyValues(matcher map[string]any) map[string]cty.Value {
fieldName, _ := matcher["fieldName"].(string)
operator, _ := matcher["operator"].(string)
value, _ := matcher["value"].(string)
func convertMatcherToCtyValues(matcher admin.StreamsMatcher) map[string]cty.Value {
return map[string]cty.Value{
"field_name": cty.StringVal(fieldName),
"operator": cty.StringVal(operator),
"value": cty.StringVal(value),
"field_name": cty.StringVal(matcher.FieldName),
"operator": cty.StringVal(matcher.Operator),
"value": cty.StringVal(matcher.Value),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

const alertConfigurationsDataSourceName = "alert_configurations"
Expand Down
34 changes: 14 additions & 20 deletions internal/service/alertconfiguration/model_alert_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

func NewNotificationList(list []TfNotificationModel) (*[]admin.AlertsNotificationRootForGroup, error) {
Expand Down Expand Up @@ -81,13 +81,13 @@ func NewMetricThreshold(tfMetricThresholdConfigSlice []TfMetricThresholdConfigMo
}
}

func NewMatcherList(list []TfMatcherModel) *[]map[string]any {
matchers := make([]map[string]any, len(list))
func NewMatcherList(list []TfMatcherModel) *[]admin.StreamsMatcher {
matchers := make([]admin.StreamsMatcher, len(list))
for i, matcher := range list {
matchers[i] = map[string]any{
"fieldName": matcher.FieldName.ValueString(),
"operator": matcher.Operator.ValueString(),
"value": matcher.Value.ValueString(),
matchers[i] = admin.StreamsMatcher{
FieldName: matcher.FieldName.ValueString(),
Operator: matcher.Operator.ValueString(),
Value: matcher.Value.ValueString(),
Comment on lines -87 to +90
Copy link
Member Author

@AgustinBettati AgustinBettati Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only change was in alert configuration matchers model which is now typed (was a map[string]any before).

}
}
return &matchers
Expand Down Expand Up @@ -250,17 +250,14 @@ func NewTFThresholdConfigModel(t *admin.GreaterThanRawThreshold, currStateSlice
return []TfThresholdConfigModel{newState}
}

func NewTFMatcherModelList(m []map[string]any, currStateSlice []TfMatcherModel) []TfMatcherModel {
func NewTFMatcherModelList(m []admin.StreamsMatcher, currStateSlice []TfMatcherModel) []TfMatcherModel {
matchers := make([]TfMatcherModel, len(m))
if len(m) != len(currStateSlice) { // matchers were modified elsewhere from terraform, or import statement is being called
for i, matcher := range m {
fieldName, _ := matcher["fieldName"].(string)
operator, _ := matcher["operator"].(string)
value, _ := matcher["value"].(string)
matchers[i] = TfMatcherModel{
FieldName: conversion.StringNullIfEmpty(fieldName),
Operator: conversion.StringNullIfEmpty(operator),
Value: conversion.StringNullIfEmpty(value),
FieldName: types.StringValue(matcher.FieldName),
Operator: types.StringValue(matcher.Operator),
Value: types.StringValue(matcher.Value),
}
}
return matchers
Expand All @@ -269,16 +266,13 @@ func NewTFMatcherModelList(m []map[string]any, currStateSlice []TfMatcherModel)
currState := currStateSlice[i]
newState := TfMatcherModel{}
if !currState.FieldName.IsNull() {
fieldName, _ := matcher["fieldName"].(string)
newState.FieldName = conversion.StringNullIfEmpty(fieldName)
newState.FieldName = types.StringValue(matcher.FieldName)
}
if !currState.Operator.IsNull() {
operator, _ := matcher["operator"].(string)
newState.Operator = conversion.StringNullIfEmpty(operator)
newState.Operator = types.StringValue(matcher.Operator)
}
if !currState.Value.IsNull() {
value, _ := matcher["value"].(string)
newState.Value = conversion.StringNullIfEmpty(value)
newState.Value = types.StringValue(matcher.Value)
}
matchers[i] = newState
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/alertconfiguration"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

const (
Expand Down Expand Up @@ -176,16 +176,16 @@ func TestThresholdConfigSDKToTFModel(t *testing.T) {
func TestMatcherSDKToTFModel(t *testing.T) {
testCases := []struct {
name string
SDKResp []map[string]interface{}
SDKResp []admin.StreamsMatcher
currentStateMatcher []alertconfiguration.TfMatcherModel
expectedTFModel []alertconfiguration.TfMatcherModel
}{
{
name: "Complete SDK response",
SDKResp: []map[string]interface{}{{
"fieldName": "HOSTNAME",
"operator": "EQUALS",
"value": "PRIMARY",
SDKResp: []admin.StreamsMatcher{{
FieldName: "HOSTNAME",
Operator: "EQUALS",
Value: "PRIMARY",
},
},
currentStateMatcher: []alertconfiguration.TfMatcherModel{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion internal/service/apikey/data_source_api_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

func PluralDataSource() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion internal/service/apikey/resource_api_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

func Resource() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion internal/service/atlasuser/data_source_atlas_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

func TestAccConfigDSAtlasUser_ByUserID(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/service/atlasuser/data_source_atlas_users.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/id"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/atlasuser"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

func TestAccConfigDSAtlasUsers_ByOrgID(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/service/auditing/resource_auditing.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"net/http"
"strings"

"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
"github.com/spf13/cast"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/mig"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

func TestMigBackupRSCloudBackupSchedule_basic(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

func PluralDataSource() *schema.Resource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"
"regexp"

"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

func SplitSnapshotImportID(id string) (*admin.GetReplicaSetBackupApiParams, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/go-test/deep"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/cloudbackupsnapshot"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

func TestSplitSnapshotImportID(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/cluster"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

func Resource() *schema.Resource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
"go.mongodb.org/atlas-sdk/v20231115010/admin"
"go.mongodb.org/atlas-sdk/v20231115012/admin"
)

const (
Expand Down
Loading
Loading