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: Uses new Atlas Go SDK version #1831

Merged
merged 21 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from 13 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 @@ -27,7 +27,7 @@ require (
github.com/zclconf/go-cty v1.14.1
go.mongodb.org/atlas v0.36.0
go.mongodb.org/atlas-sdk/v20231001002 v20231001002.0.0
go.mongodb.org/atlas-sdk/v20231115002 v20231115002.1.0
go.mongodb.org/atlas-sdk/v20231115003 v20231115003.1.0
go.mongodb.org/realm v0.1.0
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -761,8 +761,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/v20231001002 v20231001002.0.0 h1:h1X2CGKyN1UFvNs69vp7xpufbbreq6p7bbrg5uJ1sxw=
go.mongodb.org/atlas-sdk/v20231001002 v20231001002.0.0/go.mod h1:4TAUPaWPFNSbi8c1hbQLr1wAdkmqi48O7zvyXjBM+a8=
go.mongodb.org/atlas-sdk/v20231115002 v20231115002.1.0 h1:x6nnq2pUIP9mN4WLD4/EseBzV88OmSgexxYchPilgno=
go.mongodb.org/atlas-sdk/v20231115002 v20231115002.1.0/go.mod h1:el7cm23kEiiw72HAYimhNweKqp/ubHsNJk+Mk30yJhM=
go.mongodb.org/atlas-sdk/v20231115003 v20231115003.1.0 h1:31Li8Xb1THAzYfAVDR9hhAn4z9IhmFs/+AbGqADsyt8=
go.mongodb.org/atlas-sdk/v20231115003 v20231115003.1.0/go.mod h1:tXE5JorXFSauhnw9Xu+/tNrRh90rTX8rYs9y0i2Jy+c=
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
14 changes: 14 additions & 0 deletions internal/common/conversion/type_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,17 @@ func IsStringPresent(strPtr *string) bool {
func MongoDBRegionToAWSRegion(region string) string {
return strings.ReplaceAll(strings.ToLower(region), "_", "-")
}

func SlicePtrToSlice[T any](v *[]T) []T {
lantoli marked this conversation as resolved.
Show resolved Hide resolved
if v == nil {
return nil
}
return *v
}

func NonEmptySliceToSlicePtr[T any](v []T) *[]T {
Copy link
Collaborator

@gssbzn gssbzn Jan 15, 2024

Choose a reason for hiding this comment

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

if slices only let's be more correct about it

Suggested change
func NonEmptySliceToSlicePtr[T any](v []T) *[]T {
func NonEmptySliceToSlicePtr[S ~[]E, E any]](v S) *S {

Copy link
Member Author

Choose a reason for hiding this comment

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

name changed to NonEmptyToPtr as it might called for slices or also arrays.

Copy link
Member

Choose a reason for hiding this comment

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

we will likely have a similar approach in CFN and CLI for this version upgrade, could be worth incorporating within SDK as a helper function and mention in upgrade guide.

Copy link
Member Author

Choose a reason for hiding this comment

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

@gssbzn what do you think?

on the other hand I think I'll be able to delete most of the uses of this function in next PRs

if len(v) == 0 {
return nil
}
return &v
}
32 changes: 32 additions & 0 deletions internal/common/conversion/type_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"time"

"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/stretchr/testify/assert"
)

func TestTimeToStringWithoutNanos(t *testing.T) {
Expand Down Expand Up @@ -67,3 +68,34 @@ func TestMongoDBRegionToAWSRegion(t *testing.T) {
}
}
}

func TestSlice_SameBehavior(t *testing.T) {
tests := []struct {
name string
ptr *[]string
slice []string
}{
{"nil pointer and slice", nil, nil},
{"slice with content", &[]string{"hello", "there"}, []string{"hello", "there"}},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
assert.Equal(t, tc.slice, conversion.SlicePtrToSlice(tc.ptr))
assert.Equal(t, tc.ptr, conversion.NonEmptySliceToSlicePtr(tc.slice))
})
}
}

func TestSlice_DifferentBehavior(t *testing.T) {
lantoli marked this conversation as resolved.
Show resolved Hide resolved
var (
nilSlice []string
emptyNonNilSlice = []string{}
)
assert.Nil(t, conversion.SlicePtrToSlice(&nilSlice))
assert.NotEqual(t, &nilSlice, conversion.NonEmptySliceToSlicePtr[string](nil))
assert.Nil(t, conversion.NonEmptySliceToSlicePtr[string](nil))

assert.Equal(t, emptyNonNilSlice, conversion.SlicePtrToSlice(&emptyNonNilSlice))
assert.NotNil(t, conversion.SlicePtrToSlice(&emptyNonNilSlice))
assert.Nil(t, conversion.NonEmptySliceToSlicePtr(emptyNonNilSlice))
}
2 changes: 1 addition & 1 deletion internal/config/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/mongodb/terraform-provider-mongodbatlas/version"
"github.com/spf13/cast"
oldAtlasSDK "go.mongodb.org/atlas-sdk/v20231001002/admin"
atlasSDK "go.mongodb.org/atlas-sdk/v20231115002/admin"
atlasSDK "go.mongodb.org/atlas-sdk/v20231115003/admin"
matlasClient "go.mongodb.org/atlas/mongodbatlas"
realmAuth "go.mongodb.org/realm/auth"
"go.mongodb.org/realm/realm"
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/provider_authentication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
"go.mongodb.org/atlas-sdk/v20231115002/admin"
"go.mongodb.org/atlas-sdk/v20231115003/admin"
)

func TestAccSTSAssumeRole_basic(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/zclconf/go-cty/cty"
"go.mongodb.org/atlas-sdk/v20231115002/admin"
"go.mongodb.org/atlas-sdk/v20231115003/admin"
)

var _ datasource.DataSource = &alertConfigurationDS{}
Expand Down Expand Up @@ -319,7 +319,7 @@ func outputAlertConfigurationResourceHcl(label string, alert *admin.GroupAlertsC
resource.SetAttributeValue("enabled", cty.BoolVal(*alert.Enabled))
}

for _, matcher := range alert.Matchers {
for _, matcher := range conversion.SlicePtrToSlice(alert.Matchers) {
gssbzn marked this conversation as resolved.
Show resolved Hide resolved
appendBlockWithCtyValues(resource, "matcher", []string{}, convertMatcherToCtyValues(matcher))
}

Expand All @@ -331,8 +331,9 @@ func outputAlertConfigurationResourceHcl(label string, alert *admin.GroupAlertsC
appendBlockWithCtyValues(resource, "threshold_config", []string{}, convertThresholdToCtyValues(alert.Threshold))
}

for i := 0; i < len(alert.Notifications); i++ {
appendBlockWithCtyValues(resource, "notification", []string{}, convertNotificationToCtyValues(&alert.Notifications[i]))
notifications := conversion.SlicePtrToSlice(alert.Notifications)
for i := 0; i < len(notifications); i++ {
appendBlockWithCtyValues(resource, "notification", []string{}, convertNotificationToCtyValues(&notifications[i]))
}

return string(f.Bytes())
Expand Down Expand Up @@ -438,16 +439,14 @@ func convertNotificationToCtyValues(notification *admin.AlertsNotificationRootFo
values["sms_enabled"] = cty.BoolVal(*notification.SmsEnabled)
}

if len(notification.Roles) > 0 {
roles := make([]cty.Value, 0)

for _, r := range notification.Roles {
if roles := conversion.SlicePtrToSlice(notification.Roles); len(roles) > 0 {
roleList := make([]cty.Value, 0)
gssbzn marked this conversation as resolved.
Show resolved Hide resolved
for _, r := range roles {
if r != "" {
roles = append(roles, cty.StringVal(r))
roleList = append(roleList, cty.StringVal(r))
}
}

values["roles"] = cty.TupleVal(roles)
values["roles"] = cty.TupleVal(roleList)
}

return values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
"go.mongodb.org/atlas-sdk/v20231115002/admin"
"go.mongodb.org/atlas-sdk/v20231115003/admin"
)

func TestAccConfigDSAlertConfiguration_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/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/v20231115002/admin"
"go.mongodb.org/atlas-sdk/v20231115003/admin"
)

const alertConfigurationsDataSourceName = "alert_configurations"
Expand Down Expand Up @@ -143,7 +143,7 @@ func (d *AlertConfigurationsDS) Read(ctx context.Context, req datasource.ReadReq
alertConfigurationsConfig.ID = types.StringValue(conversion.EncodeStateID(map[string]string{
"project_id": projectID,
}))
alertConfigurationsConfig.Results = NewTFAlertConfigurationDSModelList(alerts.Results, projectID, alertConfigurationsConfig.OutputType)
alertConfigurationsConfig.Results = NewTFAlertConfigurationDSModelList(conversion.SlicePtrToSlice(alerts.Results), projectID, alertConfigurationsConfig.OutputType)
if *params.IncludeCount {
alertConfigurationsConfig.TotalCount = types.Int64Value(int64(*alerts.TotalCount))
}
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/mwielbut/pointy"
"go.mongodb.org/atlas-sdk/v20231115002/admin"
"go.mongodb.org/atlas-sdk/v20231115003/admin"
)

func NewNotificationList(tfNotificationSlice []TfNotificationModel) ([]admin.AlertsNotificationRootForGroup, error) {
Expand Down Expand Up @@ -43,7 +43,7 @@ func NewNotificationList(tfNotificationSlice []TfNotificationModel) ([]admin.Ale
Username: n.Username.ValueStringPointer(),
VictorOpsApiKey: n.VictorOpsAPIKey.ValueStringPointer(),
VictorOpsRoutingKey: n.VictorOpsRoutingKey.ValueStringPointer(),
Roles: n.Roles,
Roles: conversion.NonEmptySliceToSlicePtr(n.Roles),
MicrosoftTeamsWebhookUrl: n.MicrosoftTeamsWebhookURL.ValueStringPointer(),
WebhookSecret: n.WebhookSecret.ValueStringPointer(),
WebhookUrl: n.WebhookURL.ValueStringPointer(),
Expand Down Expand Up @@ -108,8 +108,8 @@ func NewTFAlertConfigurationModel(apiRespConfig *admin.GroupAlertsConfig, currSt
Enabled: types.BoolPointerValue(apiRespConfig.Enabled),
MetricThresholdConfig: NewTFMetricThresholdConfigModel(apiRespConfig.MetricThreshold, currState.MetricThresholdConfig),
ThresholdConfig: NewTFThresholdConfigModel(apiRespConfig.Threshold, currState.ThresholdConfig),
Notification: NewTFNotificationModelList(apiRespConfig.Notifications, currState.Notification),
Matcher: NewTFMatcherModelList(apiRespConfig.Matchers, currState.Matcher),
Notification: NewTFNotificationModelList(conversion.SlicePtrToSlice(apiRespConfig.Notifications), currState.Notification),
Matcher: NewTFMatcherModelList(conversion.SlicePtrToSlice(apiRespConfig.Matchers), currState.Matcher),
}
}

Expand All @@ -121,7 +121,7 @@ func NewTFNotificationModelList(n []admin.AlertsNotificationRootForGroup, currSt
value := n[i]
notifications[i] = TfNotificationModel{
TeamName: conversion.StringPtrNullIfEmpty(value.TeamName),
Roles: value.Roles,
Roles: conversion.SlicePtrToSlice(value.Roles),
ChannelName: conversion.StringPtrNullIfEmpty(value.ChannelName),
DatadogRegion: conversion.StringPtrNullIfEmpty(value.DatadogRegion),
DelayMin: types.Int64PointerValue(conversion.IntPtrToInt64Ptr(value.DelayMin)),
Expand All @@ -145,7 +145,7 @@ func NewTFNotificationModelList(n []admin.AlertsNotificationRootForGroup, currSt
currState := currStateNotifications[i]
newState := TfNotificationModel{
TeamName: conversion.StringPtrNullIfEmpty(value.TeamName),
Roles: value.Roles,
Roles: conversion.SlicePtrToSlice(value.Roles),
// sentive attributes do not use value returned from API
APIToken: conversion.StringNullIfEmpty(currState.APIToken.ValueString()),
DatadogAPIKey: conversion.StringNullIfEmpty(currState.DatadogAPIKey.ValueString()),
Expand Down Expand Up @@ -303,8 +303,8 @@ func NewTfAlertConfigurationDSModel(apiRespConfig *admin.GroupAlertsConfig, proj
Enabled: types.BoolPointerValue(apiRespConfig.Enabled),
MetricThresholdConfig: NewTFMetricThresholdConfigModel(apiRespConfig.MetricThreshold, []TfMetricThresholdConfigModel{}),
ThresholdConfig: NewTFThresholdConfigModel(apiRespConfig.Threshold, []TfThresholdConfigModel{}),
Notification: NewTFNotificationModelList(apiRespConfig.Notifications, []TfNotificationModel{}),
Matcher: NewTFMatcherModelList(apiRespConfig.Matchers, []TfMatcherModel{}),
Notification: NewTFNotificationModelList(conversion.SlicePtrToSlice(apiRespConfig.Notifications), []TfNotificationModel{}),
Matcher: NewTFMatcherModelList(conversion.SlicePtrToSlice(apiRespConfig.Matchers), []TfMatcherModel{}),
}
}

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/v20231115002/admin"
"go.mongodb.org/atlas-sdk/v20231115003/admin"
)

const (
Expand Down Expand Up @@ -45,7 +45,7 @@ func TestNotificationSDKToTFModel(t *testing.T) {
SmsEnabled: admin.PtrBool(disabled),
EmailEnabled: admin.PtrBool(enabled),
ChannelName: admin.PtrString("#channel"),
Roles: roles,
Roles: conversion.NonEmptySliceToSlicePtr(roles),
ApiToken: admin.PtrString("newApiToken"),
},
},
Expand Down Expand Up @@ -290,7 +290,7 @@ func TestNotificationTFModelToSDK(t *testing.T) {
DelayMin: admin.PtrInt(delayMin),
SmsEnabled: admin.PtrBool(disabled),
EmailEnabled: admin.PtrBool(enabled),
Roles: roles,
Roles: conversion.NonEmptySliceToSlicePtr(roles),
},
},
},
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/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
"github.com/mwielbut/pointy"
"go.mongodb.org/atlas-sdk/v20231115002/admin"
"go.mongodb.org/atlas-sdk/v20231115003/admin"
)

const (
Expand Down Expand Up @@ -380,7 +380,7 @@ func (r *alertConfigurationRS) Create(ctx context.Context, req resource.CreateRe
apiReq := &admin.GroupAlertsConfig{
EventTypeName: alertConfigPlan.EventType.ValueStringPointer(),
Enabled: alertConfigPlan.Enabled.ValueBoolPointer(),
Matchers: NewMatcherList(alertConfigPlan.Matcher),
Matchers: conversion.NonEmptySliceToSlicePtr(NewMatcherList(alertConfigPlan.Matcher)),
MetricThreshold: NewMetricThreshold(alertConfigPlan.MetricThresholdConfig),
Threshold: NewThreshold(alertConfigPlan.ThresholdConfig),
}
Expand All @@ -390,7 +390,7 @@ func (r *alertConfigurationRS) Create(ctx context.Context, req resource.CreateRe
resp.Diagnostics.AddError(errorCreateAlertConf, err.Error())
return
}
apiReq.Notifications = notifications
apiReq.Notifications = conversion.NonEmptySliceToSlicePtr(notifications)

apiResp, _, err := connV2.AlertConfigurationsApi.CreateAlertConfiguration(ctx, projectID, apiReq).Execute()
if err != nil {
Expand Down Expand Up @@ -482,7 +482,7 @@ func (r *alertConfigurationRS) Update(ctx context.Context, req resource.UpdateRe
}

if !reflect.DeepEqual(alertConfigPlan.Matcher, alertConfigState.Matcher) {
apiReq.Matchers = NewMatcherList(alertConfigPlan.Matcher)
apiReq.Matchers = conversion.NonEmptySliceToSlicePtr(NewMatcherList(alertConfigPlan.Matcher))
}

// Always refresh structure to handle service keys being obfuscated coming back from read API call
Expand All @@ -491,7 +491,7 @@ func (r *alertConfigurationRS) Update(ctx context.Context, req resource.UpdateRe
resp.Diagnostics.AddError(errorUpdateAlertConf, err.Error())
return
}
apiReq.Notifications = notifications
apiReq.Notifications = conversion.NonEmptySliceToSlicePtr(notifications)

var updatedAlertConfigResp *admin.GroupAlertsConfig

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"
"testing"

"go.mongodb.org/atlas-sdk/v20231115002/admin"
"go.mongodb.org/atlas-sdk/v20231115003/admin"

"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
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/config"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/alertconfiguration"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
"go.mongodb.org/atlas-sdk/v20231115002/admin"
"go.mongodb.org/atlas-sdk/v20231115003/admin"
)

func TestAccConfigRSAlertConfiguration_basic(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions 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/v20231115002/admin"
"go.mongodb.org/atlas-sdk/v20231115003/admin"
)

const (
Expand Down Expand Up @@ -189,9 +189,9 @@ func newTFAtlasUserDSModel(user *admin.CloudAppUser) tfAtlasUserDSModel {
LastAuth: types.StringPointerValue(conversion.TimePtrToStringPtr(user.LastAuth)),
LastName: types.StringValue(user.LastName),
MobileNumber: types.StringValue(user.MobileNumber),
TeamIDs: user.TeamIds,
Links: newTFLinksList(user.Links),
Roles: newTFRolesList(user.Roles),
TeamIDs: conversion.SlicePtrToSlice(user.TeamIds),
Links: newTFLinksList(conversion.SlicePtrToSlice(user.Links)),
Roles: newTFRolesList(conversion.SlicePtrToSlice(user.Roles)),
}
}

Expand Down
6 changes: 3 additions & 3 deletions internal/service/atlasuser/data_source_atlas_user_test.go
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/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
"go.mongodb.org/atlas-sdk/v20231115002/admin"
"go.mongodb.org/atlas-sdk/v20231115003/admin"
)

func TestAccConfigDSAtlasUser_ByUserID(t *testing.T) {
Expand Down Expand Up @@ -66,8 +66,8 @@ func dataSourceChecksForUser(dataSourceName, attrPrefix string, user *admin.Clou
resource.TestCheckResourceAttr(dataSourceName, fmt.Sprintf("%smobile_number", attrPrefix), user.MobileNumber),
resource.TestCheckResourceAttr(dataSourceName, fmt.Sprintf("%scountry", attrPrefix), user.Country),
resource.TestCheckResourceAttr(dataSourceName, fmt.Sprintf("%screated_at", attrPrefix), *conversion.TimePtrToStringPtr(user.CreatedAt)),
resource.TestCheckResourceAttr(dataSourceName, fmt.Sprintf("%steam_ids.#", attrPrefix), fmt.Sprintf("%d", len(user.TeamIds))),
resource.TestCheckResourceAttr(dataSourceName, fmt.Sprintf("%slinks.#", attrPrefix), fmt.Sprintf("%d", len(user.Links))),
resource.TestCheckResourceAttr(dataSourceName, fmt.Sprintf("%steam_ids.#", attrPrefix), fmt.Sprintf("%d", len(*user.TeamIds))),
resource.TestCheckResourceAttr(dataSourceName, fmt.Sprintf("%slinks.#", attrPrefix), fmt.Sprintf("%d", len(*user.Links))),
// for assertion of roles the values of `user.Roles` must not be used as it has the risk of flaky executions. CLOUDP-220377
resource.TestCheckResourceAttrWith(dataSourceName, fmt.Sprintf("%sroles.#", attrPrefix), acc.IntGreatThan(0)),
resource.TestCheckResourceAttrSet(dataSourceName, fmt.Sprintf("%sroles.0.role_name", attrPrefix)),
Expand Down
Loading